Creating Struts Application Create web Project and select struts as framework.Action ServletNameAction URLPattern
Login.jsp Create Login jsp page. Add following taglibs i.e. html <%@ taglib uri="http://struts.apache.org/tags-html"prefix="html" %> Add form using html <html:form action="/login"> <html:submit value="Login" /> </html:form> Add table using palette and two text fields using htmltag.
success.jsp Add bean tag at top of page by using strut beantaglib. Now add following:
ActionForm Bean This bean used to persist data between requests. When user submits data, it is stored temporarily inform bean. To be redisplayed in form page in case offormat problem or in success page. To add actionForm bean, create new actionFormbean from strut category and give nameLoginForm.java. Add email variable in LoginForm.java bean and addsetter and getter functions. After that you can see changes appear in struts-config.xml file.
Action Class When form is received, function of action object isexecuted and data is processed. It also decides whichview to forward processed data. Create Action Class from wizard from struts categoryby giving name LoginAction with following:Same Path givenin form of loginpage
Associate action class with form bean (LoginForm.java) previously created. Delete forward slash from input resource. Set scope to Request. Deselect the Validate ActionForm Bean option
Validate Form Your LoginAction file will look like this: It redirects the request for success view. But is desirable to validate input before forwarding it to appropriate view.
Adding forward Entries to struts-config.xml In order for the application to match JSP pages with forwarding conditionsreturned by LoginActions execute method, you need to add forward entries tothe struts-config.xml file. Open struts-config.xml amd right click anywhere in file. select struts and add forward and add following:
Setting welcome page in web.xml Goto Page tab og web.xml file and change thewelcome file to login.jsp That’s it