Home > Articles > Programming > Java

Struts Kick Start: Building Applications

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Close Window

Kevin BedellJames Turner 

Learn more…

Sorry, this author hasn't written any articles.

Sorry, this author doesn't have anything for sale.

Sorry, this author hasn't posted any blogs.

Struts Kick Start

This chapter is from the book
Struts Kick Start

Kevin Bedell and James Turner provide a rapid introduction to Struts by building a complete, although basic application from scratch. Competent developers quickly learn the basics of how to build Struts applications.
Get the latest and greatest in coding from Sams' collection of Kick Start titles. Give your code a Kick Start!

In This Chapter

  • Hello World! Application Requirements

  • Applying the Model-View-Controller Pattern

  • The View Component: The HTML Form and the Form Bean

  • MessageResources and Application.properties Files

  • The Struts Form Bean: HelloForm.java

  • Data Validation and ActionErrors

  • The Controller Component: HelloAction.java

  • The Model Component (HelloModel.java)

  • Passing Data to the View Using Attributes: Constants.java

  • Tying It All Together: The struts-config.xml File

  • Conclusions

This chapter provides a rapid introduction to Struts by building a complete—although basic—application from scratch. The goal of this chapter is to enable a competent developer to quickly grasp all the basics of how to build Struts applications.

The chapter continues the longstanding tradition of developing a first program in a new language that simply prints Hello World!. This enables developers to quickly grasp the fundamentals of how the program works without forcing them to think too much about the application requirements. To demonstrate some of the important features of Struts, however, the application built here will have a few additional features.

Development of a sample application will be covered including:

  • Application requirements

  • Using the Model-View-Controller pattern to design a solution using Struts

  • The View component: The HTML form and the form bean

  • MessageResources and Application.properties files

  • The Struts form bean: HelloForm.java

  • Data validation and using ActionErrors

  • The Controller component: HelloAction.java

  • The Model component: HelloModel.java

  • Passing data to the View using attributes: Constants.java

  • Tying it all together: struts-config.xml

Hello World! Application Requirements

The requirements of this application are very basic. They are as follows:

  • Enable the user to enter a name to say Hello! to and output the string Hello <name>!.

  • Don't let the user submit the entry form without entering a name. If he does, provide an error message to help him fill the form out correctly.

  • To add more Controller functionality (and have a bit more fun), the application should not allow the user to say hello to people they're "not allowed" to talk to.

  • To demonstrate Model components, the application should use a Model component to save the name entered for later.

This basic application provides a little bit of functionality in all three of the Model, View, and Controller components.

  • Share ThisShare This
  • Your Account

Discussions

Almost
Posted Sep 26, 2009 02:15 PM by mooladays
0 Replies
Struts
Posted Jan 10, 2008 12:28 AM by wnaveenkumar
0 Replies
about an error from struts program
Posted Jan 9, 2008 11:43 PM by wnaveenkumar
0 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

Emily NaveCommunity Tips: Starting a User Group Library
By Emily Nave on August 3, 20102 Comments

The Central Penn Adobe User Group (CPAUG) uses a library program to share books from different publishers with members. A short Q&A with group leader Megan Fister provides some great tips for starting your own.

Keep going with GWT
By Federico Kereki on August 1, 2010 No Comments

I've been using GWT for some years now, and I'm still contented with the easier way for web development. After having written a book on GWT development, doing a blog seemed a good idea for answering questions, and for further expanding topics that didn't get a place in the book.

Emily NaveUser Group Organizations: Finding Support in the Greater IT Community
By Emily Nave on July 29, 20102 Comments

Birds of a feather flock together, right? If you’re already a member of an established user group or looking for other like-minded technology evangelists, connecting with peers is an important part of being an active voice in the IT community.

See All Related Blogs

Informit Network