Modified: struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java?rev=375627&r1=375626&r2=375627&view=diff ============================================================================== --- struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java (original) +++ struts/action/trunk/src/java/org/apache/struts/action/DynaActionFormClass.java Tue Feb 7 07:25:16 2006 @@ -25,6 +25,7 @@ import org.apache.struts.util.RequestUtils; import java.io.Serializable; + import java.util.HashMap; /** @@ -39,7 +40,6 @@ * @since Struts 1.1 */ public class DynaActionFormClass implements DynaClass, Serializable { - // ----------------------------------------------------- Instance Variables /** @@ -76,8 +76,9 @@ /** * <p>Construct a new <code>DynaActionFormClass</code> for the specified * form bean configuration. This constructor is private; - * <code>DynaActionFormClass</code> instances will be created as needed via - * calls to the static <code>createDynaActionFormClass()</code> method.</p> + * <code>DynaActionFormClass</code> instances will be created as needed + * via calls to the static <code>createDynaActionFormClass()</code> + * method.</p> * * @param config The FormBeanConfig instance describing the properties of * the bean to be created @@ -105,8 +106,8 @@ } /** - * <p>Return a property descriptor for the specified property, if it exists; - * otherwise, return <code>null</code>.</p> + * <p>Return a property descriptor for the specified property, if it + * exists; otherwise, return <code>null</code>.</p> * * @param name Name of the dynamic property for which a descriptor is * requested @@ -138,9 +139,10 @@ /** * <p>Instantiate and return a new [EMAIL PROTECTED] DynaActionForm} instance, - * associated with this <code>DynaActionFormClass</code>. The properties of - * the returned [EMAIL PROTECTED] DynaActionForm} will have been initialized to the - * default values specified in the form bean configuration information.</p> + * associated with this <code>DynaActionFormClass</code>. The properties + * of the returned [EMAIL PROTECTED] DynaActionForm} will have been initialized to + * the default values specified in the form bean configuration + * information.</p> * * @return A new [EMAIL PROTECTED] DynaActionForm} instance. * @throws IllegalAccessException if the Class or the appropriate @@ -151,9 +153,8 @@ * some other reason */ public DynaBean newInstance() - throws IllegalAccessException, InstantiationException { - DynaActionForm dynaBean = - (DynaActionForm) getBeanClass().newInstance(); + throws IllegalAccessException, InstantiationException { + DynaActionForm dynaBean = (DynaActionForm) getBeanClass().newInstance(); dynaBean.setDynaActionFormClass(this); @@ -206,7 +207,7 @@ * @return The instance for the specified form bean config. */ public static DynaActionFormClass createDynaActionFormClass( - FormBeanConfig config) { + FormBeanConfig config) { return config.getDynaActionFormClass(); } @@ -214,9 +215,9 @@ /** * <p>Return the implementation class we are using to construct new - * instances, re-introspecting our [EMAIL PROTECTED] FormBeanConfig} if necessary (that - * is, after being deserialized, since <code>beanClass</code> is marked - * transient).</p> + * instances, re-introspecting our [EMAIL PROTECTED] FormBeanConfig} if necessary + * (that is, after being deserialized, since <code>beanClass</code> is + * marked transient).</p> * * @return The implementation class used to construct new instances. */ @@ -245,17 +246,17 @@ // Validate the ActionFormBean implementation class try { beanClass = RequestUtils.applicationClass(config.getType()); - } catch (Throwable t) { + } + catch (Throwable t) { throw new IllegalArgumentException( - "Cannot instantiate ActionFormBean class '" - + config.getType() - + "': " + t); + "Cannot instantiate ActionFormBean class '" + config.getType() + + "': " + t); } if (!DynaActionForm.class.isAssignableFrom(beanClass)) { throw new IllegalArgumentException("Class '" + config.getType() - + "' is not a subclass of " - + "'org.apache.struts.action.DynaActionForm'"); + + "' is not a subclass of " + + "'org.apache.struts.action.DynaActionForm'"); } // Set the name we will know ourselves by from the form bean name @@ -272,7 +273,8 @@ properties = new DynaProperty[descriptors.length]; for (int i = 0; i < descriptors.length; i++) { - properties[i] = new DynaProperty(descriptors[i].getName(), + properties[i] = + new DynaProperty(descriptors[i].getName(), descriptors[i].getTypeClass()); propertiesMap.put(properties[i].getName(), properties[i]); }
Modified: struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java?rev=375627&r1=375626&r2=375627&view=diff ============================================================================== --- struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java (original) +++ struts/action/trunk/src/java/org/apache/struts/action/ExceptionHandler.java Tue Feb 7 07:25:16 2006 @@ -28,6 +28,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import java.io.IOException; /** @@ -42,7 +43,8 @@ * <p>The name of a configuration property which can be set to specify an * alternative path which should be used when the HttpServletResponse has * already been committed.</p> <p>To use this, in your - * <code>struts-config.xml</code> specify the exception handler like this: + * <code>struts-config.xml</code> specify the exception handler like + * this: * <pre> * <exception * key="GlobalExceptionHandler.default" @@ -51,8 +53,8 @@ * <set-property key="INCLUDE_PATH" value="/error.jsp" /> * </exception> * </pre> - * </p> <p>You would want to use this when your normal ExceptionHandler path - * is a Tiles definition or otherwise unsuitable for use in an + * </p> <p>You would want to use this when your normal ExceptionHandler + * path is a Tiles definition or otherwise unsuitable for use in an * <code>include</code> context. If you do not use this, and you do not * specify "SILENT_IF_COMMITTED" then the ExceptionHandler will attempt to * forward to the same path which would be used in normal circumstances, @@ -66,10 +68,11 @@ /** * <p>The name of a configuration property which indicates that Struts * should do nothing if the response has already been committed. This - * suppresses the default behavior, which is to use an "include" rather than - * a "forward" in this case in hopes of providing some meaningful + * suppresses the default behavior, which is to use an "include" rather + * than a "forward" in this case in hopes of providing some meaningful * information to the browser.</p> <p>To use this, in your - * <code>struts-config.xml</code> specify the exception handler like this: + * <code>struts-config.xml</code> specify the exception handler like + * this: * <pre> * <exception * key="GlobalExceptionHandler.default" @@ -78,11 +81,11 @@ * <set-property key="SILENT_IF_COMMITTED" value="true" /> * </exception> * </pre> - * To be effective, this value must be defined to the literal String "true". - * If it is not defined or defined to any other value, the default behavior - * will be used. </p> <p>You only need to use this if you do not want error - * information displayed in the browser when Struts intercepts an exception - * after the response has been committed.</p> + * To be effective, this value must be defined to the literal String + * "true". If it is not defined or defined to any other value, the default + * behavior will be used. </p> <p>You only need to use this if you do not + * want error information displayed in the browser when Struts intercepts + * an exception after the response has been committed.</p> * * @since Struts 1.3 */ @@ -96,8 +99,9 @@ /** * <p>The message resources for this package.</p> */ - private static MessageResources messages = MessageResources - .getMessageResources("org.apache.struts.action.LocalStrings"); + private static MessageResources messages = + MessageResources.getMessageResources( + "org.apache.struts.action.LocalStrings"); /** * <p> Handle the Exception. Return the ActionForward instance (if any) @@ -109,17 +113,15 @@ * @param formInstance The ActionForm we are processing * @param request The servlet request we are processing * @param response The servlet response we are creating - * @return The <code>ActionForward</code> instance (if any) returned by the - * called <code>ExceptionHandler</code>. + * @return The <code>ActionForward</code> instance (if any) returned by + * the called <code>ExceptionHandler</code>. * @throws ServletException if a servlet exception occurs * @since Struts 1.1 */ public ActionForward execute(Exception ex, ExceptionConfig ae, - ActionMapping mapping, - ActionForm formInstance, - HttpServletRequest request, - HttpServletResponse response) - throws ServletException { + ActionMapping mapping, ActionForm formInstance, + HttpServletRequest request, HttpServletResponse response) + throws ServletException { LOG.debug("ExceptionHandler executing for exception " + ex); ActionForward forward; @@ -130,7 +132,8 @@ // or from the form input if (ae.getPath() != null) { forward = new ActionForward(ae.getPath()); - } else { + } + else { forward = mapping.getInputForward(); } @@ -138,7 +141,8 @@ if (ex instanceof ModuleException) { error = ((ModuleException) ex).getActionMessage(); property = ((ModuleException) ex).getProperty(); - } else { + } + else { error = new ActionMessage(ae.getKey(), ex.getMessage()); property = error.getKey(); } @@ -154,13 +158,15 @@ } LOG.debug("Response is already committed, so forwarding will not work." - + " Attempt alternate handling."); + + " Attempt alternate handling."); + if (!silent(ae)) { handleCommittedResponse(ex, ae, mapping, formInstance, request, - response, forward); - } else { + response, forward); + } + else { LOG.warn("ExceptionHandler configured with " + SILENT_IF_COMMITTED - + " and response is committed.", ex); + + " and response is committed.", ex); } return null; @@ -168,10 +174,10 @@ /** * <p>Attempt to give good information when the response has already been - * committed when the exception was thrown. This happens often when Tiles is - * used. Base implementation will see if the INCLUDE_PATH property has been - * set, or if not, it will attempt to use the same path to which control - * would have been forwarded.</p> + * committed when the exception was thrown. This happens often when Tiles + * is used. Base implementation will see if the INCLUDE_PATH property has + * been set, or if not, it will attempt to use the same path to which + * control would have been forwarded.</p> * * @param ex The exception to handle * @param config The ExceptionConfig we are processing @@ -183,71 +189,63 @@ * @since Struts 1.3 */ protected void handleCommittedResponse(Exception ex, - ExceptionConfig config, - ActionMapping mapping, - ActionForm formInstance, - HttpServletRequest request, - HttpServletResponse response, - ActionForward actionForward) { + ExceptionConfig config, ActionMapping mapping, ActionForm formInstance, + HttpServletRequest request, HttpServletResponse response, + ActionForward actionForward) { String includePath = determineIncludePath(config, actionForward); if (includePath != null) { if (includePath.startsWith("/")) { - LOG.debug( - "response committed, " - + "but attempt to include results " - + "of actionForward path"); + LOG.debug("response committed, " + + "but attempt to include results " + + "of actionForward path"); - RequestDispatcher requestDispatcher = request - .getRequestDispatcher(includePath); + RequestDispatcher requestDispatcher = + request.getRequestDispatcher(includePath); try { requestDispatcher.include(request, response); return; - } catch (IOException e) { - LOG.error( - "IOException when trying to include " - + "the error page path " - + includePath, - e); - } catch (ServletException e) { - LOG.error( - "ServletException when trying to include " - + "the error page path " - + includePath, - e); } - } else { - LOG.warn( - "Suspicious includePath doesn't seem likely to work, " - + "so skipping it: " - + includePath - + "; expected path to start with '/'"); + catch (IOException e) { + LOG.error("IOException when trying to include " + + "the error page path " + includePath, e); + } + catch (ServletException e) { + LOG.error("ServletException when trying to include " + + "the error page path " + includePath, e); + } + } + else { + LOG.warn("Suspicious includePath doesn't seem likely to work, " + + "so skipping it: " + includePath + + "; expected path to start with '/'"); } } - LOG.debug( - "Include not available or failed; " - + "try writing to the response directly."); + LOG.debug("Include not available or failed; " + + "try writing to the response directly."); try { response.getWriter().println("Unexpected error: " + ex); response.getWriter().println("<!-- "); ex.printStackTrace(response.getWriter()); response.getWriter().println("-->"); - } catch (IOException e) { + } + catch (IOException e) { LOG.error("Error giving minimal information about exception", e); LOG.error("Original exception: ", ex); } } /** - * <p>Return a path to which an include should be attempted in the case when - * the response was committed before the <code>ExceptionHandler</code> was - * invoked. </p> <p>If the <code>ExceptionConfig</code> has the property - * <code>INCLUDE_PATH</code> defined, then the value of that property will - * be returned. Otherwise, the ActionForward path is returned. </p> + * <p>Return a path to which an include should be attempted in the case + * when the response was committed before the <code>ExceptionHandler</code> + * was invoked. </p> <p>If the <code>ExceptionConfig</code> has the + * property <code>INCLUDE_PATH</code> defined, then the value of that + * property will be returned. Otherwise, the ActionForward path is + * returned. </p> * * @param config Configuration element * @param actionForward Forward to use on error @@ -255,7 +253,7 @@ * @since Struts 1.3 */ protected String determineIncludePath(ExceptionConfig config, - ActionForward actionForward) { + ActionForward actionForward) { String includePath = config.getProperty("INCLUDE_PATH"); if (includePath == null) { @@ -279,29 +277,29 @@ * <p>Default implementation for handling an <code>ActionMessage</code> * generated from an <code>Exception</code> during <code>Action</code> * delegation. The default implementation is to set an attribute of the - * request or session, as defined by the scope provided (the scope from the - * exception mapping). An <code>ActionMessages</code> instance is created, - * the error is added to the collection and the collection is set under the - * <code>Globals.ERROR_KEY</code>.</p> + * request or session, as defined by the scope provided (the scope from + * the exception mapping). An <code>ActionMessages</code> instance is + * created, the error is added to the collection and the collection is set + * under the <code>Globals.ERROR_KEY</code>.</p> * * @param request The request we are handling * @param property The property name to use for this error * @param error The error generated from the exception mapping - * @param forward The forward generated from the input path (from the form - * or exception mapping) + * @param forward The forward generated from the input path (from the + * form or exception mapping) * @param scope The scope of the exception mapping. * @since Struts 1.2 */ protected void storeException(HttpServletRequest request, String property, - ActionMessage error, ActionForward forward, - String scope) { + ActionMessage error, ActionForward forward, String scope) { ActionMessages errors = new ActionMessages(); errors.add(property, error); if ("request".equals(scope)) { request.setAttribute(Globals.ERROR_KEY, errors); - } else { + } + else { request.getSession().setAttribute(Globals.ERROR_KEY, errors); } } Modified: struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java?rev=375627&r1=375626&r2=375627&view=diff ============================================================================== --- struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java (original) +++ struts/action/trunk/src/java/org/apache/struts/action/PlugIn.java Tue Feb 7 07:25:16 2006 @@ -22,21 +22,23 @@ import javax.servlet.ServletException; /** - * <p>A <strong>PlugIn</strong> is a configuration wrapper for a module-specific - * resource or service that needs to be notified about application startup and - * application shutdown events (corresponding to when the container calls - * <code>init</code> and <code>destroy</code> on the corresponding [EMAIL PROTECTED] - * ActionServlet} instance). <code>PlugIn</code> objects can be configured in - * the <code>struts-config.xml</code> file, without the need to subclass [EMAIL PROTECTED] - * ActionServlet} simply to perform application lifecycle activities.</p> + * <p>A <strong>PlugIn</strong> is a configuration wrapper for a + * module-specific resource or service that needs to be notified about + * application startup and application shutdown events (corresponding to when + * the container calls <code>init</code> and <code>destroy</code> on the + * corresponding [EMAIL PROTECTED] ActionServlet} instance). <code>PlugIn</code> objects + * can be configured in the <code>struts-config.xml</code> file, without the + * need to subclass [EMAIL PROTECTED] ActionServlet} simply to perform application + * lifecycle activities.</p> * - * <p>Implementations of this interface must supply a zero-argument constructor - * for use by [EMAIL PROTECTED] ActionServlet}. Configuration can be accomplished by - * providing standard JavaBeans property setter methods, which will all have - * been called before the <code>init()</code> method is invoked.</p> + * <p>Implementations of this interface must supply a zero-argument + * constructor for use by [EMAIL PROTECTED] ActionServlet}. Configuration can be + * accomplished by providing standard JavaBeans property setter methods, which + * will all have been called before the <code>init()</code> method is + * invoked.</p> * - * <p>This interface can be applied to any class, including an Action subclass. - * </p> + * <p>This interface can be applied to any class, including an Action + * subclass. </p> * * @version $Rev$ $Date: 2005-05-14 01:09:32 -0400 (Sat, 14 May 2005) * $ @@ -52,13 +54,13 @@ * <p>Receive notification that the specified module is being started * up.</p> * - * @param servlet ActionServlet that is managing all the modules in this web - * application + * @param servlet ActionServlet that is managing all the modules in this + * web application * @param config ModuleConfig for the module with which this plug-in is * associated * @throws ServletException if this <code>PlugIn</code> cannot be * successfully initialized */ void init(ActionServlet servlet, ModuleConfig config) - throws ServletException; + throws ServletException; } Modified: struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java URL: http://svn.apache.org/viewcvs/struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java?rev=375627&r1=375626&r2=375627&view=diff ============================================================================== --- struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java (original) +++ struts/action/trunk/src/java/org/apache/struts/action/RequestProcessor.java Tue Feb 7 07:25:16 2006 @@ -34,7 +34,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; + import java.io.IOException; + import java.util.HashMap; import java.util.Iterator; import java.util.Locale; @@ -43,8 +45,8 @@ * <p><strong>RequestProcessor</strong> contains the processing logic that the * [EMAIL PROTECTED] ActionServlet} performs as it receives each servlet request from the * container. You can customize the request processing behavior by subclassing - * this class and overriding the method(s) whose behavior you are interested in - * changing.</p> + * this class and overriding the method(s) whose behavior you are interested + * in changing.</p> * * @version $Rev$ $Date: 2005-11-09 00:11:45 -0500 (Wed, 09 Nov 2005) * $ @@ -58,7 +60,7 @@ * processing during a <code>RequestDispatcher.include</code> call.</p> */ public static final String INCLUDE_PATH_INFO = - "javax.servlet.include.path_info"; + "javax.servlet.include.path_info"; /** * <p>The request attribute under which the servlet path information is @@ -66,7 +68,7 @@ * call.</p> */ public static final String INCLUDE_SERVLET_PATH = - "javax.servlet.include.servlet_path"; + "javax.servlet.include.servlet_path"; /** * <p>Commons Logging instance.</p> @@ -122,7 +124,7 @@ * @throws ServletException If an error occor during initialization */ public void init(ActionServlet servlet, ModuleConfig moduleConfig) - throws ServletException { + throws ServletException { synchronized (actions) { actions.clear(); } @@ -141,9 +143,8 @@ * @throws IOException if an input/output error occurs * @throws ServletException if a processing exception occurs */ - public void process(HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { + public void process(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { // Wrap multipart requests with a special wrapper request = processMultipart(request); @@ -156,7 +157,7 @@ if (log.isDebugEnabled()) { log.debug("Processing a '" + request.getMethod() + "' for path '" - + path + "'"); + + path + "'"); } // Select a Locale for the current user if requested @@ -212,8 +213,7 @@ // Call the Action instance itself ActionForward forward = - processActionPerform(request, response, action, - form, mapping); + processActionPerform(request, response, action, form, mapping); // Process the returned ActionForward instance processForwardConfig(request, response, forward); @@ -228,14 +228,13 @@ * @param request The servlet request we are processing * @param response The servlet response we are creating * @param mapping The mapping we are using - * @return An <code>Action</code> instance that will be used to process the - * current request. + * @return An <code>Action</code> instance that will be used to process + * the current request. * @throws IOException if an input/output error occurs */ protected Action processActionCreate(HttpServletRequest request, - HttpServletResponse response, - ActionMapping mapping) - throws IOException { + HttpServletResponse response, ActionMapping mapping) + throws IOException { // Acquire the Action instance we will be using (if there is one) String className = mapping.getType(); @@ -266,18 +265,17 @@ } try { - instance = - (Action) RequestUtils.applicationInstance(className); + instance = (Action) RequestUtils.applicationInstance(className); // Maybe we should propagate this exception // instead of returning null. - } catch (Exception e) { + } + catch (Exception e) { log.error(getInternal().getMessage("actionCreate", mapping.getPath()), e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - getInternal().getMessage("actionCreate", - mapping.getPath())); + getInternal().getMessage("actionCreate", mapping.getPath())); return (null); } @@ -304,11 +302,11 @@ * @return The <code>ActionForm</code> associated with this mapping. */ protected ActionForm processActionForm(HttpServletRequest request, - HttpServletResponse response, - ActionMapping mapping) { + HttpServletResponse response, ActionMapping mapping) { // Create (if necessary) a form bean to use - ActionForm instance = RequestUtils.createActionForm(request, mapping, - moduleConfig, servlet); + ActionForm instance = + RequestUtils.createActionForm(request, mapping, moduleConfig, + servlet); if (instance == null) { return (null); @@ -317,13 +315,14 @@ // Store the new instance in the appropriate scope if (log.isDebugEnabled()) { log.debug(" Storing ActionForm bean instance in scope '" - + mapping.getScope() + "' under attribute key '" - + mapping.getAttribute() + "'"); + + mapping.getScope() + "' under attribute key '" + + mapping.getAttribute() + "'"); } if ("request".equals(mapping.getScope())) { request.setAttribute(mapping.getAttribute(), instance); - } else { + } + else { HttpSession session = request.getSession(); session.setAttribute(mapping.getAttribute(), instance); @@ -334,8 +333,8 @@ /** * <p>Forward or redirect to the specified destination, by the specified - * mechanism. This method uses a <code>ForwardConfig</code> object instead - * an <code>ActionForward</code>.</p> + * mechanism. This method uses a <code>ForwardConfig</code> object + * instead an <code>ActionForward</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating @@ -344,9 +343,8 @@ * @throws ServletException if a servlet exception occurs */ protected void processForwardConfig(HttpServletRequest request, - HttpServletResponse response, - ForwardConfig forward) - throws IOException, ServletException { + HttpServletResponse response, ForwardConfig forward) + throws IOException, ServletException { if (forward == null) { return; } @@ -363,7 +361,8 @@ if (forwardPath.startsWith("/")) { // get module relative uri uri = RequestUtils.forwardURL(request, forward, null); - } else { + } + else { uri = forwardPath; } @@ -374,7 +373,8 @@ } response.sendRedirect(response.encodeRedirectURL(uri)); - } else { + } + else { doForward(uri, request, response); } } @@ -384,29 +384,29 @@ // ServletException? /** - * <P>Ask the specified <code>Action</code> instance to handle this request. - * Return the <code>ActionForward</code> instance (if any) returned by the - * called <code>Action</code> for further processing. </P> + * <P>Ask the specified <code>Action</code> instance to handle this + * request. Return the <code>ActionForward</code> instance (if any) + * returned by the called <code>Action</code> for further processing. + * </P> * * @param request The servlet request we are processing * @param response The servlet response we are creating * @param action The Action instance to be used * @param form The ActionForm instance to pass to this Action * @param mapping The ActionMapping instance to pass to this Action - * @return The <code>ActionForward</code> instance (if any) returned by the - * called <code>Action</code>. + * @return The <code>ActionForward</code> instance (if any) returned by + * the called <code>Action</code>. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ protected ActionForward processActionPerform(HttpServletRequest request, - HttpServletResponse response, - Action action, - ActionForm form, - ActionMapping mapping) - throws IOException, ServletException { + HttpServletResponse response, Action action, ActionForm form, + ActionMapping mapping) + throws IOException, ServletException { try { return (action.execute(mapping, form, request, response)); - } catch (Exception e) { + } + catch (Exception e) { return (processException(request, response, e, form, mapping)); } } @@ -423,7 +423,7 @@ * @since Struts 1.2 */ protected void processCachedMessages(HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) { HttpSession session = request.getSession(false); if (session == null) { @@ -432,7 +432,7 @@ // Remove messages as needed ActionMessages messages = - (ActionMessages) session.getAttribute(Globals.MESSAGE_KEY); + (ActionMessages) session.getAttribute(Globals.MESSAGE_KEY); if (messages != null) { if (messages.isAccessed()) { @@ -452,17 +452,17 @@ /** * <p>Set the default content type (with optional character encoding) for - * all responses if requested. <strong>NOTE</strong> - This header will be - * overridden automatically if a <code>RequestDispatcher.forward</code> call - * is ultimately invoked.</p> + * all responses if requested. <strong>NOTE</strong> - This header will + * be overridden automatically if a <code>RequestDispatcher.forward</code> + * call is ultimately invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processContent(HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) { String contentType = - moduleConfig.getControllerConfig().getContentType(); + moduleConfig.getControllerConfig().getContentType(); if (contentType != null) { response.setContentType(contentType); @@ -479,17 +479,15 @@ * @param exception The exception being handled * @param form The ActionForm we are processing * @param mapping The ActionMapping we are using - * @return The <code>ActionForward</code> instance (if any) returned by the - * called <code>ExceptionHandler</code>. + * @return The <code>ActionForward</code> instance (if any) returned by + * the called <code>ExceptionHandler</code>. * @throws IOException if an input/output error occurs * @throws ServletException if a servlet exception occurs */ protected ActionForward processException(HttpServletRequest request, - HttpServletResponse response, - Exception exception, - ActionForm form, - ActionMapping mapping) - throws IOException, ServletException { + HttpServletResponse response, Exception exception, ActionForm form, + ActionMapping mapping) + throws IOException, ServletException { // Is there a defined handler for this exception? ExceptionConfig config = mapping.findException(exception.getClass()); @@ -499,21 +497,25 @@ if (exception instanceof IOException) { throw (IOException) exception; - } else if (exception instanceof ServletException) { + } + else if (exception instanceof ServletException) { throw (ServletException) exception; - } else { + } + else { throw new ServletException(exception); } } // Use the configured exception handling try { - ExceptionHandler handler = (ExceptionHandler) RequestUtils - .applicationInstance(config.getHandler()); + ExceptionHandler handler = + (ExceptionHandler) RequestUtils.applicationInstance(config + .getHandler()); return (handler.execute(exception, config, mapping, form, request, - response)); - } catch (Exception e) { + response)); + } + catch (Exception e) { throw new ServletException(e); } } @@ -532,9 +534,8 @@ * @throws ServletException if a servlet exception occurs */ protected boolean processForward(HttpServletRequest request, - HttpServletResponse response, - ActionMapping mapping) - throws IOException, ServletException { + HttpServletResponse response, ActionMapping mapping) + throws IOException, ServletException { // Are we going to processing this request? String forward = mapping.getForward(); @@ -561,9 +562,8 @@ * @throws ServletException if thrown by invoked methods */ protected boolean processInclude(HttpServletRequest request, - HttpServletResponse response, - ActionMapping mapping) - throws IOException, ServletException { + HttpServletResponse response, ActionMapping mapping) + throws IOException, ServletException { // Are we going to processing this request? String include = mapping.getInclude(); @@ -579,13 +579,14 @@ /** * <p>Automatically select a <code>Locale</code> for the current user, if * requested. <strong>NOTE</strong> - configuring Locale selection will - * trigger the creation of a new <code>HttpSession</code> if necessary.</p> + * trigger the creation of a new <code>HttpSession</code> if + * necessary.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processLocale(HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) { // Are we configured to select the Locale automatically? if (!moduleConfig.getControllerConfig().getLocale()) { return; @@ -618,16 +619,16 @@ * @param request The servlet request we are processing * @param response The servlet response we are creating * @param path The portion of the request URI for selecting a mapping - * @return The mapping used to process the selection path for this request. + * @return The mapping used to process the selection path for this + * request. * @throws IOException if an input/output error occurs */ protected ActionMapping processMapping(HttpServletRequest request, - HttpServletResponse response, - String path) - throws IOException { + HttpServletResponse response, String path) + throws IOException { // Is there a mapping for this path? ActionMapping mapping = - (ActionMapping) moduleConfig.findActionConfig(path); + (ActionMapping) moduleConfig.findActionConfig(path); // If a mapping is found, put it in the request and return it if (mapping != null) { @@ -665,8 +666,7 @@ * @return A wrapped request, if the request is multipart; otherwise the * original request. */ - protected HttpServletRequest processMultipart( - HttpServletRequest request) { + protected HttpServletRequest processMultipart(HttpServletRequest request) { if (!"POST".equalsIgnoreCase(request.getMethod())) { return (request); } @@ -674,36 +674,37 @@ String contentType = request.getContentType(); if ((contentType != null) - && contentType.startsWith("multipart/form-data")) { + && contentType.startsWith("multipart/form-data")) { return (new MultipartRequestWrapper(request)); - } else { + } + else { return (request); } } /** * <p>Set the no-cache headers for all responses, if requested. - * <strong>NOTE</strong> - This header will be overridden automatically if a - * <code>RequestDispatcher.forward</code> call is ultimately invoked.</p> + * <strong>NOTE</strong> - This header will be overridden automatically if + * a <code>RequestDispatcher.forward</code> call is ultimately + * invoked.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating */ protected void processNoCache(HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) { if (moduleConfig.getControllerConfig().getNocache()) { response.setHeader("Pragma", "No-cache"); - response.setHeader("Cache-Control", - "no-cache,no-store,max-age=0"); + response.setHeader("Cache-Control", "no-cache,no-store,max-age=0"); response.setDateHeader("Expires", 1); } } /** - * <p>Identify and return the path component (from the request URI) that we - * will use to select an <code>ActionMapping</code> with which to dispatch. - * If no such path can be identified, create an error response and return - * <code>null</code>.</p> + * <p>Identify and return the path component (from the request URI) that + * we will use to select an <code>ActionMapping</code> with which to + * dispatch. If no such path can be identified, create an error response + * and return <code>null</code>.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating @@ -711,8 +712,8 @@ * @throws IOException if an input/output error occurs */ protected String processPath(HttpServletRequest request, - HttpServletResponse response) - throws IOException { + HttpServletResponse response) + throws IOException { String path; // For prefix matching, match on the path info (if any) @@ -770,9 +771,8 @@ * @throws ServletException if thrown by RequestUtils.populate() */ protected void processPopulate(HttpServletRequest request, - HttpServletResponse response, - ActionForm form, ActionMapping mapping) - throws ServletException { + HttpServletResponse response, ActionForm form, ActionMapping mapping) + throws ServletException { if (form == null) { return; } @@ -787,24 +787,24 @@ if (mapping.getMultipartClass() != null) { request.setAttribute(Globals.MULTIPART_KEY, - mapping.getMultipartClass()); + mapping.getMultipartClass()); } RequestUtils.populate(form, mapping.getPrefix(), mapping.getSuffix(), - request); + request); // Set the cancellation request attribute if appropriate if ((request.getParameter(Globals.CANCEL_PROPERTY) != null) - || (request.getParameter(Globals.CANCEL_PROPERTY_X) != null)) { + || (request.getParameter(Globals.CANCEL_PROPERTY_X) != null)) { request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE); } } /** - * <p>General-purpose preprocessing hook that can be overridden as required - * by subclasses. Return <code>true</code> if you want standard processing - * to continue, or <code>false</code> if the response has already been - * completed. The default implementation does nothing.</p> + * <p>General-purpose preprocessing hook that can be overridden as + * required by subclasses. Return <code>true</code> if you want standard + * processing to continue, or <code>false</code> if the response has + * already been completed. The default implementation does nothing.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating @@ -812,14 +812,14 @@ * <code>false</code> if a response has been created. */ protected boolean processPreprocess(HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) { return (true); } /** * <p>If this action is protected by security roles, make sure that the - * current user possesses at least one of them. Return <code>true</code> to - * continue normal processing, or <code>false</code> if an appropriate + * current user possesses at least one of them. Return <code>true</code> + * to continue normal processing, or <code>false</code> if an appropriate * response has been created and processing should terminate.</p> * * @param request The servlet request we are processing @@ -831,9 +831,8 @@ * @throws ServletException if a servlet exception occurs */ protected boolean processRoles(HttpServletRequest request, - HttpServletResponse response, - ActionMapping mapping) - throws IOException, ServletException { + HttpServletResponse response, ActionMapping mapping) + throws IOException, ServletException { // Is this action protected by role requirements? String[] roles = mapping.getRoleNames(); @@ -846,8 +845,7 @@ if (request.isUserInRole(roles[i])) { if (log.isDebugEnabled()) { log.debug(" User '" + request.getRemoteUser() - + "' has role '" + roles[i] - + "', granting access"); + + "' has role '" + roles[i] + "', granting access"); } return (true); @@ -857,11 +855,11 @@ // The current user is not authorized for this action if (log.isDebugEnabled()) { log.debug(" User '" + request.getRemoteUser() - + "' does not have any required role, denying access"); + + "' does not have any required role, denying access"); } response.sendError(HttpServletResponse.SC_FORBIDDEN, - getInternal().getMessage("notAuthorized", mapping.getPath())); + getInternal().getMessage("notAuthorized", mapping.getPath())); return (false); } @@ -871,8 +869,9 @@ * ActionMapping} has not disabled validation, call the * <code>validate</code> method of the specified [EMAIL PROTECTED] ActionForm}, and * forward to the input path if there were any errors. Return - * <code>true</code> if we should continue processing, or <code>false</code> - * if we have already forwarded control back to the input form.</p> + * <code>true</code> if we should continue processing, or + * <code>false</code> if we have already forwarded control back to the + * input form.</p> * * @param request The servlet request we are processing * @param response The servlet response we are creating @@ -884,9 +883,8 @@ * @throws ServletException if a servlet exception occurs */ protected boolean processValidate(HttpServletRequest request, - HttpServletResponse response, - ActionForm form, ActionMapping mapping) - throws IOException, ServletException { + HttpServletResponse response, ActionForm form, ActionMapping mapping) + throws IOException, ServletException { if (form == null) { return (true); } @@ -938,7 +936,7 @@ } response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - getInternal().getMessage("noInput", mapping.getPath())); + getInternal().getMessage("noInput", mapping.getPath())); return (false); } @@ -954,7 +952,8 @@ ForwardConfig forward = mapping.findForward(input); processForwardConfig(request, response, forward); - } else { + } + else { internalModuleRelativeForward(input, request, response); } @@ -965,8 +964,8 @@ * <p>Do a module relative forward to specified URI using request * dispatcher. URI is relative to the current module. The real URI is * compute by prefixing the module name.</p> <p>This method is used - * internally and is not part of the public API. It is advised to not use it - * in subclasses. </p> + * internally and is not part of the public API. It is advised to not use + * it in subclasses. </p> * * @param uri Module-relative URI to forward to * @param request Current page request @@ -976,9 +975,8 @@ * @since Struts 1.1 */ protected void internalModuleRelativeForward(String uri, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { + HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { // Construct a request dispatcher for the specified path uri = moduleConfig.getPrefix() + uri; @@ -995,8 +993,8 @@ * <p>Do a module relative include to specified URI using request * dispatcher. URI is relative to the current module. The real URI is * compute by prefixing the module name.</p> <p>This method is used - * internally and is not part of the public API. It is advised to not use it - * in subclasses.</p> + * internally and is not part of the public API. It is advised to not use + * it in subclasses.</p> * * @param uri Module-relative URI to include * @param request Current page request @@ -1006,9 +1004,8 @@ * @since Struts 1.1 */ protected void internalModuleRelativeInclude(String uri, - HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { + HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { // Construct a request dispatcher for the specified path uri = moduleConfig.getPrefix() + uri; @@ -1023,7 +1020,8 @@ /** * <p>Do a forward to specified URI using a <code>RequestDispatcher</code>. - * This method is used by all internal method needing to do a forward.</p> + * This method is used by all internal method needing to do a + * forward.</p> * * @param uri Context-relative URI to forward to * @param request Current page request @@ -1033,13 +1031,13 @@ * @since Struts 1.1 */ protected void doForward(String uri, HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { + HttpServletResponse response) + throws IOException, ServletException { RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - getInternal().getMessage("requestDispatcher", uri)); + getInternal().getMessage("requestDispatcher", uri)); return; } @@ -1049,7 +1047,8 @@ /** * <p>Do an include of specified URI using a <code>RequestDispatcher</code>. - * This method is used by all internal method needing to do an include.</p> + * This method is used by all internal method needing to do an + * include.</p> * * @param uri Context-relative URI to include * @param request Current page request @@ -1059,13 +1058,13 @@ * @since Struts 1.1 */ protected void doInclude(String uri, HttpServletRequest request, - HttpServletResponse response) - throws IOException, ServletException { + HttpServletResponse response) + throws IOException, ServletException { RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd == null) { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, - getInternal().getMessage("requestDispatcher", uri)); + getInternal().getMessage("requestDispatcher", uri)); return; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
