struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hill" <>
Subject RE: what is controller servlet in struts framework
Date Wed, 04 Feb 2004 15:09:08 GMT
The controller servlet is the struts ActionServlet class. You configure this
in your web.xml file so that it sends all requests whose path ends in .do
(or whatever extension/path mapping you choose for your actions) to this

The ActionServlet will actually make use of another class to do the bulk of
its work when a request comes in (in struts1.1). This is the
RequestProcessor. It examines the path and looks up the appropriate
ActionMapping for that path that you have defined in struts-config.xml.

>From the information in the ActionMapping it determines which ActionForm
class you want to use and in which scope it should be, creates an instance
if necessary and populates it from the parameters in the request.

Then the RequestProcessor will pass the ActionForm, and references to the
request, response, and ActionMapping to the execute method of your Action
class. (The first time this Action is used it will instantiate the action
object. All subsequent requests in all threads will reuse the same instance
that it created the first time).

Your Action will (usually) return an instance of ActionForward, and the
RequestProcessor will then forward the request to the path specified in the
ActionForward (doing a client side redirect if the redirect property is

In the event that an exception is thrown by your Actions execute method, and
you defined an ExceptionHandler in struts-config.xml for it, the
RequestProcessor will instead pass control to this ExceptionHandler.

Basically the ActionServlet is the controller, but it delegates the
processing of requests to the RequestProcessor. The RequestProcessor
determines which Action should handle that request and calls it, so your
Actions fit into the controller part of the MVC architecture along with the
ActionServlet and RequestProcessor.

(Other tasks of the ActionServlet include parsing the struts-config.xml file
at application startup, and calling at startup any PlugIns you have

You may subclass the ActionServlet to customise its behaviour, but under
struts1.1 this is less useful to do - in 1.1 if you need to customise that
behaviour you would usually subclass the RequestProcessor. You can specify
which RequestProcessor class to use in your struts-config.xml file.

-----Original Message-----
From: []
Sent: Wednesday, 4 February 2004 22:58
Subject: what is controller servlet in struts framework

Hi guys
I have been having a question. I do not understand what is the controller
servlet in the struts framewrok. Is it the Action classes or
struts-config.xml that is the controller servlet for struts framework.
Please let me know



To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message