|
-
Now we need to create the Results.jsp page
-
From the main project expand the WebRoot tree, and open the Results.jsp page.
-
Paste the following logic into it and save the page
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ page import="pdata.*" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored ="false" %>
<html:html>
<body bgcolor="lightblue">
<h3>My First Struts Application </h3>
<ul>
<li>${personalDataBean.firstname} </li>
<li>${personalDataBean.lastname} </li>
<li>${personalDataBean.address} </li>
<li>${personalDataBean.city} </li>
<li>${personalDataBean.state} </li>
</ul> <br>
</body>
</html:html>
-
Let's create the Error.jsp page
- From the main project expand the WebRoot tree, and open the Error.jsp page.
- Paste the following logic into it and save the file
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<html>
<body>
<h3>
FAILURE
</h3>
</body>
<html>
-
Create a ApplicationResources.properties file by Right clicking on New => File, and name the file ApplicationResources.properties.
-
Now we need to create a simple build file
- From the main project select the ant folder, and add a new file.
- Right click and select New => File, and name the file build.xml
-
Copy the following logic to it and save the file.
<?xml version="1.0"?>
<project name="Copy To Local Tomcat" default="copy" basedir=".">
<property name="webapp.name" value="BasicStrutsExample"/>
<property environment="env"/>
<property name="source.dir" value="../"/>
<property name="destination.dir" value="C:/Tomcat5.0/webapps/${webapp.name}"/>
<target name="copy"
description="Copies all files to tomcat webapps directory">
<echo message="Copy to: ${destination.dir}"/>
<echo message="Copy from: ${source.dir}"/>
<!-- Copy All Main Files -->
<copy todir="${destination.dir}/">
<fileset dir="${source.dir}/WebRoot/">
<exclude name="**/*.java"/>
<exclude name="**CVS**"/>
</fileset>
</copy>
</target>
</project>
-
Run the ant build
-
Right click on the build.xml and select Run as => 1 Ant Build
NOTE: This should copy all of the files we worked on into the Tomcat webapp directory.
-
You should get the following output:
-
Because we deployed to Tomcat, we need to restart the service so it sees the project.
- Double click the monitor Tomcat icon in the toolbar
- Select stop
- Select start and OK
-
Now we need to add 2 jar files to Tomcat
- Navigate to: C:\Tomcat5.0\webapps\BasicStrutsExample\WEB-INF\lib
- Add the jstl-standard.jar file
- Add the jstl.jar file
-
Let's test the application.
-
Type in the following URL in a web browser: http://localhost:8080/BasicStrutsExample/PersonalData.do.
-
The browser should display:
-
Once you fill in the text boxes and select the submit button, you should see the following screen:
Congratulations! You have just created your first struts application.
Page 1 Page 2 Page 3
|
|