Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
44
Chapter 2 First Servlets
Figure 2 7
Specifying initialization parameters for a named servlet with the Java Web 
Server.
2.8 An Example Using Servlet Initialization 
and Page Modification Dates
Listing 2.11 shows a servlet that uses 
init
 to do two things. First, it builds an
array of 10 integers. Since these numbers are based upon complex calcula 
tions, I don't want to repeat the computation for each request. So I have
doGet
 look up the values that 
init
 computed instead of generating them
each time. The results of this technique are shown in Figure 2 8. 
However, since all users get the same result, 
init
 also stores a page modifi 
cation date that is used by the 
getLastModified
 method. This method should
return a modification time expressed in milliseconds since 1970, as is standard
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved