File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performance Issue

 
meera rao
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 258
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meera, I think your question is A Action class with Many ActionForward (Not ActionForard classes)


Thanks
Sudhakar
 
meera rao
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean to say that you have many forwards in one action class? I could understand "ActionForward classes".
 
meera rao
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic