3.1.4 JavaServer Pages 
JavaServer Pages (JSP) are a server side extension to the servlet technology. A JavaServer 
Page is basically an HTML or XML page that contains scripting elements (scriptlets) and tags in 
addition to the regular page contents. A JSP engine always converts/compiles a page to a 
servlet prior to execution. JSP engines are included in most servlet engines, such as Tomcat. 
JSP's offer the following advantages over pure servlet programming: 
   JSP pages make it easier for a Web designer to generate pages with dynamic content. 
The Web designer can call so called  JavaBeans  (for an explanation, see below) with 
XML tag style commands, which most Web designers are familiar with. No additional 
programming skills are required. Therefore, JSP pages foster the concept of separating 
application logic from content presentation. 
   Web developers can use JSP pages for the generation of presentation driven contents, 
such as complex forms or outputs that would be cumbersome to implement with servlet 
programming only. 
JSP's use the following elements to extend the functionality of static HTML or XML pages with 
dynamic content: 
   Directives (enclosed within <%@ and %>) are short statements that are used to give the 
JSP engine information about the page that follows (such as page language, used 
packages, or whether the page should have session state). Directives also provide the 
means to include other HTML or JSP pages on the server side. 
   Declaratives (enclosed within <%! and %>) are used for page wide variable and method 
declarations. 
   Scriptlets (enclosed within <% and %>) contain Java code embedded in the page. Unlike 
client side JavaScript or VBScript, Scriptlet code is interpreted on the server side. 
   Expression Evaluations (enclosed within <%= and %>) offer a way to directly evaluate a 
variable or function to a String for inclusion in the output of the page. 
   JavaBean invocation and manipulation tags (enclosed within ). 
JavaBeans can be instantiated with the useBean command. In a nutshell, JavaBeans 
29 




Java Web Hosting Application Development Using Java Technologies Hosting




 
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved.