Package org.apache.struts.upload

Examples of org.apache.struts.upload.MultipartRequestHandler


        if (bean instanceof ActionForm) {
            ((ActionForm) bean).setMultipartRequestHandler(null);
        }

        MultipartRequestHandler multipartHandler = null;
        if ((contentType != null)
            && (contentType.startsWith("multipart/form-data"))
            && (method.equalsIgnoreCase("POST"))) {
            // Get the ActionServletWrapper from the form bean
            ActionServletWrapper servlet;

            if (bean instanceof ActionForm) {
                servlet = ((ActionForm) bean).getServletWrapper();
            } else {
                throw new ServletException("bean that's supposed to be "
                    + "populated from a multipart request is not of type "
                    + "\"org.apache.struts.action.ActionForm\", but type "
                    + "\"" + bean.getClass().getName() + "\"");
            }

            // Obtain a MultipartRequestHandler
            multipartHandler = getMultipartHandler(request);

            if (multipartHandler != null) {
                isMultipart = true;

                // Set servlet and mapping info
                servlet.setServletFor(multipartHandler);
                multipartHandler.setMapping((ActionMapping) request
                    .getAttribute(Globals.MAPPING_KEY));

                // Initialize multipart request class handler
                multipartHandler.handleRequest(request);

                //stop here if the maximum length has been exceeded
                Boolean maxLengthExceeded =
                    (Boolean) request.getAttribute(MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
View Full Code Here


     *                          locate the multipart handler.
     */
    private static MultipartRequestHandler getMultipartHandler(
        HttpServletRequest request)
        throws ServletException {
        MultipartRequestHandler multipartHandler = null;
        String multipartClass =
            (String) request.getAttribute(Globals.MULTIPART_KEY);

        request.removeAttribute(Globals.MULTIPART_KEY);

View Full Code Here

    {
        public RehydratedMultipartRequestWrapper( HttpServletRequest req )
        {
            super( req );

            MultipartRequestHandler handler = MultipartRequestUtils.getCachedMultipartHandler( req );

            if ( handler != null )
            {
                ScopedRequest scopedRequest = ScopedServletUtils.unwrapRequest( req );
                Map textElements = handler.getTextElements();
                parameters = scopedRequest != null ? scopedRequest.filterParameterMap( textElements ) : textElements;
            }
        }
View Full Code Here

                        + bean.getClass().getName()
                        + "\"");
            }

            // Obtain a MultipartRequestHandler
            MultipartRequestHandler multipartHandler = getMultipartHandler(request);

            // Set the multipart request handler for our ActionForm.
            // If the bean isn't an ActionForm, an exception would have been
            // thrown earlier, so it's safe to assume that our bean is
            // in fact an ActionForm.
            ((ActionForm) bean).setMultipartRequestHandler(multipartHandler);

            if (multipartHandler != null) {
                isMultipart = true;
                // Set servlet and mapping info
                servlet.setServletFor(multipartHandler);
                multipartHandler.setMapping(
                        (ActionMapping) request.getAttribute(Globals.MAPPING_KEY));
                // Initialize multipart request class handler
                multipartHandler.handleRequest(request);
                //stop here if the maximum length has been exceeded
                Boolean maxLengthExceeded =
                        (Boolean) request.getAttribute(
                                MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED);
                if ((maxLengthExceeded != null) && (maxLengthExceeded.booleanValue())) {
View Full Code Here

     *                             to locate the multipart handler.
     */
    private static MultipartRequestHandler getMultipartHandler(HttpServletRequest request)
            throws ServletException {

        MultipartRequestHandler multipartHandler = null;
        String multipartClass = (String) request.getAttribute(Globals.MULTIPART_KEY);
        request.removeAttribute(Globals.MULTIPART_KEY);

        // Try to initialize the mapping specific request handler
        if (multipartClass != null) {
View Full Code Here

        if ((contentType != null) &&
            (contentType.startsWith("multipart/form-data")) &&
            (method.equalsIgnoreCase("POST"))) {
            isMultipart = true;
            //initialize a MultipartRequestHandler
            MultipartRequestHandler multipart = null;

            //get an instance of ActionServlet
            ActionServlet servlet;

            if (bean instanceof ActionForm) {
                servlet = ((ActionForm) bean).getServlet();
            } else {
                throw new ServletException("bean that's supposed to be " +
                                           "populated from a multipart request is not of type " +
                                           "\"org.apache.struts.action.ActionForm\", but type " +
                                           "\"" + bean.getClass().getName() + "\"");
            }
            String multipartClass = (String)
                request.getAttribute(Action.MULTIPART_KEY);
            request.removeAttribute(Action.MULTIPART_KEY);

            if (multipartClass != null) {
                //try to initialize the mapping specific request handler
                try {
                    multipart = (MultipartRequestHandler) Class.forName(multipartClass).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    servlet.log("MultipartRequestHandler class \"" +
                    multipartClass + "\" in mapping class not found, " +
                    "defaulting to global multipart class");
                }
                catch (InstantiationException ie) {
                    servlet.log("InstantiaionException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    servlet.log("IllegalAccessException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    iae.getMessage());
                }
            }

            if (multipart == null) {
                //try to initialize the global multipart class
                try {
                    multipart = (MultipartRequestHandler) Class.forName(servlet.getMultipartClass()).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    throw new ServletException("Cannot find multipart class \"" +
                    servlet.getMultipartClass() + "\"" +
                    ", exception: " + cnfe.getMessage());
                }
                catch (InstantiationException ie) {
                    throw new ServletException("InstantiaionException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    throw new ServletException("IllegalAccessException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + iae.getMessage());
                }
            }


            //set the multipart request handler for our ActionForm
            //if the bean isn't an ActionForm, an exception would have been
            //thrown earlier, so it's safe to assume that our bean is
            //in fact an ActionForm
            ((ActionForm) bean).setMultipartRequestHandler(multipart);

            //set servlet and mapping info
            multipart.setServlet(servlet);
            multipart.setMapping((ActionMapping)
                                 request.getAttribute(Action.MAPPING_KEY));
            request.removeAttribute(Action.MAPPING_KEY);

            //initialize request class handler
            multipart.handleRequest(request);

            //retrive form values and put into properties
            multipartElements = multipart.getAllElements();
            names = multipartElements.keys();
        }

        if (!isMultipart) {
            names = request.getParameterNames();
View Full Code Here

        if ((contentType != null) &&
            (contentType.startsWith("multipart/form-data")) &&
            (method.equalsIgnoreCase("POST"))) {
            isMultipart = true;
            //initialize a MultipartRequestHandler
            MultipartRequestHandler multipart = null;

            //get an instance of ActionServlet
            ActionServlet servlet;

            if (bean instanceof ActionForm) {
                servlet = ((ActionForm) bean).getServlet();
            } else {
                throw new ServletException("bean that's supposed to be " +
                                           "populated from a multipart request is not of type " +
                                           "\"org.apache.struts.action.ActionForm\", but type " +
                                           "\"" + bean.getClass().getName() + "\"");
            }
            String multipartClass = (String)
                request.getAttribute(Action.MULTIPART_KEY);
            request.removeAttribute(Action.MULTIPART_KEY);

            if (multipartClass != null) {
                //try to initialize the mapping specific request handler
                try {
                    multipart = (MultipartRequestHandler) Class.forName(multipartClass).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    servlet.log("MultipartRequestHandler class \"" +
                    multipartClass + "\" in mapping class not found, " +
                    "defaulting to global multipart class");
                }
                catch (InstantiationException ie) {
                    servlet.log("InstantiaionException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    servlet.log("IllegalAccessException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    iae.getMessage());
                }
            }

            if (multipart == null) {
                //try to initialize the global multipart class
                try {
                    multipart = (MultipartRequestHandler) Class.forName(servlet.getMultipartClass()).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    throw new ServletException("Cannot find multipart class \"" +
                    servlet.getMultipartClass() + "\"" +
                    ", exception: " + cnfe.getMessage());
                }
                catch (InstantiationException ie) {
                    throw new ServletException("InstantiaionException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    throw new ServletException("IllegalAccessException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + iae.getMessage());
                }
            }


            //set the multipart request handler for our ActionForm
            //if the bean isn't an ActionForm, an exception would have been
            //thrown earlier, so it's safe to assume that our bean is
            //in fact an ActionForm
            ((ActionForm) bean).setMultipartRequestHandler(multipart);

            //set servlet and mapping info
            multipart.setServlet(servlet);
            multipart.setMapping((ActionMapping)
                                 request.getAttribute(Action.MAPPING_KEY));
            request.removeAttribute(Action.MAPPING_KEY);

            //initialize request class handler
            multipart.handleRequest(request);

            //retrive form values and put into properties
            multipartElements = multipart.getAllElements();
            names = multipartElements.keys();
        }

        if (!isMultipart) {
            names = request.getParameterNames();
View Full Code Here

        if ((contentType != null) &&
            (contentType.startsWith("multipart/form-data")) &&
            (method.equalsIgnoreCase("POST"))) {
            isMultipart = true;
            //initialize a MultipartRequestHandler
            MultipartRequestHandler multipart = null;

            //get an instance of ActionServletWrapper
            ActionServletWrapper servlet;

            if (bean instanceof ActionForm) {
                servlet = ((ActionForm) bean).getServletWrapper();
            } else {
                throw new ServletException("bean that's supposed to be " +
                                           "populated from a multipart request is not of type " +
                                           "\"org.apache.struts.action.ActionForm\", but type " +
                                           "\"" + bean.getClass().getName() + "\"");
            }
            String multipartClass = (String)
                request.getAttribute(Action.MULTIPART_KEY);
            request.removeAttribute(Action.MULTIPART_KEY);

            if (multipartClass != null) {
                //try to initialize the mapping specific request handler
                try {
                    multipart = (MultipartRequestHandler) Class.forName(multipartClass).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    servlet.log("MultipartRequestHandler class \"" +
                    multipartClass + "\" in mapping class not found, " +
                    "defaulting to global multipart class");
                }
                catch (InstantiationException ie) {
                    servlet.log("InstantiaionException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    servlet.log("IllegalAccessException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    iae.getMessage());
                }
            }

            if (multipart == null) {
                //try to initialize the global multipart class
                try {
                    multipart = (MultipartRequestHandler) Class.forName(servlet.getMultipartClass()).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    throw new ServletException("Cannot find multipart class \"" +
                    servlet.getMultipartClass() + "\"" +
                    ", exception: " + cnfe.getMessage());
                }
                catch (InstantiationException ie) {
                    throw new ServletException("InstantiaionException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    throw new ServletException("IllegalAccessException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + iae.getMessage());
                }
            }


            //set the multipart request handler for our ActionForm
            //if the bean isn't an ActionForm, an exception would have been
            //thrown earlier, so it's safe to assume that our bean is
            //in fact an ActionForm
            ((ActionForm) bean).setMultipartRequestHandler(multipart);

            //set servlet and mapping info
            servlet.setServletFor(multipart);
            multipart.setMapping((ActionMapping)
                                 request.getAttribute(Action.MAPPING_KEY));
            request.removeAttribute(Action.MAPPING_KEY);

            //initialize request class handler
            multipart.handleRequest(request);

            //retrive form values and put into properties
            multipartElements = multipart.getAllElements();
            names = multipartElements.keys();
        }

        if (!isMultipart) {
            names = request.getParameterNames();
View Full Code Here

        String contentType = request.getContentType();
        if ((contentType != null) &&
            (contentType.startsWith("multipart/form-data"))) {
            isMultipart = true;
            //initialize a MultipartRequestHandler
            MultipartRequestHandler multipart = null;

            //get an instance of ActionServlet
            ActionServlet servlet;

            if (bean instanceof ActionForm) {
                servlet = ((ActionForm) bean).getServlet();
            } else {
                throw new ServletException("bean that's supposed to be " +
                                           "populated from a multipart request is not of type " +
                                           "\"org.apache.struts.action.ActionForm\", but type " +
                                           "\"" + bean.getClass().getName() + "\"");
            }
            String multipartClass = (String)
                request.getAttribute(Action.MULTIPART_KEY);
            request.removeAttribute(Action.MULTIPART_KEY);

            if (multipartClass != null) {
                //try to initialize the mapping specific request handler
                try {
                    multipart = (MultipartRequestHandler) Class.forName(multipartClass).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    servlet.log("MultipartRequestHandler class \"" +
                    multipartClass + "\" in mapping class not found, " +
                    "defaulting to global multipart class");
                }
                catch (InstantiationException ie) {
                    servlet.log("InstantiaionException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    servlet.log("IllegalAccessException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    iae.getMessage());
                }
            }

            if (multipart == null) {
                //try to initialize the global multipart class
                try {
                    multipart = (MultipartRequestHandler) Class.forName(servlet.getMultipartClass()).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    throw new ServletException("Cannot find multipart class \"" +
                    servlet.getMultipartClass() + "\"" +
                    ", exception: " + cnfe.getMessage());
                }
                catch (InstantiationException ie) {
                    throw new ServletException("InstantiaionException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    throw new ServletException("IllegalAccessException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + iae.getMessage());
                }
            }


            //set the multipart request handler for our ActionForm
            //if the bean isn't an ActionForm, an exception would have been
            //thrown earlier, so it's safe to assume that our bean is
            //in fact an ActionForm
            ((ActionForm) bean).setMultipartRequestHandler(multipart);

            //set servlet and mapping info
            multipart.setServlet(servlet);
            multipart.setMapping((ActionMapping)
                                 request.getAttribute(Action.MAPPING_KEY));
            request.removeAttribute(Action.MAPPING_KEY);

            //initialize request class handler
            multipart.handleRequest(request);

            //retrive form values and put into properties
            multipartElements = multipart.getAllElements();
            names = multipartElements.keys();
        }

        if (!isMultipart) {
            names = request.getParameterNames();
View Full Code Here

        String contentType = request.getContentType();
        if ((contentType != null) &&
            (contentType.startsWith("multipart/form-data"))) {
            isMultipart = true;
            //initialize a MultipartRequestHandler
            MultipartRequestHandler multipart = null;

            //get an instance of ActionServlet
            ActionServlet servlet;

            if (bean instanceof ActionForm) {
                servlet = ((ActionForm) bean).getServlet();
            } else {
                throw new ServletException("bean that's supposed to be " +
                                           "populated from a multipart request is not of type " +
                                           "\"org.apache.struts.action.ActionForm\", but type " +
                                           "\"" + bean.getClass().getName() + "\"");
            }
            String multipartClass = (String)
                request.getAttribute(Action.MULTIPART_KEY);
            request.removeAttribute(Action.MULTIPART_KEY);

            if (multipartClass != null) {
                //try to initialize the mapping specific request handler
                try {
                    multipart = (MultipartRequestHandler) Class.forName(multipartClass).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    servlet.log("MultipartRequestHandler class \"" +
                    multipartClass + "\" in mapping class not found, " +
                    "defaulting to global multipart class");
                }
                catch (InstantiationException ie) {
                    servlet.log("InstantiaionException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    servlet.log("IllegalAccessException when instantiating " +
                    "MultipartRequestHandler \"" + multipartClass + "\", " +
                    "defaulting to global multipart class, exception: " +
                    iae.getMessage());
                }
            }

            if (multipart == null) {
                //try to initialize the global multipart class
                try {
                    multipart = (MultipartRequestHandler) Class.forName(servlet.getMultipartClass()).newInstance();
                }
                catch (ClassNotFoundException cnfe) {
                    throw new ServletException("Cannot find multipart class \"" +
                    servlet.getMultipartClass() + "\"" +
                    ", exception: " + cnfe.getMessage());
                }
                catch (InstantiationException ie) {
                    throw new ServletException("InstantiaionException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + ie.getMessage());
                }
                catch (IllegalAccessException iae) {
                    throw new ServletException("IllegalAccessException when instantiating " +
                    "multipart class \"" + servlet.getMultipartClass() +
                    "\", exception: " + iae.getMessage());
                }
            }


            //set the multipart request handler for our ActionForm
            //if the bean isn't an ActionForm, an exception would have been
            //thrown earlier, so it's safe to assume that our bean is
            //in fact an ActionForm
            ((ActionForm) bean).setMultipartRequestHandler(multipart);

            //set servlet and mapping info
            multipart.setServlet(servlet);
            multipart.setMapping((ActionMapping)
                                 request.getAttribute(Action.MAPPING_KEY));
            request.removeAttribute(Action.MAPPING_KEY);

            //initialize request class handler
            multipart.handleRequest(request);

            //retrive form values and put into properties
            multipartElements = multipart.getAllElements();
            names = multipartElements.keys();
        }

        if (!isMultipart) {
            names = request.getParameterNames();
View Full Code Here

TOP

Related Classes of org.apache.struts.upload.MultipartRequestHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.