

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The role of the action class in the struts framework, providing its signature, parameters, and an example of its configuration in the struts-config.xml file. It also demonstrates how to test an action class by adding a link in the index.jsp file.
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Understanding Action Class Here is the signature of the Action Class.
public ActionForward execute (ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
Action Class process the specified HTTP request, and create the corresponding HTTP response (or forward to another web component that will create it), with provision for handling exceptions thrown by the business logic. Return an ActionForward instance describing where and how control should be forwarded, or null if the response has already been completed.
Parameters:
mapping - The ActionMapping used to select this instance form - The optional ActionForm bean for this request (if any) request - The HTTP request we are processing response - The HTTP response we are creating
Throws: Action class throws java.lang.Exception - if the application business logic throws an exception
Adding the Action Mapping in the struts-config.xml To test the application we will add a link in the index.jsp <html:link page="/TestAction.do">Test the Action</html:link>
Following code under the <action-mappings> tag is used to for mapping the TestAction class.
To test the new application click on Test the Action link on the index page. The content of TestAction.jsp should be displayed on the user browser.
In this l struts-co TestActi
lesson you l onfig.xml. on.jsp.
learned how Our Action
w to create Class retur
e Action Cla rns the Act
ass and add tionForward
d the mapp d mapping
pings in the g of the
e