Sample Program

You will be implementing your BookShoppingServlet using JavaServer Pages; see Listing 5.1.

Listing 5.1 ShoppingCartJsp.jsp
 /******************************************************************************   * Class Name   :ShoppingCartJsp.jsp   * Description  :First JSP of the JSP counterpart of Shopping Cart Application   * @author Mandar S. Chitnis, Lakshmi AM.       @version 1.1   * Copyright © by Sams Publishing. All Rights Reserved. *******************************************************************************/ <!-- Creates an HTML page that is used to demonstrate the shopping cart example <%@ page import="com.sams.learnweblogic7.utils.*, com.sams.learnweblogic7.servlets.*, java.util.*" %> <%! Book book1; %> <%! Book book2; %> <%! Book book3; %> <%! ServletContext sc; %> <%! Hashtable shoppingCartHash = null; %> <%! HttpSession session; %> <%! private static final int DEFAULT_ZERO_VALUE = 0; %> <%         sc = getServletConfig().getServletContext();         session = request.getSession(true);         if(session.isNew()){             //getting the init params             String book1Id = config.getInitParameter("book1Id");             String book1Name = config.getInitParameter("book1Name");             double book1Price = new Double(config.getInitParameter("book1Price")).doubleValue();             String book1Image = config.getInitParameter("book1Image");             String book1Description = config.getInitParameter("book1Description");             book1 = new Book(book1Id, book1Name, book1Price, book1Image, book1Description);             sc.setAttribute("book1",book1);             String book2Id = config.getInitParameter("book2Id");             String book2Name = config.getInitParameter("book2Name");             double book2Price = new Double(config.getInitParameter("book2Price")).doubleValue();             String book2Image = config.getInitParameter("book2Image");             String book2Description = config.getInitParameter("book2Description");             book2 = new Book(book2Id, book2Name, book2Price, book2Image, book2Description);             sc.setAttribute("book2",book2);             String book3Id = config.getInitParameter("book3Id");             String book3Name = config.getInitParameter("book3Name");             double book3Price = new Double(config.getInitParameter("book3Price")).doubleValue();             String book3Image = config.getInitParameter("book3Image");             String book3Description = config.getInitParameter("book3Description");             book3 = new Book(book3Id, book3Name, book3Price, book3Image, book3Description);             sc.setAttribute("book3",book3);             //create an empty shopping cart hashtable,             //with zero quantity for each book id             shoppingCartHash = new Hashtable();             shoppingCartHash.put(book1.getBookId(),                     new Integer(DEFAULT_ZERO_VALUE));             shoppingCartHash.put(book2.getBookId(),                     new Integer(DEFAULT_ZERO_VALUE));             shoppingCartHash.put(book3.getBookId(),                     new Integer(DEFAULT_ZERO_VALUE));             session.setAttribute("shoppingCartHash", shoppingCartHash);         }         else         {             book1 = (Book)sc.getAttribute("book1");             book2 = (Book)sc.getAttribute("book2");             book3 = (Book)sc.getAttribute("book3");             String clickedButton = (request.getParameter("buttonName") == null)?"":         request.getParameter("buttonName");             if(clickedButton.equals("view"))             {                     RequestDispatcher rd = sc.getRequestDispatcher("/ViewCartJsp");                     //here, if you use include, it will show the view cart page                     //and the page following this scriptlet tag                     rd.forward(request,response);             }             else if(clickedButton.equals("add"))             {                 shoppingCartHash= (session.getAttribute("shoppingCartHash") == null)?newHashtable():         (Hashtable)session.getAttribute("shoppingCartHash");                 int Book1Qty = Utility.getDefaultValue                         (((Integer)shoppingCartHash.get                         (book1.getBookId())).toString(),                         DEFAULT_ZERO_VALUE)+Utility.getDefaultValue                         (request.getParameter("book1_qty"),DEFAULT_ZERO_VALUE);                 int Book2Qty = Utility.getDefaultValue                         (((Integer)shoppingCartHash.get                         (book2.getBookId())).toString(),                         DEFAULT_ZERO_VALUE)+Utility.getDefaultValue                         (request.getParameter("book2_qty"),DEFAULT_ZERO_VALUE);                 int Book3Qty = Utility.getDefaultValue                         (((Integer)shoppingCartHash.get                         (book3.getBookId())).toString(),                         DEFAULT_ZERO_VALUE)+Utility.getDefaultValue                         (request.getParameter("book3_qty"),DEFAULT_ZERO_VALUE);                 shoppingCartHash.put(book1.getBookId(), new Integer(Book1Qty));                 shoppingCartHash.put(book2.getBookId(), new Integer(Book2Qty));                 shoppingCartHash.put(book3.getBookId(), new Integer(Book3Qty));                 session.setAttribute("shoppingCartHash", shoppingCartHash);             }         } %> <HTML> <HEAD>     <TITLE>         Shopping Cart Example using JSP's and HTTP session     </TITLE> </HEAD> <BODY> <FORM name="addcart" action="/ShoppingApp/ShoppingCartJsp" method="post"> <B><font face = "Verdana" color="blue" size=-2>    <p align = "right">Shopping Cart using JSP's and Http Session</p> </font></B> <CENTER><B>Most popular books from Sams Publishing</B></CENTER><BR> <TABLE width = 100%> <TR>    <TH>&nbsp;</TH>    <TH>Book Name and Description</TH>    <TH>Book Price</TH><TH>No of Books to add to cart</TH> </TR> <TR bgcolor='#cccc99'>    <TD><img src="/books/2/96/1/html/2/<%= book1.getImagePath()%>"></TD>    <TD align='left'><b><%=book1.getBookName()%></b>            <BR><%= book1.getBookDescription()%></TD>    <TD align='center'>$<%= book1.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book1_qty' size = 3></TD> </TR> <TR bgcolor='#eeeeee'>    <TD><img src="/books/2/96/1/html/2/<%= book2.getImagePath()%>"></TD>    <TD align='left'><b><%=book2.getBookName()%></b>            <BR><%= book2.getBookDescription()%></TD>    <TD align='center'>$<%= book2.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book2_qty' size = 3></TD> </TR> <TR bgcolor='#cccc99'>    <TD><img src="/books/2/96/1/html/2/<%= book3.getImagePath()%>"></TD>    <TD align='left'><b><%=book3.getBookName()%></b>            <BR><%= book3.getBookDescription()%></TD>    <TD align='center'>$<%= book3.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book3_qty' size = 3></TD> </TR> </TD></TR></TABLE><BR> <CENTER><TABLE width = 100%><TR> <TD><INPUT type="submit" name="buttonName" value="add"></TD> <TD><INPUT type="submit" name="buttonName" value="view"></TD> </TR></TABLE></CENTER> </FORM> </BODY> </HTML> 

Because you are already aware of the functionality of the application, you will be focusing attention on the use of the different JSP tags that you studied in this application.

The directive tag was used at the very beginning of the JSP:

 <%@ page import="com.sams.learnweblogic7.utils.*,  com.sams.learnweblogic7.servlets.*, java.util.*" %> 

The page directive used here tells the JSP engine to import classes from the com.sams.learnweblogic7.utils, com.sams.learnweblogic7.servlets, and java.util packages.

The next tag that you use is the declaration tag. Recall that the declaration tag is used to declare variables or methods outside the service() method. You utilize this feature of the declaration tag to declare the global variables for your class.

The following statements show the use of the declaration tag to declare your global variables book1, book2, book3, servlet context, shoppingCart hash table and the HttpSession session object:

 <%! Book book1; %>  <%! Book book2; %> <%! Book book3; %> <%! ServletContext sc; %> <%! Hashtable shoppingCartHash = null; %> <%! HttpSession session; %> <%! private static final int DEFAULT_ZERO_VALUE = 0; %> 

This is similar to the declarations that you made in your BookShoppingServlet. You need not declare a variable for HttpSession. You can just as well use the implicit variable session provided in the JSP specification.

Now that you have imported the necessary packages and declared your variables, you will proceed to embedding the actual Java code in the HTML file. You will use the scriptlet tag to embed the Java code:

 <%          sc = getServletConfig().getServletContext();         session = request.getSession(true);         if(session.isNew()){             //getting the init params             String book1Id = config.getInitParameter("book1Id");             String book1Name = config.getInitParameter("book1Name");             double book1Price = new Double(config.getInitParameter("book1Price")).doubleValue();             String book1Image = config.getInitParameter("book1Image");             String book1Description = config.getInitParameter("book1Description");             book1 = new Book(book1Id, book1Name, book1Price, book1Image, book1Description);             sc.setAttribute("book1",book1); ... %> 

The preceding code snippet shows the use of normal Java statements in the HTML file. In this code snippet, you are trying to determine whether the session is a new session. If it is a new session, you will initialize the Book object variables (your global variables) to the values retrieved from the web.xml file. The initialization values will be set in the web.xml file when you deploy the JSP in the WebLogic Server. If the session is not a new session, you are processing the user request to identify the type of request (view or add) and process it accordingly. To retrieve the user data, you are using the implicit variable request and its method getParameter(). This is similar to the code in the BookShoppingServlet, where you used the HttpServletRequest class and its method getParameter(). The request implicit variable is the same as the HttpServletRequest class.

Here is another interesting code snippet that you should note:

             if(clickedButton.equals("view"))              {                     RequestDispatcher rd = sc.getRequestDispatcher("/ViewCartJsp");                     //here, if you use include, it will show the view cart page                     //and the page following this scriptlet tag                     rd.forward(request,response);             } 

Here you use the request dispatcher mechanism to perform "inter-JSP" communication. It is simply a forwarding of the request and response objects to the ViewCartJsp and is a simple example of JSP chaining. Since the next JSP receives the request and response objects, it can read the user data as well as send a response to the browser.

Finally you will see the expression tag:

 <TR bgcolor='#cccc99'>     <TD><img src="/books/2/96/1/html/2/<%= book1.getImagePath()%>"></TD>    <TD align='left'><b><%=book1.getBookName()%></b>            <BR><%= book1.getBookDescription()%></TD>    <TD align='center'>$<%= book1.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book1_qty' size = 3></TD> </TR> 

In the preceding code snippet, you see the use of the expression tag to generate the path of the image file in the <img src= HTML code. The image file path is retrieved from the book1 object using the getImagePath() method and included with the HTML code using the expression tag. The JSP engine evaluates the value by invoking the getImagePath() method when the JSP is compiled into the servlet and loaded by the WebLogic Server's JSP engine.

When the View button is clicked, you forward the request to the ViewCartJsp.jsp. Take a quick look at the ViewCartJsp.jsp file (see Listing 5.2).

Listing 5.2 ViewCartJsp.jsp
 /******************************************************************************   * Class Name   :ViewCartJsp.jsp   * Description  :Second JSP of the JSP counterpart of Shopping Cart Application   *               Displays the contents of the shopping cart   * @author Mandar S. Chitnis, Lakshmi AM.       @version 1.1   * Copyright  by Sams Publishing. All Rights Reserved. *******************************************************************************/ <!-- Creates an HTML page that is used to demonstrate the shopping cart example <%@ page import="com.sams.learnweblogic7.utils.*, com.sams.learnweblogic7.servlets.*, java.util.*" %> <%! Book book1; %> <%! Book book2; %> <%! Book book3; %> <%! ServletContext sc; %> <%! Hashtable shoppingCartHash = null; %> <%! HttpSession session; %> <%! private static final int DEFAULT_ZERO_VALUE = 0; %> <%         sc = getServletConfig().getServletContext();         session = request.getSession(true);         if(session.isNew()){             //getting the init params             String book1Id = config.getInitParameter("book1Id");             String book1Name = config.getInitParameter("book1Name");             double book1Price = new Double(config.getInitParameter("book1Price")).doubleValue();             String book1Image = config.getInitParameter("book1Image");             String book1Description = config.getInitParameter("book1Description");             book1 = new Book(book1Id, book1Name, book1Price, book1Image, book1Description);             sc.setAttribute("book1",book1);             String book2Id = config.getInitParameter("book2Id");             String book2Name = config.getInitParameter("book2Name");             double book2Price = new Double(config.getInitParameter("book2Price")).doubleValue();             String book2Image = config.getInitParameter("book2Image");             String book2Description = config.getInitParameter("book2Description");             book2 = new Book(book2Id, book2Name, book2Price, book2Image, book2Description);             sc.setAttribute("book2",book2);             String book3Id = config.getInitParameter("book3Id");             String book3Name = config.getInitParameter("book3Name");             double book3Price = new Double(config.getInitParameter("book3Price")).doubleValue();             String book3Image = config.getInitParameter("book3Image");             String book3Description = config.getInitParameter("book3Description");             book3 = new Book(book3Id, book3Name, book3Price, book3Image, book3Description);             sc.setAttribute("book3",book3);             //create an empty shopping cart hashtable,             //with zero quantity for each book id             shoppingCartHash = new Hashtable();             shoppingCartHash.put(book1.getBookId(),                     new Integer(DEFAULT_ZERO_VALUE));             shoppingCartHash.put(book2.getBookId(),                     new Integer(DEFAULT_ZERO_VALUE));             shoppingCartHash.put(book3.getBookId(),                     new Integer(DEFAULT_ZERO_VALUE));             session.setAttribute("shoppingCartHash", shoppingCartHash);         }         else         {             book1 = (Book)sc.getAttribute("book1");             book2 = (Book)sc.getAttribute("book2");             book3 = (Book)sc.getAttribute("book3");             String clickedButton = (request.getParameter("buttonName") ==                     null)?"":request.getParameter("buttonName");             if(clickedButton.equals("view"))             {                     RequestDispatcher rd = sc.getRequestDispatcher("/ViewCartJsp");                     //here, if you use include, it will show the view cart page                    //and the page following this scriptlet tag                     rd.forward(request,response);             }             else if(clickedButton.equals("add"))             {                 shoppingCartHash= (session.getAttribute("shoppingCartHash") == null)?new Hashtable():         (Hashtable)session.getAttribute("shoppingCartHash");                 int Book1Qty = Utility.getDefaultValue                         (((Integer)shoppingCartHash.get                         (book1.getBookId())).toString(),                         DEFAULT_ZERO_VALUE)+Utility.getDefaultValue                         (request.getParameter("book1_qty"),DEFAULT_ZERO_VALUE);                 int Book2Qty = Utility.getDefaultValue                         (((Integer)shoppingCartHash.get                         (book2.getBookId())).toString(),                         DEFAULT_ZERO_VALUE)+Utility.getDefaultValue                         (request.getParameter("book2_qty"),DEFAULT_ZERO_VALUE);                 int Book3Qty = Utility.getDefaultValue                         (((Integer)shoppingCartHash.get                         (book3.getBookId())).toString(),                         DEFAULT_ZERO_VALUE)+Utility.getDefaultValue                         (request.getParameter("book3_qty"),DEFAULT_ZERO_VALUE);                 shoppingCartHash.put(book1.getBookId(), new Integer(Book1Qty));                 shoppingCartHash.put(book2.getBookId(), new Integer(Book2Qty));                 shoppingCartHash.put(book3.getBookId(), new Integer(Book3Qty));                 session.setAttribute("shoppingCartHash", shoppingCartHash);             }         } %> <HTML> <HEAD>     <TITLE>         Shopping Cart Example using JSP's and HTTP session     </TITLE> </HEAD> <BODY> <FORM name="addcart" action="/ShoppingApp/ShoppingCartJsp" method="post"> <B><font face = "Verdana" color="blue" size=-2>    <p align = "right">Shopping Cart using JSP's and Http Session</p> </font></B> <CENTER><B>Most popular books from Sams Publishing</B></CENTER><BR> <TABLE width = 100%> <TR>    <TH>&nbsp;</TH>    <TH>Book Name and Description</TH>    <TH>Book Price</TH>    <TH>No of Books to add to cart</TH> </TR> <TR bgcolor='#cccc99'>    <TD><img src="/books/2/96/1/html/2/<%= book1.getImagePath()%>"></TD>    <TD align='left'><b><%=book1.getBookName()%></b>            <BR><%= book1.getBookDescription()%></TD>    <TD align='center'>$<%= book1.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book1_qty' size = 3></TD> </TR> <TR bgcolor='#eeeeee'>    <TD><img src="/books/2/96/1/html/2/<%= book2.getImagePath()%>"></TD>    <TD align='left'><b><%=book2.getBookName()%></b>            <BR><%= book2.getBookDescription()%></TD>    <TD align='center'>$<%= book2.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book2_qty' size = 3></TD> </TR> <TR bgcolor='#cccc99'>    <TD><img src="/books/2/96/1/html/2/<%= book3.getImagePath()%>"></TD>    <TD align='left'><b><%=book3.getBookName()%></b>            <BR><%= book3.getBookDescription()%></TD>    <TD align='center'>$<%= book3.getBookPrice()%></TD>    <TD align='center'><INPUT type = 'text' name='book3_qty' size = 3></TD> </TR> </TD></TR></TABLE><BR> <CENTER><TABLE width = 100%><TR> <TD><INPUT type="submit" name="buttonName" value="add"></TD> <TD><INPUT type="submit" name="buttonName" value="view"></TD> </TR></TABLE></CENTER> </FORM> </BODY> </HTML> 

In this JSP, you are using all the JSP tag types available. At the start of the JSP, you use the page directive tag to import the com.sams.learnweblogic7.utils, com.sams.learnweblogic7.servlets, and the java.util packages:

 <%@ page import="com.sams.learnweblogic7.utils.*,  com.sams.learnweblogic7.servlets.*, java.util.*"%%> 

After this you declare the global variables for this JSP using the declaration tag:

 <%! Book book1; %>  <%! Book book2; %> <%! Book book3; %> <%! ServletContext sc; %> <%! Hashtable shoppingCartHash = null; %> <%! HttpSession session; %> <%! private static final int DEFAULT_ZERO_VALUE = 0; %> 

The main Java code is embedded in the scriptlet tags. Here is a code snippet:

 <%          sc = getServletConfig().getServletContext();         book1 = (Book)sc.getAttribute("book1");         book2 = (Book)sc.getAttribute("book2");         book3 = (Book)sc.getAttribute("book3");         shoppingCartHash=(session.getAttribute("shoppingCartHash") == null)?                 new Hashtable():(Hashtable)session.                 getAttribute("shoppingCartHash"); ... %> 

You terminate the user's session when this JSP is loaded using this statement:

 <% weblogic.servlet.security.ServletAuthentication.invalidateAll(request); %>  

This is similar to the session invalidation that you performed in the BookShoppingServlet.

The next step to be carried out is deploying the JSP.

Deploy the Program

Notice the change in the steps that you are performing for the Web application implemented using JSP. Normally, after writing the source code of the application, you would expect to compile it, deploy it, and then execute it. In JSPs that is not so. Since compiling the file is the responsibility of the WebLogic Server, you just need to deploy the JSP application in the WebLogic environment. The deployment activities that need to be carried out are explained in the following sections.

Creating a .war Web Archive File

This is an optional step since you have a simple Web application based on only JSP. For larger applications consisting of different classes and servlets, it is recommended that you carry out this step and prepare a Web archive file. For this application you can skip this step.

Registering your JSP in web.xml

JSPs need not be explicitly registered in the deployment descriptor file web.xml. They only need to be placed in the root directory (or any subdirectory) of the Web application (which you defined on Day 3 for servlet Web applications). For this example, this directory is

 c:\bea\user_domains\mydomain\applications\ShoppingApp  

So how does the server know it is a JavaServer Page? On receiving a request from the browser for a JSP, the WebLogic Server detects the extension .jsp in the request and looks in the application directory (specified in the URL) to parse and compile the JSP and generate the final servlet. There is another way to register JSPs as servlets:

 <servlet>      <servlet-name>ShoppingCartJsp</servlet-name>     <jsp-file>ShoppingCartJsp.jsp</jsp-file> </servlet> 

After registering the servlet, you need to map it to an appropriate URL:

 <servlet-mapping>      <servlet-name>ShoppingCartJsp</servlet-name>     <url-pattern>/ShoppingCartJsp</url-pattern> </servlet-mapping> 

For the ShoppingCartJsp.jsp you will be defining the following initialization parameters for initializing your three book objects:

 <init-param>     <param-name>book1Id</param-name>    <param-value>BK0001</param-value> </init-param> <init-param>    <param-name>book1Name</param-name>    <param-value>Sams Teach yourself Adobe(R) Photoshop in 24 hours -            by Carla Rose</param-value> </init-param> <init-param>    <param-name>book1Price</param-name>    <param-value>18</param-value> </init-param> <init-param>    <param-name>book1Image</param-name>    <param-value>/ShoppingApp/images/book1Image.jpg</param-value> </init-param> <init-param>    <param-name>book1Description</param-name>    <param-value>Learn Adobe with great examples</param-value>    </init-param> <init-param>    <param-name>book2Id</param-name>    <param-value>BK0002</param-value> </init-param> <init-param>    <param-name>book2Name</param-name>    <param-value>Sams Teach Yourself Web Publishing with HTML and XHTML in 21            Days (Third Edition)  by Laura Lemay, et al; </param-value> </init-param> <init-param>    <param-name>book2Price</param-name>    <param-value>25</param-value> </init-param> <init-param>    <param-name>book2Image</param-name>    <param-value>/ShoppingApp/images/book2Image.jpg</param-value> </init-param> <init-param>    <param-name>book2Description</param-name>    <param-value>The best way to learn it yourself! Be the best in technology            with HTML and XHTML</param-value> </init-param> <init-param>    <param-name>book3Id</param-name>    <param-value>BK0003</param-value> </init-param> <init-param>    <param-name>book3Name</param-name>    <param-value>Sams Teach Yourself Adobe(R) Illustrator(R) 9 in 24 Hours            -- by Mordy Golding;</param-value> </init-param> <init-param>    <param-name>book3Price</param-name>    <param-value>14</param-value> </init-param> <init-param>    <param-name>book3Image</param-name>    <param-value>/ShoppingApp/images/book3Image.jpg</param-value> </init-param> <init-param>    <param-name>book3Description</param-name>    <param-value>Another of the great Sams series - learn everything you need            to know about Adobe Illustrator in just 24 hours!</param-value> </init-param> 

This technique enables you to leverage all the deployment descriptor facilities available in servlets, such as initial parameters, security, and so on, for your JSP application. Your deployment descriptor file, web.xml, should look similar to Figure 5.4.

Figure 5.4. Registering the JSP as a servlet in the web.xml file.

graphics/05fig04.jpg

Setting WebLogic Server Specific Parameters

JSPs normally do not have any WebLogic Server specific parameters that need to be defined in the weblogic.xml deployment descriptor file. The tags are listed here:

 <jsp-descriptor>     <jsp-param>       <param-name>param1</param-name>       <param-value>value1</param-value>    </jsp-param> </jsp-descriptor> 

Some of the important parameter names and their values for the <param-name> and <param-value> tags are:

  • compileCommand The default value is %JDK_HOME%/javac.exe. If you have a custom compiler, you can specify it here.

  • keepgenerated The default value is false. If set to true, this flag instructs the WebLogic Server to keep the Java files generated after the parsing and not to delete them. By default, the generated servlet Java files are deleted since the default value is false.

  • pageCheckSeconds The default value is 1. You can specify in seconds the interval at which the WebLogic Server checks for any new or modified JSPs that need to be recompiled. Setting a value of 0 causes the WebLogic Server to check for modified JSP files on every browser request. A value of -1 disables the page checking.

    Tip

    During development, set a value of 0 for pageCheckSeconds to enable the WebLogic Server to always pick the latest modified JSP that you are working on. Since pageCheckSeconds reduces the performance of the WebLogic Server, set this value to -1 when you are deploying your JSPs during production.


  • verbose The default is true. This parameter enables you to debug any errors that may have occurred either during JSP parsing, during compilation, or at runtime. This debugging information is displayed in the browser as well as in the WebLogic log file.

  • workingDir The default value is any internally generated directory. The workingDir parameter's value is the directory where the precompiled Java code and class file of the JSP are stored. You can give any directory path you like for this parameter. Setting a value for this parameter enables you to check the precompiled files for any errors during debugging.

Compile the Program

JavaServer Pages do not need to be explicitly compiled by the developer. You need to place the JSPs in the appropriate directory for deployment and register the directory in the deployment descriptor files; the WebLogic Server will automatically compile the JSP to create a servlet and load the servlet so that the servlet can start processing browser requests! That's all there is to it. No cumbersome CLASSPATHs to be set, no recompiling to be done! The deployment directory for the JSPs in the ShoppingCartJsp.jsp is

 c:\bea\user_domains\mydomain\applications\ShoppingApp  

as shown in the screen shot in Figure 5.5.

Figure 5.5. The directory structure.

graphics/05fig05.jpg

To verify that the JSP has been successfully compiled, you can check the precompiled files generated by the JSP compiler. The JSP compiler generates the precompiled servlet Java file and then compiles this file to generate the .class file. The .class file is what is loaded by the WebLogic Server. The precompiled files are generated in the c:\bea\user_domains\mydomain\applications\temp directory.

Execute the Program

The Book Listing page is invoked from the browser by calling the following URL:

http://localhost:7001/ShoppingApp/ShoppingCartJsp

Figures 5.6 and 5.7 show the screen shots of the two screens generated by the JSPs.

Figure 5.6. Book Listing screen of the JSP.

graphics/05fig06.jpg

Figure 5.7. View Cart screen of the JSP.

graphics/05fig07.jpg



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net