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
Organizations do not need a Big Data strategy; they need a business strategy that incorporates Big Data. Most organizations lack a road map for using Big Data to optimize key business processes, deliver a differentiated customer experience, or uncover new business opportunities. They do not understand what’s possible with respect to integrating Big Data into the business model.
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
SYS-CON Events announced today that Dasher Technologies 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. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they b...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, 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. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
SYS-CON Events announced today that TidalScale 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. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of 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. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...