Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

HttpServlet.getLastModified

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to figure out the use of the HttpServlet.getLastModified(HttpServletRequest req) method. The api says "Returns the time the HttpServletRequest object was last modified". I don't get this at all, if anyone has a link to an article or an explanation I would really appreciate.
Thanks in advance
Dominic
 
author
Posts: 3252
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The meaning of this method is to return the last time the resource represented by the servlet was modified. For example, if a GET for this servlet would return the contents of a file, you would override getLastModified() to return the modification date of the file. That way, browsers and proxies can find out whether they can use their own cached copy of the URL contents or have to download a new updated copy.
The default implementation of this method simply returns a negative number (-1 in fact), which should tell proxies and browsers never to cache the page (Microsoft Proxy is another story altogether though). After all, as far as the HttpServlet class knows you may be generating different content in doGet/doPost for every request, so it cannot make smart assumptions about how long content will remain valid for.
Overriding this method with something sensible will reduce network traffic and improve your site's responsiveness.
- Peter
 
Dominic Paquette
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer
Dominic
 
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic