A Conditional Get Method for JSP - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

A Conditional Get Method for JSP

Description:

if( ifModSince lastModified ) doGet( req, resp ); else. resp.setStatus( 304 ); Servlet Classes ... { if( lastModified == -1 ) lastModified = System. ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 9
Provided by: Stu6171
Category:

less

Transcript and Presenter's Notes

Title: A Conditional Get Method for JSP


1
A Conditional Get Method for JSP
  • Stuart Maclean
  • Intelligent Transportation Systems
  • University of Washington
  • http//www.its.washington.edu

2
HTTP 1.1 Conditional Get
  • GET foo.html
  • Status 200 (OK)
  • Content-Length N
  • Last-Modified T
  • GET foo.html
  • If-Modified-Since T
  • Status 304 (Not Modified)
  • Content-Length -
  • Last-Modified T

3
HttpServlet.service( HttpServletRequest
req,HttpServletResponse resp ) if(
GET.equals( req.getMethod() ) ) long
lastModified getLastModified( req ) if(
lastModified -1 ) doGet( req, resp
) else long ifModSince
req.getDateHeader( If-Modified-Since ) if(
ifModSince lt lastModified ) doGet( req, resp
) else resp.setStatus( 304
)
4
Servlet Classes
Interface
Servlet
Implements
Extends
JSPPage
GenericServlet
Extends
Extends
HttpJspPage _jspService
HttpServlet getLastModified
5
JSP Wrapping Classes
HttpServlet service
JSPWrapper doGet - include JSP
MyJSPWrapper getLastModified
6
class JSPWrapper extends HttpServlet public
void doGet( HttpServletRequest req,
HttpServletResponse resp ) String servletPath
req.getServletPath() String target
servletPath.substring( 0, servletPath.length()
- matchingSuffix.length() ) target
target targetSuffix String query
req.getQueryString() if( query ! null
) target target ? query req.getReque
stDispatcher( target ).include( req, resp
) String matchingSuffix .jsp,
targetSuffix .wjsp
7
class MyJspWrapper extends JspWrapper public
long getLastModified( HttpServletRequest req )
if( lastModified -1 ) lastModified
System.currentTimeMillis() / 1000
1000 return lastModified long
lastModified -1
8
JSPFile
GET foo.jsp
GET foo.jsp
JSP
JSPWrapper
doGet
MyJSPWrapper
include foo.wjsp
getLastModified
200
JSP
304
200
Write a Comment
User Comments (0)
About PowerShow.com