Sie sind auf Seite 1von 2

27-12-12 Steps to develop a struts application on NetBeans6.9: 1) start --> programs --> NetBeans --> NetBeans6.9.

2) File menu -->New Project --> select Java Web (at left side)--> web application (at right side) --> next -->Enter Project Name: StrutsLogin , (uncheck )main project --> next --> next --> select struts 1.3.8 --> Enter Application Resource: satya --> Finish 3) Delete index.jsp and welcomeStruts.jsp pages from web pages folder(at left side). 4) Right Click on Project Name --> new --> other --> select struts (at left side) --> select struts ActionForm Bean (at right side) --> next --> enter class name:LoginForm --> Finish. 5) open source code of LoginForm.java and remove existing properties, setter and getter methods and add the following two properties. private string uname,pwd; Right click in source code of LoginForm.java --> insert code --> select getter and setter --> select uname and pwd --> generate if required apply validations in validate() method and otherwise remove validate() method and save. 6) Right Click on Project Name --> new --> other --> select struts --> select strutsAction ---> next --> Enter class name: LoginAction --> Enter Action path:/login --> next --> Finish. 7) open source code of loginAction.java and enter the following code in to execute() method. LoginForm loginform=(LoginForm) form; String str1=loginform.getUname(); String str2=loginform.getPwd(); if(str1.equals(sathya) && str2.equals(struts)) return mapping.findForward(SUCCESS); else retrun mapping.findForward(failure); 8) open struts-config.xml from webpages\WEB-INF folder and configure the following forward tags in <global-forwards> section. <forward name=success path=/success.jsp/> <forward name=failure path=/failure.jsp/>

9) Right click on project name --> new --> jsp --> Enter File name: login --> Finish --> remove existing code and type the following code <%@taglib uri=http://struts.apache.org/tags.html prefix=html%> <center> <html:form action=login> username: <html:text property=uname/><br> password: <html:password property=pwd/><br> <html:submit value=click></html:submit> </html:form> </center> 10) Right click on project name --> new --> jsp --> File Name: success --> finish. similarly create another jsp called failure. <% out.println(Login Success); %> <% out.println(Login Failure); %> 11) Right Click on Project name struts login --> run

Note: by default, glassfish server uses http service port number as 8080 but there is a clash with oracle http service on port 8080. so we need to change http service port number of glassfish server like the following. 1)go to c:\program files\glassfish-3.0.1\glassfish\domains\domain1\config folder and open domain.xml file and change <network-listener> port from 8080 to 9999. save the xml file. 2)open services tab at left side of NetBeansIDE --> expand servers --> right click on glassfish server and stop then start the glassfish server. steps to develop a struts application on MyEclipse8.x: 1) start --> programs --> MyEclipse --> MyEclipse8.x --> Enter workspace: d:\strutswork1 -->ok. 2)

Das könnte Ihnen auch gefallen