|Home |Login |Registration |Struts Step by Step Tutorial |Hibernate Step by Step Tutorial |Spring Step by Step Tutorial |JSP Step by Step Tutorial |JDBC Step by Step Tutorial |Web Services Step by Step Tutorial |EJB fundamentals | ORACLE Step by Step Tutorial | SCJP 5.0 and SCJP 6.0 Study Guide | SCWCD 5.0 Study Guide | SCJP Tips
Java mock test | SCJP mock test | SCJP DUMP | SCBCD mock test |Java online test exam | JSP online test | ORACLE online test | Hibernate online test | Servlet online test | Struts online test | EJB online test | C online test | C++ online test | Aptitude online test

Java interview questions | JSP interview questions | ORACLE interview questions | Hibernate interview questions | Servlet interview questions | Struts interview questions | JDBC interview questions | C/C++ interview questions | Spring interview questions | JMS interview questions | Informatica interview questions | EJB interview questions | OOPS and Design Pattern interview questions
1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc) JobsJobs and Walkins

 

Recent Questions

!!! Struts Frequently Asked Questions !!!

What is role of Action Class?

SCJP 1.5/1.6 Exam Kit

!!!Answer!!!- From Technical Expert

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.

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) slects an appropriate Action and Request Processor creates an instance if necessary,

and finally calls execute method of Action class.

To use the Action, we need to Subclass and overwrite the execute() method. and your bussiness login in execute() method.

The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the JSP as per the value of the returned ActionForward object.

ActionForward JSP from struts_config.xml file.



Developing our Action Class :



Our Action class (EmpAction.java) is simple class that only forwards the success.jsp.

Our Action class returns the ActionForward called "success", which is defined in the struts-config.xml file (action mapping is show later in this page).

Here is code of our Action Class

public class EmpAction extends Action

{

public ActionForward execute(

ActionMapping mapping,

ActionForm form,

HttpServletRequest request,

HttpServletResponse response) throws Exception{

return mapping.findForward("success");

}

}



mapping.findForward("success"); forward to JSP mentioned in struts_config.xml.

struts_config.xml configuration is :



<action

path="/EmpAction"

type="com.techfaq.EmpAction">

<forward name="success" path="/success.jsp"/>

</action>

mapping.findForward("success") method forward to success.jsp (mentioned in struts_config.xml);





Here is the signature of the execute() method Action Class.



public ActionForward execute(ActionMapping mapping,

ActionForm form,

javax.servlet.http.HttpServletRequest request,

javax.servlet.http.HttpServletResponse response)

throws java.lang.Exception



Where

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



In the browser : http://localhost:8080/testApp/EmpAction.do

This will call to execute() method of EmpAction and after that based on mapping.findForward("success") forward to success.jsp.


Answered By : null Replied Date : Feb 2 2012
Answer :


Answered By : null Replied Date : Dec 6 2011
Answer :


Answered By : null Replied Date : Oct 26 2011
Answer :


Answered By : null Replied Date : Oct 24 2011
Answer :


Answered By : null Replied Date : Aug 19 2011
Answer :


Answered By : null Replied Date : Aug 10 2011
Answer :


Answered By : null Replied Date : Jun 30 2011
Answer :


Answered By : null Replied Date : Jun 18 2011
Answer :


Answered By : null Replied Date : Jun 18 2011
Answer :


Answered By : null Replied Date : Jun 3 2011
Answer :


Answered By : null Replied Date : May 11 2011
Answer :


Answered By : null Replied Date : Apr 20 2011
Answer :


Answered By : null Replied Date : Apr 7 2011
Answer :


Answered By : null Replied Date : Mar 22 2011
Answer :


Answered By : null Replied Date : Mar 7 2011
Answer :


Answered By : null Replied Date : Mar 5 2011
Answer :


Answered By : null Replied Date : Mar 4 2011
Answer :


Answered By : null Replied Date : Mar 4 2011
Answer :


Answered By : null Replied Date : Feb 27 2011
Answer :


Answered By : null Replied Date : Feb 23 2011
Answer :


Answered By : null Replied Date : Feb 20 2011
Answer :


Answered By : null Replied Date : Feb 19 2011
Answer :


Answered By : null Replied Date : Feb 11 2011
Answer :


Answered By : null Replied Date : Feb 1 2011
Answer :


Answered By : null Replied Date : Jan 30 2011
Answer :


Answered By : null Replied Date : Jan 22 2011
Answer :


Answered By : null Replied Date : Jan 15 2011
Answer :


Answered By : null Replied Date : Jan 11 2011
Answer :


Answered By : null Replied Date : Dec 28 2010
Answer :


Answered By : null Replied Date : Nov 27 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Nov 7 2010
Answer :


Answered By : null Replied Date : Oct 9 2010
Answer :


Answered By : null Replied Date : Sep 24 2010
Answer :


Answered By : null Replied Date : Sep 22 2010
Answer :


Answered By : null Replied Date : Sep 17 2010
Answer :


Answered By : null Replied Date : Sep 14 2010
Answer :


Answered By : null Replied Date : Sep 3 2010
Answer :


Answered By : null Replied Date : Aug 21 2010
Answer :


Answered By : null Replied Date : Jun 3 2012
Answer :


Answered By : null Replied Date : Jun 30 2012
Answer :


Answered By : null Replied Date : Aug 14 2012
Answer :


Answered By : null Replied Date : Oct 10 2012
Answer :


Answered By : null Replied Date : Nov 25 2012
Answer :


Answered By : null Replied Date : Nov 26 2012
Answer :


Answered By : null Replied Date : Jan 3 2013
Answer :


Answered By : null Replied Date : Feb 26 2013
Answer :


Answered By : null Replied Date : Mar 19 2013
Answer :


Answered By : null Replied Date : Jun 7 2013
Answer :


 

You can also contribute to this answer:

Your Name:
Answer:

 
Ask Question and get answer from Expert.
View Answers List from Expert.

The information you are posting should be related to java and ORACLE technology. Not political.