JavaServer Pages and Servlets: A Comparison

JSP is based on the concept of server-side parsing. A JSP page is an HTML page with Java statements embedded in it. JSP files do not have an extension of .html or .htm but rather a special extension, .jsp. This extension indicates to the server that the file is a JavaServer Page.

When a browser requests a JSP page from the server, the server identifies the page as a JSP page from the extension. The server does not return the JSP file as it is but rather processes it. The processing of the JSP file includes parsing it for special tags in the Java code in the file. The Java code in the JSP page is compiled by the server using a special compiler called a JSP compiler. If no errors are encountered by the compiler, the entire JSP page is compiled to a Java class file. This Java class file is essentially a Java servlet. The compiled Java servlet is then loaded by the server like any other Java servlet, and the processing continues.

So what happens to the HTML code in the JSP page? Well, the JSP compiler compiles the Java code and builds a Java servlet, and all the HTML statements in the JSP are automatically converted into out.println(...) statements by the compiler. Hence, instead of manually writing out.println(...) statements for the HTML code in your servlet, the JSP compiler generates it all for you. A simple way to manually compile your JSP using the JSP compiler supplied by WebLogic Server is with this command:

 java weblogic.jspc -options filename.jsp  

WebLogic's Support for JavaServer Pages

Now that you have an idea of what JavaServer Pages are all about, take a look at the support for JavaServer Pages provided by WebLogic.

From Figure 5.1 you can see that WebLogic Server contains a JSP engine to support the parsing, compiling, execution, and deployment of JavaServer Pages. The JSP engine in WebLogic Server version 7.0 supports the JavaServer Page API version 1.2 specification. Part of this support includes the following important features:

  • JSP tags Support for JSP tags is the primary feature in WebLogic Server. Four types of tags are supported by WebLogic Server: directive, declaration, expression, and scriptlet tags.

  • Custom JSP tag libraries The other major feature of JSP that is supported by WebLogic Server is the ability to create and use custom tag libraries in JSP pages.

Figure 5.1. WebLogic Server and its components: the JSP engine.

graphics/05fig01.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