advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Tutorials : Building a sample Web App with STRUTS:

Building a sample Web App with STRUTS

by Harshal Deo

A few years back I wrote an article on 'Building Sample Web App with Servlets & JSP'. A lot has changed since then. In this article, I will discuss building a sample web application using STRUTS. STRUTS is a leading open-source Web Application Framework. A lot has been written about it and if you want a detailed introduction, please read The Introduction To STRUTS
Articles. NetBeans is the leading open-source IDE and we will use it to demonstrate how to simplify application development using the IDE. Finally our application will run on TomCat application server.

For this article we will use the following versions:
STRUTS 1.1 Beta 3 , NetBeans IDE 3.4.

Prerequisites:

We will assume that as a reader you are familiar with web application development, specifically using JSP and Java.

Preparation:

We need to install NetBeans IDE (and JDK needed for the IDE). You can install NetBeans from www.netbeans.org. Or click here for simple instructions on how to install the IDE.

Quick overview:

We will create a very simple web application just to demonstrate screen flow and action handling using STRUTS. We will use NetBeans to create the JSP aNDjava files, use tools such as auto generation of getters and setters and finally use the IDE to compile and test the app. NetBeans comes with integrated TomCat.

The application will just have two pages. A Start page where you enter your name and a results page that will display a personalized welcome message.

Ok, so let's get started.

1. Download the Quick start Zip File from here and extract it to any directory. It should create this directory structure:

StrutsNetBeansSample
	/META-INF   (Some meta info - ignore for now)

/WEB-INF  (Main dir. For our web app - 

the TLD files are struts tag libraries. Also there are 2 config files) /Lib (Struts.jar - the struts framework jar file) /Src (Here we will keep our sources ) Under this we have dir structure com/openstack/struts/testapp /Classes (Here we the built classes will be stored)
Note: Normally the struts.jar , tld and config files will be downloaded from Struts website, when you download and install STRUTS. These are provided here just for the 'quick start'.

2. Start NetBeans and mount this directory(In netbeans, right click on filesystems in editor window -choose the 'local directory' option and choose the directory: StrutsNetBeansSample). After you successfully mount the directory the editor window will show the StrutsNetBeansSample directory and underlying WEB-INF/classes directory as two separate entries. If not then mount those directories separately. At this point you can now switch to the 'project' window in NetBeans if you prefer that view - the 'alternate' view.

3. Now let us create our first JSP - a Test Form. A sample JSP is provided under the quickstart directory. Create the TestForm.jsp under the document base (StrutsNetBeansSample) directory. It should look like this:

< %@ 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" %>

< html:html>
< head>
< title>test form < /title>
< /head>
< body bgcolor="white">
< B> This is a template STRUTS APP< /b>
Please enter your name:
< html:form action="/TestAction">

      < html:text property="ipString" size="50"/>

      < html:submit property="submit" value="Submit"/>
< /html:form>
< /body>
< /html:html>



[Next]

Harshal Deo has 10 years of experience working with enterprise systems. He has worked with companies like Citicorp & KPMG and currently works for an enterprise software company Asera. Previously he has worked with a valley startup MHP, as a lead Architect, defining the application architecture of its J2EE based system. He has also published a few articles on technology and related areas.

Harshal is also one of the founders of www.theopenstack.com--an online community, simplifying and promoting the use of open source technologies for enterprise application development.

How to Add Java Applets to Your Site

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.

 Microsoft Visual Studio 2010 Showcase
 Avaya Developer Showcase
 MSDN Spotlight
 PHP for Windows Showcase
XML error: undefined entity at line 39
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

Windows 7: From Beta to Final Code in One Year
Google Shows Off Chrome OS, Releases Source
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?
Fedora 12 Takes Aim at Linux Networking
Top Supercomputer Nearly Doubles in Speed
Fedora 12 Linux Tackles Virtualization
Apple Gives iPhone Developers App Status Tracker
Novell Sets OpenSUSE 11.2 Free

Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Exploring HTML 5's Audio/Video Multimedia Support
Overriding Virtual Functions? Use C++0x Attributes to Avoid Bugs.
Understanding the Cloud Computing Security Vulnerabilities
Cisco and IBM Target a Greener World
Upgrade to Visual Studio 2010 with the Ultimate Offer

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs