This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Replacement for Session Object in Struts Action Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Replacement for Session Object in Struts Action Class" Watch "Replacement for Session Object in Struts Action Class" New topic

Replacement for Session Object in Struts Action Class

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All,

I am working with struts In my action class I am getting a Collection of EmployeeName and then I am setting this in Session and displaying it in my JSP page in this way..
Collection employeeName= getEmployeeName(empForm, req, res);
if (employeeName != null) {
session.setAttribute( "departmentListAll",departmentList);

I want some other way to pass my Collection(employeeName) Object to my jsp page,As session might will be overloaded if I set all Objects in session.

Please write your suggestion I know I can use request Object but it will be lost after request.

I am calling my EJB methods in my Action Class only.

SCJP 1.2

Joined: Aug 12, 2004
Posts: 2

Couldn't u use set the collection in the request
In that way the collection would be available only till the request and wouldn't be residing in the session ..

hope this helps

�If you Always Do, what you Always Did, you will Always Get, What you Always Got.� <br />-- Anonymous

Joined: Aug 12, 2004
Posts: 2
Sorry hadn't read ur entire post ..

If u need ur collection to be alive more than the request , the solution would be session .. what u could do is clear the session once u are doen with the collection a way out can be intercepting your requests and clearign the session ..
In any case u would need to put ur object in session for it to be available more than the request..
Prasanna Puttappa
Ranch Hand

Joined: Jul 21, 2003
Posts: 54
Try using SFSB. There by you will be keeping data at the server side and you can set data at the request scope for displaying in JSP.

I know this is not a struts solution, but i feel this is a good soln.

- Prasanna B.P

~Prasanna (SCJP5.0, SCWCD5)
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

If departmentListAll values do not change, you can place them in application scope. That way you only deal with one copy and one reference.

Another thing to keep in mind is that if all of the sessions hold a reference to the same list, then there is still only one copy of the list and this will not put a huge load on your server.

A good workman is known by his tools.
I agree. Here's the link:
subject: Replacement for Session Object in Struts Action Class
It's not a secret anymore!