This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action in struts

 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In struts, an Action class is subclassed to act as a controller. In the jsp page, it needs to display many records (obtained from database).
I am now thinking which method in the following 2 cases is better:
1) call the session bean in the subclass of Action class
2) the jsp page calls a javabean which call the session bean
Which method is better for the performance? In the code, it seems that it is better for the case 1, because the jsp page does not need to deal with the business logic. However, in case 1, after the Action obtained the data, I need to use this code: request.setAttribute("...", theObject).
Thanks!
Stephen Lee
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When it comes to webapps, the two biggest drags on performance are generally DBMS latency and network delays. Compared to them, where you put your code is likely to be virtually indetectable.
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Tim says, you'll probably not notice any performance difference whichever you choose. From an architecture/design perspective, since you're using a Model-2 framework, you're better off accessing the session bean functionality from your Action class for increased reusability, maintainability, etc.
Cheers
Simon
 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic