aspose file tools*
The moose likes Struts and the fly likes Performance Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Performance Issue" Watch "Performance Issue" New topic
Author

Performance Issue

meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
Hello,

I am new to Struts and I just finished some code for my project. I have some questions regarding the preformance issues.

1) I have an action class , with many ActionForward classes. To pass some variables between these classes I am using session Variable. Is this a good way to program, or should i use a public variable to pass data between these classes.

2)I am using lot of session variables to pass arraylists to the JSP page from my code. Is this a good way to program?

Any kind of suggestions will be appreciated.

Thank you
Pranav Sharma
Ranch Hand

Joined: Oct 27, 2003
Posts: 258
From my experience any action needs only a single Action Forward object. I don't know why you would need this. Could you tell me more.

Its not a good idea passing collections in session scope, if you are passing them from an action to the jsp it builds, that can be accomplished by putting them in request scope.

Maybe the more experienced Ranch Hands/bartender can correct me, but this what i think.
meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
I have many ActionForward classes in the Action class because I am using LookupDispatchAction. So there is a class for each buttton.
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
Meera, I think your question is A Action class with Many ActionForward (Not ActionForard classes)


Thanks
Sudhakar
meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
Regarding my First Question,
1) I have an action class , with many ActionForward classes. To pass some variables between these classes I am using session Variable. Is this a good way to program, or should i use a public variable to pass data between these classes.

Does anybody have any suggestions.

Thanks,
Meera
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
Do you mean to say that you have many forwards in one action class? I could understand "ActionForward classes".
meera rao
Ranch Hand

Joined: Jun 30, 2005
Posts: 67
it is something like this:

public class XYZ extends LookupDispatchAction {

public ActionForward abc(ActionMapping mapping, ActionForm
form,HttpServletRequest request, HttpServletResponse response)
throws Exception {

return mapping.findForward("abc");

public ActionForward def(ActionMapping mapping, ActionForm
form,HttpServletRequest request, HttpServletResponse response)
throws Exception {

return mapping.findForward("def");
}
}


Now I want to pass some variables from class 'abc' to 'def'.
I am already passing these variables to the jsp page as session variables. so Should i use those session variables to get values inthe 'def'calss. or use public variables.
sudhakar Tadepalli
Ranch Hand

Joined: Dec 27, 2001
Posts: 130
Meera,
'abc' and 'def' are two different action methods in one Action class. Each method have its own ActionForward. If you forward to "abc" and kept some values in session, you can just use them in any number of jsp's as long as the session is valid.You don't have to create any public variables to hold the data.It is also not thread safe.

Thanks
Sudhakar
Ruchik Mehtaji
Greenhorn

Joined: Jun 27, 2005
Posts: 7
I am new to Struts so I may be wrong but I think you have to put the attributes in the session scope because if you put it in the request scope it will only avalable to the jsp and not the next action that is called.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Performance Issue