Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

JNDI and Web Applications on the WLS 6.0 Certification Test

JNDI and Web Applications on the WLS 6.0 Certification Test

Last month, I talked about signing up to take the BEA WebLogic Server 6.0 Certification test. At that time, I promised I would go into more detail about what you should study, and that's what I'm including for your use.

This article covers two specific topics on the test: the Java Naming and Directory Interface (JNDI) and Web applications.

But before we start, there's one thing I forgot to mention last month: another benefit of the study material is that there is a strong overlap of these topics with the Sun Web Component Developer for J2EE test. So, by studying for this test, you'll be studying for the Web Component Developer test as well.

Now I'm assuming most of you are fairly experienced J2EE developers, so I'll gloss over most of the material, just pointing out the important aspects of the test. I've also provided a set of review questions at the end of this article that will help readers of all skill levels prepare for the test. Let's get started.

The Java Naming and Directory Interface
There isn't too much direct coverage of JNDI on the test, but using JNDI is important and, therefore, requires a little attention. The primary thing to be concerned about is configuring an InitialContxt and knowing the java:comp naming convention to look up objects.

When you're configuring an InitialContext, an Environment object (or HashTable) is used to initialize the InitialContext. The Environment contains several properties that assist in configuring the InitialContext object. The property names, constants, and default values are shown in Table 1.

In addition to the normal naming convention used by WebLogic Server JNDI, the J2EE specification has defined a standard naming convention for the objects stored in a JNDI tree. You can read more about this naming convention at http://java.sun.com/products/jndi/
tutorial/beyond/misc/policy.html
, but Table 2 summarizes the important names to know.

That's more or less all you need to know about JNDI for the test. I would recommend having a good general knowledge of JNDI though, since it is used in some of the code in the test questions.

Web Applications
Now that I've covered a minor test topic, it's time to look at something a little more substantial. Web applications is one of the core topics of the BEA WebLogic Server 6.0 test. A good understanding of Web applications is extremely important to passing. Apart from the topic of Enterprise JavaBeans (EJBs), this is the most widely covered topic of the test, so be sure to study this area carefully. To make it easier, I'm going to break the Web applications section down into three areas: servlets, Java Server Pages (JSPs), and deployment.

When you prepare for the HTTP servlets portion, be sure to know the basics of creating an HTTP servlet. You should be familiar with servlet methods, how they are used, and when they are called. Table 3 illustrates the methods that are important to understand for the test.

Be sure to refamiliarize yourself with the HttpServletRequest class and its methods, such as getParameter(), which retrieves parameters from the request. In addition, study the HttpServletResponse and its methods, such as setContentType(), which is used to inform the client (browser) of which type of data is being sent back.

The HttpSession class represents the user's session. It is retrieved by the getSession() method of HttpServlet. Objects may be stored and retrieved from the HttpSession by using the putValue() and getValue() methods, respectively.

WebLogic Server exposes information about the servlet container through the ServletContext object. You can obtain the ServletContext by the getServletContext() method of ServletConfig, which is passed into your servlet's init() method. In addition, the ServletContext can be used to store data on the Web application's scope by using the getAttribute() and setAttribute() methods. It's important to note that, unlike data stored in the HttpSession object, data stored in the ServletContext may be used by all of the users of the Web application.

Java Servlet Pages
The next subtopic of Web applications is JSPs. Be sure to know the basics of creating a JSP and how WebLogic Server turns your page into a servlet. Also, be very familiar with the JSP tags used in creating a page (see Table 4). Below, I'll discuss each tag and what you should know about it.

Scriptlet
Understanding that a scriptlet is just a piece of Java code that will be placed in the service() method of the generated servlet is critical. The code used in a scriplet has access to built-in objects (see Table 5).

Declaration
A declaration is very similar to a scriptlet, but its code is placed at the class level of the generated servlet. Because of this, you can use declarations for defining methods or class-level variables. Since this code may be accessed by many users it should be synchronized for thread safety. Declarations have access to the same built-in objects that scriptlets do.

Expression
Not much to know here, but you should be aware that an expression returns the result of a single Java expression to the client. Also, realize that the expression must evaluate to a String.

Directive
A directive is an instruction to the JSP compiler that affects page compilation. An important fact to remember about directives is that they affect how the page is compiled, not how the page executes. Table 6 shows a list of directives. I'll break each of them down below.

PAGE Directive
Table 7 summarizes some possible values for a page directive.

Include Directive
The include directive textually includes the contents of a file into the JSP. It is important to distinguish between the include directive and the include action (see below). TAGLIB DIRECTIVE

The taglib directive specifies the location and usage of a tag library. There isn't much coverage of tag libraries on the WebLogic Server 6.0 test, but you may want to take some extra time out to review them if you are also looking to take the Sun Web Component Developer for J2EE test.

Action
Generically, an action is a reference from a tag library, but for the purposes of the test, be sure to know the standard set of actions JSP provides (see Table 8).

UseBean Action
The useBean action accesses a JavaBean object. It is not a valid way to use or create an Entity Java Bean. If the referenced JavaBean doesn't exist, it will be created. The useBean action specifies the scope at which the JavaBean exists (see Table 9).

To retrieve a bean programmatically from a different scope, the getAttribute(id) method of the proper scope object.

Include Action
Remember that the include action is different from the include directive. The include action delegates processing from one page to another by having the initial JSP page accept the request, call an included JSP page to perform some function, and then send the response back to the client.

Forward Action
Similar to the include action, the forward action also delegates processing from one page to another. However, the forward action works by having the initial JSP page accept the request and forward it to the next page. The last JSP page in the "chain" of pages sends the response back to the client. Multiple forwards may occur, but only the last page is allowed to send a response to the client.

Deployments
We're just about finished with the Web applications section. The last topic to cover here is deployment. Web application deployment is a mixed bag of information.

First, you should be familiar with the Web application directory structure and what each directory is used for (see Table 10).

There is quite a bit on deployment descriptors on the test, but most of the coverage relates to EJB. You should, however, be familiar enough with the descriptors to deploy a servlet and a JSP page. These go in the web.xml file. Examples of servlet and JSP deployment descriptors are shown in Listings 1 and 2.

Along with the deployment information, the web.xml configuration file also defines some security attributes. These security attributes specify how WebLogic Server handles security in a Web application (see Table 11).

And finally, although this really isn't deployment-related, it merits mention: you should know that WebLogic Server provides several servlets to handle incoming requests (see Table 12).

Review
As promised, I've prepared a short study test for you. The answers are provided at the end of the test questions. I'd advise taking the whole test at once and then checking your answers; this way, you'll see how well you'd have done on the real test.

Next time, we'll cover JDBC and EJB. Have fun studying!

1. What property of the InitialContext Environment affects how the InitialContext is created?

    a) weblogic.jndi.WLInitialContextFactory
    b) java.naming.factory.initial
    c) java.naming.provider.url
    d) java.naming.security.principal
2. What method of an InitialContext do you call to retrieve an object from the JNDI tree?
    a) lookup()
    b) find()
    c) bind()
    d) get()
3. Which servlet allows you to execute any other servlet in the classpath?
    a) FileServlet
    b) JspServlet
    c) ServletServlet
    d) CgiServlet
4. What method of the response should you call before you send any content back to the browser?
    a) setMIMEType()
    b) setContentType()
    c) setResponse()
    d) setContent()
5. What class can be used by a Servlet to store attributes at Web application scope?
    a) AppContext
    b) ServerScope
    c) SessionContext
    d) ServletContext
6. Which JSP tag includes a JSP page for executing at run-time?
    a)<%@ include file="somepage.jsp" %>
    b) <jsp:include page="somepage.jsp">
    c) <jsp:forward page="somepage.jsp">
    d) None of the above
7. If a JSP page has the isErrorPage directive set to true, which of the following is true?
    a) An intrinsic exception object is defined
    b) All exceptions raised by any page in the
    Web application are redirected to this page
    c) This page is displayed when the generate-
    Error()
    method is called
    d) All of the above
8. Select a valid way to call an EJB from a JSP page:
    a) Utilize a standard JSP directive
    b) EJB Creation code in scriptlet
    c) action
    d) All of the above
9. Which deployment descriptor contains the url-pattern used to map a servlet or a JSP to a URL?
    a)
    b)
    c)
    d)
10. Which Web application directory houses the deployment descriptor file weblogic.xml?
    a) The Web application root
    b) META-INF
    c) WEB-INF
    d) There is no deployment descriptor file
    named weblogic.xml.
Answer Key
    1. b 2. a 3. c 4. b 5. d 6. b 7. a 8. b 9. c 10. c

More Stories By Dave Cooke

David Cooke is an experienced software developer, currently working for Ness Technologies, Inc. a consulting firm located in Dulles, VA. In his current position, Mr. Cooke utilizes Java and BEA WebLogic Server 6.0 to build J2EE-compliant e-commerce systems for a variety of clients. Mr. Cooke has a bachelor's degree in Computer Science from George Mason University and maintains Microsoft, Java and BEA developer certifications.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
An increasing number of companies are creating products that combine data with analytical capabilities. Running interactive queries on Big Data requires complex architectures to store and query data effectively, typically involving data streams, an choosing efficient file format/database and multiple independent systems that are tied together through custom-engineered pipelines. In his session at @BigDataExpo at @ThingsExpo, Tomer Levi, a senior software engineer at Intel’s Advanced Analytics gr...
When talking IoT we often focus on the devices, the sensors, the hardware itself. The new smart appliances, the new smart or self-driving cars (which are amalgamations of many ‘things’). When we are looking at the world of IoT, we should take a step back, look at the big picture. What value are these devices providing? IoT is not about the devices, it’s about the data consumed and generated. The devices are tools, mechanisms, conduits. In his session at Internet of Things at Cloud Expo | DXWor...
Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution. In his session at @ThingsExpo, Akvelon expert and IoT industry leader Sergey Grebnov provided an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...