Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@www.apache.org Received: (qmail 44263 invoked from network); 4 Feb 2004 15:15:14 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Feb 2004 15:15:14 -0000 Received: (qmail 463 invoked by uid 500); 4 Feb 2004 15:12:53 -0000 Delivered-To: apmail-jakarta-struts-user-archive@jakarta.apache.org Received: (qmail 386 invoked by uid 500); 4 Feb 2004 15:12:52 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 218 invoked from network); 4 Feb 2004 15:12:50 -0000 Received: from unknown (HELO gridnode.com) (202.83.97.26) by daedalus.apache.org with SMTP; 4 Feb 2004 15:12:50 -0000 Received: from andrew (pc209 [192.168.213.209]) by gridnode.com (8.12.9/8.12.4) with SMTP id i14FQwVm003261 for ; Wed, 4 Feb 2004 23:26:58 +0800 Reply-To: From: "Andrew Hill" To: "Struts Users Mailing List" Subject: RE: what is controller servlet in struts framework Date: Wed, 4 Feb 2004 23:09:08 +0800 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 In-Reply-To: <63522.138.88.163.115.1075906696.squirrel@physics.gmu.edu> Importance: Normal X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 servlet. 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 true). 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 configured). 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: mohan@physics.gmu.edu [mailto:mohan@physics.gmu.edu] Sent: Wednesday, 4 February 2004 22:58 To: struts-user@jakarta.apache.org 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 Thanx --Mohan --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-user-help@jakarta.apache.org