7 Best Practices of Struts

By: Emiley J. Emailed: 1642 times Printed: 2112 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

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

jkmx

6. Use Validator Framework for validating user input

7. Use Custom tags instead of using scriplets and Java code in JSP pages

..,

Struts Home | All Struts Tutorials | Latest Struts Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(6)


1. View Comment

Hi, my name is Jaime,
I wan't to do a jsp which allows the user select an entry provided for a list, and later, goes to a JSP which allows the user modify this entry.
I'm thinking in JavaScript, because I don't know how to modify the id of the form which sends the id of the desireed element for modificating.

Please, help.

Thanks,


View Tutorial          By: Jaime at 2011-10-24 12:47:50
2. View Comment

For Jaime,

Maybe using JavaScript for submitting a form in struts can help you. Checkout this tutorial within web http://www.java-samples.com/showtutorial.php?tutorialid=868

Also if you want to get the id of an element of your form, check out how to manipulate the DOM objects with a DHTML-JavaSCript tutorial

Good luck!!!


View Tutorial          By: Jair Aviles at 2011-11-22 05:49:05
3. View Comment

Hi,
Please give the better example of resource Bundle in Struts 2
framework.


View Tutorial          By: Keerthi at 2012-01-11 11:28:24
4. View Comment

it is very useful and in understandable manner

View Tutorial          By: Deepika at 2012-03-26 05:10:15
5. View Comment

Thanks very use full ..

View Tutorial          By: bal mukund at 2012-08-21 05:42:36
6. View Comment

I want to redirect from a servlet page to another servlet page using execute method in Action, if it is possible then how?
I used a form in the first servlet to redirect. But it is issuing me http 404 :resource not available error.


View Tutorial          By: dinesh at 2014-10-20 16:44:26

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Emiley J.
Error generating R.java from manifest
ERROR 1251: Client does not support authentication protocol requested by server; consider upgrading MySQL client
IIS and Tomcat - how to configure to work together
PHP Warning: Unknown(): Unable to load dynamic library '/usr/local/php4/lib/php/extensions/no-debug ......
Adding your own Application icon for your J2ME application (jar file)
Creating Menus in Code using VB.net
Traversing all files in a directory using Ruby
Using Proxy to connect to URLs in Ruby
POST a form in Ruby
Reading URL content using Ruby (HTTP)
dRuby client/server mode sample program
Benchmark module in Ruby
encoding and decoding in Ruby using Base64 Module
Module Abbrev in Ruby
Standard Library Packages in Ruby

More Tutorials in Struts
Configuring JDBC DataSources in Struts
Struts Classes
FAQ: Why was reload removed from Struts (since 1.1)?
FAQ: Why are my checkboxes not being set from ON to OFF?
Using JavaScript to submit a form in Struts
How to prepopulate a form in Struts
Simple example of using the requiredif Validator rule in Struts
Chaining actions in Struts
When is the best time to validate input in Struts
What is a Plug-in and how to use Java plug-ins with Struts?
7 Best Practices of Struts
Origin and Architecture of Struts
ActionErrors and ActionError in Struts
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
Handling multiple buttons in HTML Form in Struts

More Latest News
Most Viewed Articles (in Struts )
Tutorial on Struts Configuration File - struts-config.xml in Struts - from the book: Struts Survival Guide. Basics to Best Practices
What is Struts? Which Version of Struts to use?
Struts 1 vs Struts 2
ActionErrors and ActionError in Struts
MVC Architecture (Model 2 Architecture)
IncludeAction in Struts
Handling Duplicate Form Submissions in Struts
Installing and configuring Tomcat and Struts
ForwardAction in Struts
Using JavaScript to submit a form in Struts
7 Best Practices of Struts
DispatchAction in Struts
Protecting JSPs from direct access in Struts
Writing the first Struts application
How to prepopulate a form in Struts
Most Emailed Articles (in Struts)
The directories and files of a Struts application
History of Struts
Struts 1 vs Struts 2
Installing and configuring Tomcat and Struts
ActionErrors and ActionError in Struts
ForwardAction in Struts
What is a Model View Controller (MVC) Model?
Creating the first application using Struts 2
Using Multibox in Struts
Using Checkbox & Radio Tags, html:select, html:options in Struts Forms
Use ImageButtonBean for Image based Form Submits in Struts
IncludeAction in Struts
Origin and Architecture of Struts
What is a Plug-in and how to use Java plug-ins with Struts?
FAQ: Why was reload removed from Struts (since 1.1)?