File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Request in Session" Watch "Request in Session" New topic

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

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.
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.
I agree. Here's the link:
subject: Request in Session
It's not a secret anymore!