• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Struts Interview Questions Answers

Question - 31 : - Where can I get help with Struts?

Answer - 31 : - The Struts package comes complete with a Users Guide to introduce people to the framework and its underlying technologies. Various components also have their own in-depth Developers Guide, to cover more advanced topics. Comprehensive Javadocs are included along with the full source code. For your convenience, these are bundled together as a self-installing application. The struts-documentation.war is the same bundle that is deployed as the Struts Web site. The Strut's mailing list is also very active, and welcomes posts from new users. Before posting a new question, be sure to consult the MAILING LIST ARCHIVE and the very excellent How To Ask Questions The Smart Way by Eric Raymond. Please do be sure to turn off HTML in your email client before posting.

Question - 32 : - Do I need to implement reset and set all my form properties to their initial values?

Answer - 32 : - No. You need to set checkbox properties to false if the ActionForm is being retained in session scope. This is because an unchecked box does not submit an attribute. Only checked boxes submit attributes. If the form is in session scope, and the checkbox was checked, there is no way to turn it back off without the reset method. Resetting the properties for other controls, or for a request scope form, is pointless. If the form is in request scope, everything already just started at the initial value.

Question - 33 : - Can I use JavaScript to submit a form?

Answer - 33 : - You can submit a form with a link as below. BTW, the examples below assume you are in an block and 'myForm' is picked up from the struts-config.xml name field of the action. <a href='javascript:void(document.forms["myForm"].submit()>My Link</a> Now the trick in the action is to decode what action you intend to perform. Since you are using JavaScript, you could set a field value and look for it in the request or in the form. ... html/javascript part ... <input type='hidden' value='myAction' /> <input type='button' value='Save Meeeee' onclick='document.forms["myForm"].myAction.value="save"; document.forms["myForm"].submit();' /> <input type='button' value='Delete Meeeee' onclick='document.forms["myForm"].myAction.value="delete"; document.forms["myForm"].submit();' /> ... the java part ... class MyAction extends ActionForm implements Serializable { public ActionForward execute (ActionMapping map, ActionForm form, HttpServletRequest req, HttpServletResponse) { String myAction = req.getParameter("myAction"); if (myAction.equals("save") { // ... save action ... } else if (myAction.equals("delete") { // ... delete action ... } } } } This is just one of many ways to achieve submitting a form and decoding the intended action. Once you get used to the framework you will find other ways that make more sense for your coding style and requirements. Just remember this example is completely non-functional without JavaScript.

Question - 34 : - ActionServlet Configurations

Answer - 34 : - With the introduction of sub-applications, a more flexible way is introduced to configure each sub-application independently. Many of the configuration entries (e.g. resource bundle location, maximum upload file size, etc) that used to be defined in web.xml have now been moved to struts-config.xml. The original entries in web.xml are deprecated but will still be effective.

Question - 35 : - How does Struts work?

Answer - 35 : - Java Servlets are designed to handle requests made by Web browsers. Java ServerPages are designed to create dynamic Web pages that can turn billboard sites into live applications. Struts uses a special Servlet as a switchboard to route requests from Web browsers to the appropriate ServerPage. This makes Web applications much easier to design, create, and maintain.

Question - 36 : - What's the difference between Struts and Turbine? What's the difference between Struts and Espresso?

Answer - 36 : - If you are starting from scratch, packages like Turbine and Espresso can be very helpful since they try to provide all of the basic services that your team is likely to need. Such services include things like data persistence and logging. If you are not starting from scratch, and need to hook up your web application to an existing infrastructure, then "plain vanilla" Struts can be a better choice. The core Struts framework does not presuppose that you are using a given set of data persistence, presentation, or logging tools. Anything goes =:0) Compared to other offerings, Struts endeavors to be a minimalist framework. We try leverage existing technologies whenever we can and provide only the missing pieces you need to combine disparate technologies into a coherent application. This is great when you want to select your own tools to use with Struts. But, if you prefer a more integrated infrastructure, then packages like Turbine or Espresso (which uses Struts) are perfectly good ways to go.

Question - 37 : - Why are some of the class and element names counter-intuitive?

Answer - 37 : - The framework grew in the telling and, as it evolved, some of the names drifted. The good thing about a nightly build, is that everything becomes available to the community as soon as it is written. The bad thing about a nightly build is that things like class names get locked down early and then become difficult to change.

Question - 38 : - Do I have to use JSPs with my application?

Answer - 38 : - The short answer to this question is: No, you are not limited to JavaServer Pages. The longer answer is that you can use any type of presentation technology which can be returned by a web server or Java container. The list includes but is not limited to: * JavaServer Pages, * HTML pages, * WML files, * Java servlets, * Velocity templates, and * XML/XLST Some people even mix and match apparently unrelated technologies, like PHP, into the same web application.

Question - 39 : - How do I use JavaScript to ...

Answer - 39 : - Struts is mainly a server-side technology. We bundled in some JSP tags to expose the framework components to your presentation page, but past that, the usual development process applies. Interactive pages require the use of JavaScript. (That's why it was invented.) If you want things popping up or doing this when they click that, you are outside the scope of Struts and back into the web development mainstream. You use JavaScript with Struts the same way you use with any presentation page. Since JavaScript is a client-side technology, you can use simple relative references to your scripts. If you need to fire a JavaScript from a HTML control, the Struts HTML tags have properties for the JavaScript events

Question - 40 : - Give the Details of XML files used in Validator Framework?

Answer - 40 : - The Validator Framework uses two XML configuration files validator-rules.xml and validation.xml. The validator-rules.xml defines the standard validation routines, these are reusable and used in validation.xml. to define the form specific validations. The validation.xml defines the validations applied to a form bean. How you will display validation fail errors on jsp page? - The following tag displays all the errors: < html:errors/ >

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners