Building and application using ant
At first download the Ant from the Apache site and then configure it in your system environment variable Now make a build.xml file as
build.xml
<project name="Struts 2 Tutorial" basedir="../" default="all"> <!-- Project settings --> <property name="project.jar.file" value="struts2tutorial.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/commons-beanutils.jar"/> <pathelement path ="lib/commons-digester.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> <!-- 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> <!-- Normal build of application --> <target name="compile" depends="prepare,resources"> <javac srcdir="src" destdir="src/classes" debug="true" debuglevel="lines,vars,source"> <classpath refid="class.path"/> </javac> <jar jarfile="lib/${project.jar.file}" basedir="src/classes"/> </target> <!-- Remove classes directory for clean build --> <target name="clean" description="Prepare for clean build"> <delete dir="src/classes"/> <mkdir dir="src/classes"/> </target> <!-- Build entire project --> <target name="project" depends="clean,prepare,compile"/> <!-- Build project and create distribution--> <target name="all" depends="project"/> </project>
In the above file you set the library, source directory, destination directory, pattern set, etc.
Save this build.xml file in the source directory. Now open the command prompt and go to the source directory and then type ant and press enter then the console appears like this
This indicates that you have built the project successfully. Now start the tomcat and open the browser ant type http://localhost:8080/login/roseindia/loginPage.action
Then the page appears like this.
Login Page Home PageIf you give password other than "web" The control remain on the login page
Advertisements
Ads
Ads