File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes storing request object in session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "storing request object in session" Watch "storing request object in session" New topic
Author

storing request object in session

Pradeep C Nair Infosense
Greenhorn

Joined: Jul 06, 2004
Posts: 1
i was trying to store request object in session variable. but that session variable is empty on the next page. but i can access that variable in the page, where it is stored. is it not possible to store request object in session?
i was trying to access the request object in a frameset. is there anyway to pass request object to a particular frame?
Dhirender Kumar
Greenhorn

Joined: Jun 18, 2004
Posts: 3
session.setAttribute("name",value);
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
HttpSession session = request.getSession();
session.setAttribute("request", request);

won't work too well, you're getting recursive calls here.
HttpSession session = ((HttpRequest)session.getAttribute("request")).getSession();

Doesn't look healthy


42
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
I'm confused. Are you attempting to store the entire request object into the session or just certain attribute-value pairs into the session?

If its the former, why not consider iterating through your request object and store them into your session?

Hope I didn't misinterprete your question.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yup, it's a really bad idea and I hope it doesn't work - if somehow it does, the behaviour would be indeterminate ie wierd and unpredictable.

As some pole have hinted, you're better moving the specific request-scope data to the session if you want to hold on to it, don't try to hold the request object, it represents something completely different.

Dave
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12781
    
    5
Storing the request object ANYWHERE is a bad idea. Request objects are managed by the servlet container and you MUST NOT try to hang on to one past the end of a single request. If you need to keep all the parameters try something like getParameterMap().
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: storing request object in session