Struts Tutorials

1. Configuring JDBC DataSources in Struts

By: Barbara : 2008-12-10

Description: You can define any number of JDBC javax.sql.DataSource objects for the application in the configuration file under the element . Every data source is defined within the element using the element. The element defines a number of attributes, the most important of which are listed in Table below.


2. Struts Classes

By: Barbara : 2008-12-09

Description: As you'd expect in an MVC framework, every request starts at the Struts controller, the heart of which is the ActionServlet class. This servlet is usually mapped to the extension *.do. For example, a request for /process.do would end up with the ActionServlet and tell it that the user has submitted a pizza order:


3. FAQ: Why was reload removed from Struts (since 1.1)?

By: Apache Foundation : 2008-09-20

Description: The problem with ReloadAction was that Struts was trying to act like a container, but it couldn't do a proper job of it. For example, you can't reload classes that have been modified, or (portably) add new classes to a running web application (even if the container supported it).


4. FAQ: Why are my checkboxes not being set from ON to OFF?

By: Apache Foundation : 2008-09-20

Description: A problem with a checkbox is that the browser will only include it in the request when it is checked. If it is not checked, the HTML specification suggests that it not be sent (i.e. omitted from the request). If the value of the checkbox is being persisted, either in a session bean or in the model, a checked box can never unchecked by a HTML form -- because the form can never send a signal to uncheck the box. The application must somehow ascertain that since the element was not sent that the corresponding value is unchecked.


5. Using JavaScript to submit a form in Struts

By: Apache Foundation : 2008-09-20

Description: This is just one of many ways to achieve submitting a form and decoding the intended action. Once you get used to the framework you will find other ways that make more sense for your coding style and requirements. Just remember this example is completely non-functional without JavaScript.


6. How to prepopulate a form in Struts

By: Apache Foundation : 2008-09-20

Description: The simplest way to prepopulate a form is to have an Action whose sole purpose is to populate an ActionForm and forward to the servlet or JSP to render that form back to the client. A separate Action would then be use to process the submitted form fields, by declaring an instance of the same form bean name.


7. Simple example of using the requiredif Validator rule in Struts

By: Apache Foundation : 2008-09-20

Description: First off, there's an even newer Validator rule called validwhen, which is almost certainly what you want to use, since it is much easier and more powerful. It will be available in the first release after 1.1 ships. The example shown below could be coded with validwhen as:


8. Chaining actions in Struts

By: Apache Foundation : 2008-09-20

Description: Chaining actions can be done by simply using the proper mapping in your forward entries in the struts-config.xml file. Assume you had the following two classes:


9. When is the best time to validate input in Struts

By: Apache Foundation : 2008-09-20

Description: This is an excellent question. Let's step back a second and think about a typical mid to large size application. If we start from the back end and work toward the view we have:


10. What is a Plug-in and how to use Java plug-ins with Struts?

By: Emiley J. : 2008-09-17

Description: Any Java class that you want to initialize when Struts application starts up and destroy when the application shuts down is a Java Plug-in. You can create a Java Plug-in by creating a Java class that implements org.apache.struts.action.Plugin interface.