File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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 ?
Maha Annadurai
Ranch Hand

Joined: Oct 27, 2002
Posts: 87
Here is a related link on this topic 'Conditional Get'
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
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();
Maha Anna
[ November 23, 2002: Message edited by: Maha Annadurai ]
I agree. Here's the link:
subject: Conditional GET operation
It's not a secret anymore!