Lesson 6: Handling Request Parameters with Form Beans #Java Short Notes

Training Video for this article
Code used for this article

  • In jsp pages, you can create forms with html form tag or html:form tag
  • Form Beans concept
    • You can use request.getParameter() to retrieve data from a form from the backend/server side. Or you can create a bean based on the form parameters/values. Then from the server side, you can retrieve values from these beans.
    • From server side, you can set output values to the request object directly or you can create a bean to carry output messages to the next step and set the output bean in the request/session object.
    • In the output jsp pages, you can use bean:write or jsp expression language to print those output/result bean values [provided that output values are set into a bean in the server side]
    • How to declare form beans: Just define a simple Java class that extends ActionForm and then declare it in the struts-config.xml file with form-beans tag
  • Steps in creating a struts application. This example will follow the same rules
    1. Modify the struts-config.xml file: declare the form beans, map incoimg .do to action classes, map all possible return strings from action calsses to destination pages
    2. Write the class for the bean that extends ActionForm. Write all the getter and setter methods, write reset method [useful for session scoped beans], write validate method for form input validation
    3. Create the result/output beans. You do not need to declare them in struts-config.xml file
    4. Define the action class to handle requests and return the right forward string that also need to be mapped in the config file
    5. Create the input pages that calles the actions
    6. Write output jsp pages

From: http://sitestree.com/?p=5009
Categories:Java Short Notes
Tags:
Post Data:2010-02-10 16:35:25

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada