This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

storing request object in session

Pradeep C Nair Infosense

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

Joined: Jun 18, 2004
Posts: 3
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

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

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.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13001
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().
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: storing request object in session
It's not a secret anymore!