Procedure the above diagram based application by using myeclipseIDE:-
Step1:- Launch myeclipse IDE by choosing one workspace folder.
Step2:- create web project in myeclipseide.
File –> new –>web project –>project name: StrutsDemoApp3 –> finish.
Step3:- Add Struts capabilities to the project
Right click on project à my eclipse –>add Struts capabilities –>select
Struts 1.3 –>based package for new classes: p1 –>finish.
Note: – the above step add Struts related jar to project library automatically.
Step4:- Add Action class to Struts application.
Right click in src folder –> new –>other –> my eclipse –> web Struts –>Struts 1.3 –>Struts 1.3
Action –>next –>path: /wish path –> superclass org.apache.Struts.action.Action –>
Type: WishAction –>forwards tag –>add –>name: ok path: /result.jsp –>add –>finish
Step5:- Write following code in the execute (-,-,-,-) method of WishAction class.
Calendar c1 = calendar.getInstance();
// gives current data & time
Int h = d.get (calendar. HOUR-OF-DAY);
String msg = null;
If (h < = 12)
Msg = “good morning jalli”;
else If (h < = 16)
Msg = “good Afternoon jalli”;
else If (h < = 20)
Msg = “good evening jalli”;
Else
Msg = “good night jalli”;
// Store result in request attribute to send to result page
Request.setAttribute (“attr1”, msg);
Return mapping.findForward (“ok”);
Step6:- Add jsp page webpage to webroot folder of the project.
Right click on webroot folder –>new –> jsp –> name: page.jsp –> finish
Page.jsp
<%@ taglib uri = “http: // Struts.apache.org / tags.html” prefix = “html” %>
<html: link action = “wish path”> get wish msg </html: link>
Step7:- Add result.jsp to the webroot folder of the project.
r.c on webroot folder –>new –> jsp –>name: result.jsp –> finish.
Result.jsp
<%@ taglib uri = “http: // Struts.apache.org / tags.bean” prefix = “bean” %>
The message is: <bean: write scope = “request” name = “attr1”/>
Step8:- Configure Tomcat 6.0 server with my eclipse ide.
Window menu –>preferences –>my eclipse –> Servers –> Tomcat –>configure Tomcat 6.x –>
Enable
Tomcat home directory D: \ Tomcat 6.0 browse
Tomcat base directory D: \ Tomcat 6.0
temp –>apply –>ok.
Step9:- Star the tomcat server
Go to server icon in the tool bar –>tomcat 6.x –>start
Step10:- develop the project in tomcat server
Go to deploy icon in the tool bar –>projects StrutsDemoApp3 –> add –> server: Tomcat 6.x
Explored Archive development mode
Package Archive (production mode)
Deployment directory: –>automatically come à finish à ok
Step11:- test the application open browser window (globe in tool url) type below url
http://localhost:2020/StrutsDemoApp3/page.jsp