• 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 ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How long does a request attribute live?

Ranch Hand
Posts: 355
Redhat Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe, it lives until response is committed. I think, once the response is committed it can't be accessed.

Have I got that right?
Posts: 543
Netbeans IDE Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two things which this could pertain to:
- The HTTP Request
- The HttpServletRequest object

HTTP Request

HTTP is a request/response protocol. This means that the browser sends a request to the server. This means a TCP/IP connections is opened for the duration of the request. When an HTTP response is sent, the server or the browser closes the TCP/IP connection. That is the end of the HTTP request/response chain. You can now see the response (containing data and a header). HTTP is stateless, so nothing else is kept.


This object is created and populated with request data by the container (server) when the request is made. Its lifecycle depends completely on the container implementation. It may choose to pool HttpServletRequest objects, or it may choose to discard them when the response is sent. As for its attributes, they will be discarded along with the HttpServletRequest object unless the attribute is an object with references in other objects. IF another object still has a reference to the object which is also a request attribute, it will continue to exist.


Do not mistake request dispatch actions (like servlet->JSP) with a response commit. The response is not committed and the request lifecycle is not over. The request is still completely valid in a JSP because a JSP is just another servlet that happens to put a bunch of html into the response without having to write a a lot of ugly, useless code. The response is only committed after the JSP is processed.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic