Consider the pages that you have seen that are doing select statements on your data source.They are pulling data out of the database, formatting it, and presenting it in a JSP. Every request for these JSPs will involve a hit on the database, even though the page created might be the same for multiple users. Also, after the data has been extracted once, it could be cached for use by other pages.The next section will explore the concept of content caching and how current JSP technology enables content caching to take place.
Caching JSP Output
One way of caching is to cache the output from the JSP servlets so that when the page is requested again, the content comes from a cache rather than being dynamically created over again.
As part of the Jakarta Taglibs project, there is a cache tag library being developed. In fact, only two tags are in the library: cache and invalidate. More information can be obtained from This caching mechanism can be very attractive because not only are you reducing the load on the database, you are also reducing the processing load as the servlets will not always need to generate the output. However, this mechanism is not always sufficient. If you have any personalization in your site, pages will frequently be different for different people within your site. For sites where the output is fairly static for different users, and the database content does not change much, this can be of significant benefit.
Caching Database Content
An alternative to caching the JSP output is to cache the content of the database.This is a popular strategy because it reduces the hit on the database without restricting the dynamic content in any way. One of the easiest ways to do this is with the use of JavaBeans. JavaBeans can be accessed relatively easily from pages using the JavaBean-specific standard actions:<jsp:useBean><jsp:setProperty><jsp:getProperty>
If the data is cached within Beans, not only does it reduce the load on the database, but it is also a relatively straightforward process to access the data from your JavaServer Pages. To demonstrate this, the shopping-cart application from Topic,“Session Tracking Using JSP,” will be modified. If you recall, the application is a basic shopping site that has the capability to log in and purchase products. In Chapter 8, the products were set up in JavaBeans and the users were defined in web.xml.We will now modify the application as follows:
JSP Related Interview Questions
|J2EE Interview Questions||Core Java Interview Questions|
|JDBC Interview Questions||Java Servlets Interview Questions|
|Hibernate Interview Questions||JavaServer Faces (JSF) Interview Questions|
|JSTL(JSP Standard Tag Library) Interview Questions||JBOSS Interview Questions|
|Log4j Interview Questions||NHibernate Interview Questions|
|Apache Struts 2 Interview Questions|
Jsp, J2ee, And The Role Of The Servlet
The Basic Syntax Of Jsp
Further Jsp Syntax
Deploying Jsp In A Web Container
The Jsp Standard Tag Library
Jsp And Javabeans
Jsp Application Architecture
Session Tracking Using Jsp
Developing Custom Tag Libraries
Utilizing Xml From Jsp
Transforming Xml Using Xslt And Xslfo
Invoking Web Services From Jsp
Locating Resources Using Jndi
Databases And Jsp
Jsp And Ejb Interaction
Security And Jsp
Personalization And Web Applications
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.