Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

all of jsp files to be passed to an action class

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Struts. I have some confusion.

If I want all of jsp files to be passed to an action class, how could do that ?

for example, if user type http://localhost/myapp/index.jsp, this jsp page request will go to an action class. how could I do this?

This is a good design ?

Thanks
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point of an MVC framework such as Struts is that all requests in an application should be made through a central control. In the case of Struts, an instance of ActionServlet serves as the control, therefore all requests should be made through the ActionServlet. By going to specific JSPs individually as you have suggested, you are defeating the purpose of MVC and instead are introducing a page-centric design.

So in general, you should never have a user access any part of your application by going to a specific JSP. One exception to this is index.jsp, which should itself forward to some Action in your Struts application (possibly through the use of <logic:forward>. Even if a particular view that you wish to present is static content that requires no setup in an Action class, you should at least use a ForwardAction as opposed to linking directly to the static content.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic