* user locale. For (Web server info) example, if there is
* user locale. For example, if there is a Date object inthe array, it * would need to be formatted for each locale. */ // Now construct an instance of the ActionError class if ( args != null && args.length > 0 ){ // Use the arguments that were provided in the exception newActionError = new ActionError( errorCode, args ); }else{ newActionError = new ActionError( errorCode ); } errors.add( ActionErrors.GLOBAL_ERROR, newActionError ); } The processBaseException( )method is responsible for creating the ActionError object. It uses the messageKey field to look up a bundle message, and if any arguments are included, it includes those in the ActionError constructor as well. As you can see, adding programmatic exception handling to your applications definitely requires more work than using the default behavior provided by the Struts framework. It also makes maintenance more difficult if you drastically change your exception hierarchy or change how you want to handle certain exceptions. However, if you are using an earlier version of Struts, this may be your only choice. You may have to extend these examples for your own applications, but they show a well-designed approach that you can build upon. Within the EJB and Servlet specifications, programmatic security is frowned upon because it’s too easy to couple your application to the physical security environment. With exception handling, it’s unlikely that you’ll need to change the exceptions that are thrown based on the target environment. Therefore, there isn’t the same stigma associated with programmatic exception handling as there is with programmatic security. It is true, though, that if you can take advantage of declarative exception handling, your application will be easier to maintain than if you have the same functionality in your source code. An application will almost always be modified over time, and new exceptions will need to be thrown and caught. The more you can specify declaratively, the easier time you’ll have maintaining it. 10.5 Tying Up the Loose Ends Before we leave the topic of exception handling, there are several special cases that we should discuss. Each one of these is unique, and you may or may not need them in your applications. 10.5.1 Handling Remote Exceptions Remote Java objects are allowed to throw instances of java.rmi.RemoteException. In fact, every EJB method that is exposed to a remote client must declare that it throws RemoteException. Dealing with RemoteExceptions is very similar to handling system exceptions except that they are not descendants of either java.lang.Erroror java.lang.RuntimeException.
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.