Java Interview Quest
Java Interview Quest
Java Interview Quest
A: T Message Resources Definitions file are 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 <messageresources /> tag. Example: <message-resources parameter=\"MessageResources\" />.
Q: What is Action Class? A: The Action Class is part of the Model and is a wrapper around the business logic. The purpose of Action Class is to translate the HttpServletRequest to the business logic. To use the Action, we need to Subclass and overwrite the execute() method. In the Action Class all the database/business processing are done. It is advisable to perform all the database related stuffs in the Action Class. The ActionServlet (commad) passes the parameterized class to Action Form using the execute() method. The return type of the execute method is ActionForward which is used by the Struts Framework to forward the request to the file as per the value of the returned ActionForward object.
What is Struts Validator Framework? A: Struts Framework provides the functionality to validate the form data. It can be use to validate the data on the users browser as well as on the server side. Struts Framework emits the java scripts and it can be used validate the form data on the client browser. Server side validation of form can be accomplished by sub classing your From Bean with DynaValidatorForm class. How you will display validation fail errors on jsp page? A: Following tag displays all the errors: <html:errors/> [ Received from Dhiraj Sharma] Q: How you will enable front-end validation based on the xml in validation.xml?
TOP
A: The <html:javascript> tag to allow front-end validation based on the xml in validation.xml. For example the code: <html:javascript formName=\"logonForm\" dynamicJavascript=\"true\" staticJavascript=\"true\" /> generates the client side java script for the form \"logonForm\" as defined in the validation.xml file. The <html:javascript> when added in the jsp file generates the client site validation script.
What if the main method is declared as private? The program compiles properly but at runtime it will give Main method not public. message. What if the static modifier is removed from the signature of the main method? Or What if I do not provide the String array as the argument to the method? Program compiles. But at runtime throws an error NoSuchMethodError.