This page contains Frequently Asked Questions relating to Struts 1
How can I learn Struts? (link)- What tutorials are available? (link)
- What books are available? (link)
Where can I find an example of a Struts Application? (link)How do I set a default value for an html:select tag? (SelectDefaultValue)How do I include the right JavaScript .js files when I'm using Tiles?(TilesJavaScript)How can I keep from adding a duplicate record to the database or ordering a duplicate product if the user submits the form a second time by mistake? (HowToPreventMultipleFormSubmits)I have an ArrayList of JavaBeans in my ActionForm and would like my JSP to display a table that has input fields for each bean in the list. How do I do that in Struts? (IndexedProperties)How do I access a database in my Struts Application? (StrutsDataSource) How do I set up Eclipse for Struts development? (StrutsAndEclipse) When I submit a form, I'm getting the error Cannot create bean of class com.mycompany.MyForm What's wrong? (CannotCreateBean)When I submit a form, I'm getting the error Exception thrown : javax.servlet.ServletException: BeanUtils.populate What's wrong? (PopulateError) When I try to display a Struts JSP, I get the error java.lang.NullPointerException: Module 'null' not found What's wrong? (ModuleNull)When I try to display a Struts JSP, I get the error Cannot find ActionMappings or ActionFormBeans collection What's wrong? (NoActionMappings)I'm using IndexedProperties in my JSP, and I'm getting the error java.lang.IllegalArgumentException: Property myProperty is not indexed What's wrong? (PropertyNotIndexed)I'm using Tiles in my application, and it worked before, but since I upgraded to Struts 1.3.x it stopped working. What's wrong? (Tiles13Upgrade)Is there a way to get Struts to reload the message resources files without restarting the server or the application? (ReloadMessageResources)I'm trying to generate Struts tags dynamically in a scriptlet, but it doesn't seem to work. What's wrong? (StrutsTagsInScriptlets)I've got a JSP with a select tag and options generated from a database that I put in request scope. It works fine if there are no errors, but if Struts validation returns to the input page because of a validation error, the collection of options is no longer there. How can I solve this problem? (RefreshValuesOnValidationError)How do I upload files using Struts? See http://wiki.apache.org/struts/StrutsFileUpload
How can I learn Struts?
Start by checking out what is available at the
Struts Home Page . This site has links to a lot of good
information about Struts. Then check out the
Struts Wiki. This page has a wealth of good information about struts
When you're first starting out, though, it's much better to learn by trying it out than poring over a bunch of reference materials.
Tutorials
If you want to start out just using your favorite text editor, the
Struts Wiki Tutorials Page has the best listing of free tutorials.
If you're going to be using an
IDE, such as
Eclipse or
NetBeans, you're in luck. Struts is popular enough and has been around long enough that most IDEs now have some sort of Struts support. When you're learning, it's a good idea to search for a Struts tutorial that is geared toward your particular IDE. Try Googling "Struts Tutorial xxx" where xxx is the name of your favorite IDE.
Here are some simple flash tutorials on creating a Struts application with
WebSphere Studio
WSAD and Struts
Books
While it's true that there's a lot of good reference material on the
Struts Home Page, a book written by a professional author can provide a much more organized, concise, and clear picture of the framework.
Here are some good books on Struts:
Struts: The Complete Reference James Holmes, McGraw-Hill, Published 2004
Programming Jakarta Struts, 2nd Edition Chuck Cavaness, O'Reilly Media, Published 2004, 2nd edition
Struts in Action Ted Husted, et al, Manning Publications, Published 2002
Beginning Apache Struts: From Novice to Professional Arnold Doray, Apress, Published 2006
Professional Jakarta Struts James Goodwill, Wrox Press, Published 2003
Pro Jakarta Struts, 2nd Edition John Carnell, et al, Apress, Published 2004
For a more complete list, see the
Struts Wiki Books Page.
Also check out the
JavaRanch Bunkhouse J2EE book list for some reviews of Struts books.
Where can I find an example of a Struts Application?
The first place to start is with the material you received when you downloaded Struts. When you unzip the file, there is a
webapps directory. In this directory, you will find the
struts-examples.war file. Deploy this war file to your app server and run it. Then look at the source code for it. That should give you a good idea of some of the things you can do in Struts, and how it all works.
You may say, "Yes, I've looked at that, but it's really just a toy application that doesn't do anything important. I want an example of a real application that was built using Struts." If you want real applications, you can download several from
this page on SourceForge. The Beer4All application on that page is a good example of a shopping cart application using Struts.
StrutsFaq