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

struts ActionServlet

 
Ian Yang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
struts framework usually uses a centrilized ActionServlet as a controller, it goes to different action class and forwards the results to different jsp pages. In Apache jarkata it briefly talks about it but has not too much good details/examples. Anybody has any examples URL ?
Thanks.
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
some sample projects also have such servlet,such as petstore.........,you can download the petstore from sun's website,extract the source code.
maybe the MainServlet(i can't remember the name for sure) in petstore is the centralized servlet.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technically, you can have more than one ActionServlet, but that would be an unusual case.
The standard Struts ActionServlet takes care of decoding incoming URLs, managing FormBeans and other generally useful tasks, after which it passes control to the Action class that it thinks should handle the functionality specific to the request.
You can do quite a bit using just the basic ActionServlet. This is why you may not find all that many examples of "using it" -- you simply refer to it in your web.xml file as the target for "*.do" requests and the ActionServlet gets its app-specific functionality from struts-config.xml.
For more ambitious projects you an also subclass ActionServlet - for example, if the standard ActionServlet's database pooling functions don't serve your needs, extend ActionServlet with methods that do.
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
otherwise,if you want to study the code,you can unzip the "struts.jar",and decompile the "ActionServlet.class"
 
Dave Van Even
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by zb cong:
otherwise,if you want to study the code,you can unzip the "struts.jar",and decompile the "ActionServlet.class"

or download the source code
Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic