|
|
|
Tomcat will automatically deploy the application. To test the struts-blank application type http:/ /localhost:8080/struts2-blank-2.0.6 in the browser and the struts-blank application get displayed in your browser window.
Struts 2 Hello World - Developing Hello World Application
In this section we will develop Hello World based on the Struts 2 Framework. Our Struts 2 Hello World application is the first step towards developing applications based on the Struts 2 Framework. It covers the basic steps like creating directory structure, developing build.xml file to build the application using ant build tool. Then we will write JSP, Java and configuration files required for the application.
Creating directory structure and Ant build file for the project
Step1: Extract struts 2 download and copy
struts2-blank-2.0.6.war (If you are using latest version of struts 2 then it may be different for you) to your tomcat’s webapps directory. Rename struts2-blank-2.0.6 to struts2example and unzip it in the tomcat’s webapps directory. Start tomcat and type http://localhost:8080/ struts2example/ into your browser. Now, you have successfully installed struts 2 blank application to start with.
Step 2: Now delete the content of
struts2example\WEB-INF\src and struts2example\WEB-INF\classes directories, as
we don’t need these files that comes with struts 2 blank application.
|
|
Step 3: Create build.xml file in the struts2example\WEB-INF\src and paste the following content in the build.xml file.
<project name=”struts2example” basedir=”../
” default=”all”>
<!— Project settings —>
<property name=”project.title”
value=”JavaJazzUp Struts 2"/>
<property name=”project.jar.file”
value=”struts2example.jar”/>
<path id=”class.path”>
<fileset dir=”lib”>
<include name=”**/*.jar”/>
</fileset>
<fileset dir=”libext”>
<include name=”**/*.jar”/>
</fileset>
</path>
<!— Classpath for Project —>
<path id=”compile.classpath”>
<pathelement path =”lib/commonsdigester.
jar”/>
<pathelement path =”lib/commonsdigester.
jar”/>
<pathelement path =”lib/struts.jar”/>
<pathelement path =”libext/servlet-api.jar”/>
<pathelement path =”libext/catalina-ant.jar”
/>
<pathelement path =”classes”/>
<pathelement path =”${classpath}”/>
</path>
<!— Check timestamp on files —>
<target name=”prepare”>
<tstamp/>
<copy file=”src/struts.xml”
todir=”src/classes”/>
</target>
<!— Copy any resource or configuration files
—>
<target name=”resources”>
<copy todir=”src/classes”
includeEmptyDirs=”no”>
<fileset dir=”src/java”>
<patternset>
<include name=”**/*.conf”/>
<include name=”**/*.properties”/>
<include name=”**/*.xml”/>
</patternset>
</fileset>
</copy>
</target>
|
|
|
|
|
Nov 2007 | Java Jazz Up | 32 |
|
|
|
View All Topics |
All Pages of this Issue |
Pages:
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53 ,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63 ,
64,
65 ,
66 ,
67 ,
68 ,
69 Download PDF |
|
|
|
|
|
|
|
|
|