Struts Action Class (I)

16 January 2008

In this article let us see how to use Struts Action Class and forward a jsp file through it.

Introduction

An Action class in the struts application extends Struts ‘org.apache.struts.action.Action” Class. Action class acts as wrapper around the business logic and provides an inteface to the application’s Model layer. It acts as glue between the View and Model layer. It also transfers the data from the view layer to the specific business process layer and finally returns the procssed data from business layer to the view layer.

An Action works as an adapter between the contents of an incoming HTTP request and the business logic that corresponds to it. Then the struts controller (ActionServlet) selects an appropriate Action and creates an instance if necessary, and finally calls execute method.

To use the Action, we need to Subclass and overwrite the execute() method. In the Action Class don’t add the business process logic, instead move the database and business process logic to the process or dao layer.

The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.

del.icio.us:Struts Action Class (I)  digg:Struts Action Class (I)  spurl:Struts Action Class (I)  wists:Struts Action Class (I)  simpy:Struts Action Class (I)  newsvine:Struts Action Class (I)  blinklist:Struts Action Class (I)  furl:Struts Action Class (I)  reddit:Struts Action Class (I)  fark:Struts Action Class (I)  blogmarks:Struts Action Class (I)  Y!:Struts Action Class (I)  smarking:Struts Action Class (I)  magnolia:Struts Action Class (I)  segnalo:Struts Action Class (I)  gifttagging:Struts Action Class (I)

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Struts Action Class (I)

Leave a Reply