File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes How long does a request attribute live? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "How long does a request attribute live?" Watch "How long does a request attribute live?" New topic
Author

How long does a request attribute live?

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

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?
Dieter Quickfend
Bartender

Joined: Aug 06, 2010
Posts: 543
    
    4

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.

HttpServletRequest

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.


Note

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.


Oracle Certified Professional: Java SE 6 Programmer && Oracle Certified Expert: (JEE 6 Web Component Developer && JEE 6 EJB Developer)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How long does a request attribute live?