Home arrow Java & J2EE arrow Page 2 - Overview of Java Web Technologies, Part 2

Sun's Solution - Java

Today, Budi walks us through a refresher and brief overview of server JSP programming. Today's portion covers JavaServer Pages (JSP), with a thorough overview of JavaBeans and Tags. This excerpt comes from chapter one of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).

  1. Overview of Java Web Technologies, Part 2
  2. Sun's Solution
  3. JSP and JavaBeans
  4. Calling a Bean from a JSP Page
  5. Accessing Bean Properties
  6. Custom Tags
  7. Developing and Using Custom Tag Libraries
  8. Writing a Tag Handler
  9. Writing and Using Tags
  10. Model 2 Architecture
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 9
March 03, 2004

print this article



Sunís solution to this problem is JSP. According to Sunís Web site, ďJSP technology is an extension of the servlet technology created to support authoring of HTML and XML pages.Ē Combining fixed or static template data with dynamic content is easier with JSP. JSP makes development more rapid than using servlets alone because it allows HTML tags to intersperse with Java code. No compilation is necessary. The first time a JSP page is invoked, the servlet/JSP container compiles it automatically. The MyLongServlet in the previous example can be rewritten in a JSP page like this:

<%@ page import="java.util.Enumeration" %> 

//Get parameter names 
Enumeration parameters = request.getParameterNames(); 
String param = null; 
while (parameters.hasMoreElements()) { 
param = (String) parameters.nextElement(); 
out.println(param + ":" + request.getParameter(param) + 


However, note that JSP did not make servlets obsolete. In fact, JSP pages and servlets coexist in many JavaWeb applications. And, bear in mind that JSP is an extension of servlets.

Inside the JSP container is a special servlet called the page compiler. The servlet container is configured to forward to this page compiler all HTTP requests with URLs that match the .jsp file extension. This page compiler turns a servlet container into a JSP container. When a JSP page is first called, the page compiler parses and compiles the JSP page into a servlet class. If the compilation is successful, the JSP servlet class is loaded into memory.

On subsequent calls, the servlet class for that JSP page is already in memory; however, it could have been updated. Therefore, the page compiler servlet will always compare the timestamp of the JSP servlet with the JSP page. If the JSP page is more current, recompilation is necessary.With this process, once deployed, JSP pages go through the time-consuming compilation process only once.

You may be thinking that after the deployment, the first user requests for a JSP page will experience unusually slow response, due to the time spent compiling the .jsp file into a JSP servlet. That scenario was anticipated, and to avoid this unpleasant situation, a mechanism in JSP allows the JSP pages to be precompiled before any user request for them is received. Alternatively, you can automatically load a JSP page by using the <load-on-startup> element under the <servlet> element in the deployment descriptor.

Buy this book now!Remember: This is part two of the first chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). Stay tuned for more chapters of developer books from McGraw-Hill/Osborne.
Buy this book!

>>> More Java & J2EE Articles          >>> More By McGraw-Hill/Osborne

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates


Dev Shed Tutorial Topics: