Error Pages, Comments, and Deployment Descriptors

An earlier section discussed how to include the implicit exception object for JSP pages. This object is provided to a JSP error page, using the following page directive:

<%@ page isErrorPage="true" %>

You can also provide a specific JSP error page containing your error text.

JSP Error Page

The following is a complete JSP error page similar to the one used in the WebAuction application. The error page accesses the implicit exception object and prints out a stack trace of the error:

<%@ page isErrorPage="true" %>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <title>WebLogic Server WebAuction Error</title>
</head>
<body text="#000000" bgcolor="#FFFFFF"
 link="#0000EE" vlink="#551A8B" alink="#FF0000">

<P>An error occurred while processing the WebLogic Server WebAuc-
tion:</P>

<%= exception.printStackTrace(); %>
<P>If this error persists, please contact the site administra-
tor</p>

</body>
</html>

JSP Comments

There are two different types of comments in JSP pages. The first enables you to generate comments in the output that is sent to client Web browsers:

<!-- comments ... -->

These comments are ignored by WebLogic Server. If you want to generate comments that have dynamic data, you can include JSP expressions in the comments code:

<!-- comments <%= expression %> more comments ... -->

These comments show up in the Web browser. If you would like to generate comments that only stay in the JSP page and are not sent to client Web browsers, you can use the following syntax to create a JSP comment:

<%-- comments comments ... --%>

The body of the comments is ignored completely. Comments are useful for documentation but also to “comment out” some portions of a JSP page. Note that JSP comments do not nest, so you cannot place multiple sets of comments inside of other comments.

JSP Deployment Descriptor Options

It is often desirable to have a Web application be precompiled at deployment time. To do this, add the following to your weblogic.xml deployment descriptor:

     <jsp-descriptor>
      <jsp-param>
           <param-name>
           precompile
           </param-name>
           <param-value>
           TRUE
           </param-value>
      </jsp-param>
</jsp-descriptor>

To hide the .jsp extension to your JSP pages, you can map them as servlets inside your web.xml deployment descriptor:

<servlet>
  <servlet-name>browse</servlet-name>
  <jsp-file>browseitems.jsp</jsp-file>
</servlet>

The URL path /browse/ would be mapped to resolve browseitems.jsp, hiding the fact that you're using JSP pages.

You can find the complete description of the functionality for both types of Web deployment descriptors on the WebLogic Server Web site at http://e-docs.bea.com/wls/docs60/programming/weblogic_xml.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.48.181