7 Best Practices of Struts
By: Emiley J.
1. Extend When You Must
•Struts framework can be stretched and customized to allow for customized behavior.
•Configuration classes in the Struts framework (say, Struts configuration file , ActionServlet RequestProcessor) can be substituted for a customized version.
•Declarative Exception Handling mechanism also allows for custom exception handlers to be used to better respond to application failures.
•Extension should be done judiciously.
•Before extending a Framework, we should always make sure that the functionality doesn't already exist somewhere.
2. Use Application Modules
•Splitting of a single Struts application into multiple modules is allowed.
•This solves one of the biggest complaints that development groups of more than a few people have had for some time because we can create Separate Struts Configuration Files for
Individual Applications.
•Each Struts application module should have its own configuration file. This allows us to configure separate Actions, ActionForms, exception handling, and much more, independent of other
application modules.
3. Use Declarative Exception Handling
•Struts framework includes a class called ExceptionHandler.
•This class by default is responsible for processing any exceptions that occur during action execution.
•This class actually creates an ActionError object and stores it in the appropriate scope object.
•This allows the JSP pages to use the errors to inform the user of a problem.
•Customized ExceptionHandler classes can also be used.
4. Use a Base Action for your application
•Often, Actions in an application will need to perform some basic tasks.
•To ensure these tasks are implemented consistently, create a base Action that can be sub-classed by other actions in the application.
5. Check logins at the Controller Level
jkmx6. Use Validator Framework for validating user input
7. Use Custom tags instead of using scriplets and Java code in JSP pages
..,Archived Comments
1. I want to redirect from a servlet page to another servlet page using execute method in Action, if it
View Tutorial By: dinesh at 2014-10-20 16:44:26
2. Thanks very use full ..
View Tutorial By: bal mukund at 2012-08-21 05:42:36
3. it is very useful and in understandable manner
View Tutorial By: Deepika at 2012-03-26 05:10:15
4. Hi,
Please give the better example of resource Bundle in Struts 2
framework.
View Tutorial By: Keerthi at 2012-01-11 11:28:24
5. For Jaime,
Maybe using JavaScript for submitting a form in struts can help you. Check
View Tutorial By: Jair Aviles at 2011-11-22 05:49:05
6. Hi, my name is Jaime,
I wan't to do a jsp which allows the user select an entry provided for
View Tutorial By: Jaime at 2011-10-24 12:47:50
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Configuring JDBC DataSources in Struts
When is the best time to validate input in Struts
Simple example of using the requiredif Validator rule in Struts
How to prepopulate a form in Struts
Using JavaScript to submit a form in Struts
FAQ: Why are my checkboxes not being set from ON to OFF?
FAQ: Why was reload removed from Struts (since 1.1)?
What is a Plug-in and how to use Java plug-ins with Struts?
Origin and Architecture of Struts
Handling multiple buttons in HTML Form in Struts