GeeCON Prague 2014*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Conditional GET operation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Conditional GET operation" Watch "Conditional GET operation" New topic
Author

Conditional GET operation

Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Dear all,
I am confused about conditional GET operation.
Can you eplain about the relation of conditional GET operation and getLastModified method in HttpServlet class ?
thanks
daniel
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
Here is a related link on this topic 'Conditional Get'
http://condor.depaul.edu/~mgehard/se452/lecture/lecture4.html
When the reqeust header If-Modified-Since is present in the request it is called a conditional get.
Advantage: reduce network traffic and server load
Steps:
User request a page that is cached in the browser
Browser sends a conditional get to server
Checks page modification date against the date sent from browser
If page has changed after date sent, page is sent
If page has not changed, a 304 (Not Modified) response is sent
Using conditional gets in servlets
Two methods:
Explicitly set Last-Modified header
long t = System.currentTimeMilis();
response.setDateHeader("Last-Modified", t);

Override getLastModified() method in HttpServlet
long getLastModified(HttpServletRequest request){
return System.currentTimeMilis();
}
Regards,
Maha Anna
[ November 23, 2002: Message edited by: Maha Annadurai ]
 
GeeCON Prague 2014
 
subject: Conditional GET operation