8. Now the final piece - lets write the TestResult.jsp:
Here is the code for that:
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<jsp:useBean id="TestFormBean" scope="request"
type="com.openstack.struts.testapp.TestFormBean"/>
<html:html>
<head>
<title>test results</title>
</head>
<body bgcolor="white">
<h3><jsp:getProperty name="TestFormBean"
property="ipString"/></h3>
</body>
</html:html>
Looking at the JSP, it defines a bean instance and uses it to print a bean property ipString:
<bean:write name="TestFormBean" property="ipString"/>
This prints the changed ipString as part of "ActionHandler".
9. Now we are ready to test. Click on compile all from the main menu, just to make sure that we have all our java code compiled. Right click on theTestFormPage.jsp and click on Execute. Depending on your settings NetBeans might give some warning like HTTP server could not be started etc. Click OK till it displays a browser window. Soon your page should show up.
10. Enter your name and click submit. The next page should come with a welcome message!!!
Conclusion:
As discussed we created a sample web
application using STRUTS. While doing that we used NetBeans as
an IDE, we utilized some tool features (such as auto generate
getters & setters), used the integrated TomCat and the compile &
test features of NetBeans. Reference
- For
further details on building an enterprise application using open
source tools such as STRUTS check out The OpenStack
Project.
- Sample code for the first open stack
project is at The
Project Page on sourceforge.
- STRUTS Kick Start
by James Turner & Kevin Bedell (SAMS) is a very good book on
STRUTS.
- On the
STRUTS resource page you will find excellent
collection of articles on STRUTS.
[Index]
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.