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.


IoT & Smart Cities Stories
In his general session at 19th Cloud Expo, Manish Dixit, VP of Product and Engineering at Dice, discussed how Dice leverages data insights and tools to help both tech professionals and recruiters better understand how skills relate to each other and which skills are in high demand using interactive visualizations and salary indicator tools to maximize earning potential. Manish Dixit is VP of Product and Engineering at Dice. As the leader of the Product, Engineering and Data Sciences team at D...
Dynatrace is an application performance management software company with products for the information technology departments and digital business owners of medium and large businesses. Building the Future of Monitoring with Artificial Intelligence. Today we can collect lots and lots of performance data. We build beautiful dashboards and even have fancy query languages to access and transform the data. Still performance data is a secret language only a couple of people understand. The more busine...
Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
Nicolas Fierro is CEO of MIMIR Blockchain Solutions. He is a programmer, technologist, and operations dev who has worked with Ethereum and blockchain since 2014. His knowledge in blockchain dates to when he performed dev ops services to the Ethereum Foundation as one the privileged few developers to work with the original core team in Switzerland.
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
Whenever a new technology hits the high points of hype, everyone starts talking about it like it will solve all their business problems. Blockchain is one of those technologies. According to Gartner's latest report on the hype cycle of emerging technologies, blockchain has just passed the peak of their hype cycle curve. If you read the news articles about it, one would think it has taken over the technology world. No disruptive technology is without its challenges and potential impediments t...
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of San...
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, its about the data consumed and generated. The devices are tools, mechanisms, conduits. This paper discusses the considerations when dealing with the...