R4R Java Core Java Faqs
adplus-dvertising
Previous

Home

Next

Struts Basic questions and answers

Q: How you will make available any Message Resources Definitions file to the Struts Framework Environment?
Ans:
The Message Resources Definitions file is a simple *.properties files and these files contains the messages that can be used in the struts project. Message Resources Definitions files can be added to the struts-config.xml file through <message-resources /> tag.
Example:
<message-resources parameter="MessageResources" />  

Q: Write code of any Action Class?
Ans:
Here is the code of Action Class that returns the ActionForward object.
ExampleAction.java
import javax.servlet.http.*;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping; 
public class ExampleAction extends Action
{public ActionForward execute(ActionMapping mapping, ActionForm form,   HttpServletRequest request, HttpServletResponse response) throws Exception{

      return mapping.findForward("testAction");
  }
}   

Struts Objective Questions And Answers

Struts Objective Questions And Answers

Struts Subjective Questions And Answers

Struts Subjective Questions And Answers

Struts Interview Questions And Answers

Struts Interview Questions And Answers
 

 

Q. How you will display validation fail errors on jsp page?
Ans:
Following tag displays all the errors:
<html:errors/>
Q. How you will enable front-end validation based on the xml in validation.xml?
Ans:
The <html:javascript> tag to allow front-end validation based on the xml in validation.xml.
Example:
 <html:javascript formName="loginForm" dynamicJavascript="true" staticJavascript="true" /> generates the client side java script for the form "loginForm" as defined in the validation.xml file. The <html:javascript> when added in the jsp file generates the client site validation script.
Q: What is RequestProcessor and RequestDispatcher?
Ans:
The class org.apache.struts.action. RequestProcessor process the request from the controller. We can make a sublass of RequestProcessor with our own version and modify how the request is processed.

   A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response. The resource can be dynamic or static.
The pathname must begin with a "/" and is interpreted as relative to the current context root. Use getContext() method is used  to obtain a RequestDispatcher for resources in foreign contexts. This method returns null if the ServletContext cannot return a RequestDispatcher.

Q: What are the uses of tiles-def.xml file, resourcebundle.properties file, validation.xml file?

Ans: tiles-def.xml: is is an xml file used to configure tiles with the struts application. You can define the layout / header / footer / body content for your View. See more at The resourcebundle.properties file is used to configure the message (error/ other messages) for the struts applications.
The file validation.xml is used to declare sets of validations that should be applied to FormBeans.   

Q:What are the disadvantages of Struts?
Ans
: Struts is very robust framework and is being used extensively in the industry. But there are some disadvantages of the Struts:
a) High Learning Curve Struts requires lot of efforts to learn and master it. For any small project less experience developers could spend more time on learning the Struts.

b) Harder to learn Struts are harder to learn, benchmark and optimize.
Q: What are the difference between <bean:message> and <bean:write>?
Ans:
<bean:message>: This tag is used to output locale-specific text (from the properties files) from a MessageResources bundle. 

<bean:write>: This tag is used to output property values from a bean. <bean:write> is a commonly used tag which enables the programmers to easily present the data.

Struts Basic questions and answers

Previous

Home

Next

Tutorials,Examples,Questions and Answer

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R