Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Conditional GET operation

 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!