Chapter 25

JavaServer Pages and Servlets


Chapter Goals

Dynamic Web Content

Dynamic Web Content

File date.jsp

Executing the Date Page

Image of the web page executing date.jap

To Deploy the Date Page

  1. Type the JSP file into a text editor
  2. Place the file into a web application directory of your JSP engine
  3. If you use Tomcat, create a subdirectory for the JSP file
    c:\jakarta-tomcat\webapps\bigjava
    
  4. Place the date.jsp file into that directory
  5. Start the web server
  6. Point your browser to
    localhost:8080/bigjava/date.jsp

Dynamic Web Content

Dynamic Web Content

The JSP Container Rewrites the Requested Page

jsp page is converted to all HTML

Encapsulating Computations in JavaBeans

Encapsulating Computations in JavaBeans

Encapsulating Computations in JavaBeans

Encapsulating Computations in JavaBeans

Encapsulating Computations in JavaBeans

Encapsulating Computations in JavaBeans

File TimeFormatterBean.Java

File time.jsp

Encapsulating Computations in JavaBeans

Handling Request Parameters

Handling Request Parameters

Handling Request Parameters

File timezone.html

The HTML Form for Entering City Names

The HTML Form for Entering City Names

Handling Request Parameters

Handling Request Parameters

File timezone.jsp

File TimeZoneBean.java

The Output of the Time Zone JSP Page

The Output of the Time Zone JSP Page

HTML Forms

The HTML Form Elements

The HTML Form Elements

HTML Forms

HTML Forms

HTML Forms

HTML Forms

HTML Forms

Session Tracking

Session Tracking

Session Tracking

Asking for the First of Several Cities

Browser window Asking for the First of Several Cities

Asking for the Next City

browser wind asking for next city

Display the Time in Multiple Locations

browser window displaying mutliple cities and times

File multizone.html

File multizone.jsp

File MultiZoneBean.java

Branching and Forwarding Pages

Branching and Forwarding Pages

Branching and Forwarding Pages

File zonebranch.html

File zonebranch.jsp

File zoneresult.jsp

File zoneerror.jsp

A Three-Tier Application

A Three-Tier Application

A Three-Tier Application

A Three-Tier Application

File zonedb.html

File zonedb.jsp

File DataSourceBean.Java

File ZoneDBBean.Java

Servlets

Servlets

Servlets

Servlets

Servlets

File DateServlet.Java

Servlets

Servlets

Placement of Web Application Files

Placement of Web Application Files

Servlets

File zoneservlet.html

File TimeZoneServlet.Java

Compilation of JSP Pages