wood burning stoves 2.0*
The moose likes JSP and the fly likes Request in Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Request in Session" Watch "Request in Session" New topic
Author

Request in Session

Weerawit Maneepongsawat
Ranch Hand

Joined: Apr 11, 2002
Posts: 203
Can i put Request object in the Session object like this.
session.setAttribute("page1", request);
after pass 2 page i want to get page1 again i use
HttpServletRequest page1 = (HttpServletRequest) session.getAttribute("page1");
Is it work ??


Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Why would you want to do something like that? it doesn't make sense to me


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

In a round-about way, Andres is saying that no, you can't do that.
A request object is only valid until you have sent your response, and that's it. It certainly wouldn't be a good idea to try to hold onto it and do anything with it during rubsequent requests.
Dave
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
One alternative you might want to consider is to use the RequestDispatcher.forward(reqest, response) method from the ServletContext(application). You can wrap your page 2 resource in a RequestDispather object and then forward the request object to page 2.
One suggestion.
craig.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Request in Session
 
Similar Threads
request object
Session time-out notification
JSF Filter prevent direct access certain page
life span of HttpServletRequest and HttpServletResponse
Session Utility class