Struts 2
  1. Struts 2
  2. WW-1278

Prefix failed when Multipart form is submited

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: WW 2.2.2
    • Fix Version/s: 2.0.0
    • Component/s: None
    • Labels:
      None

      Description

      Prefix failed when Multipart form is submited

      see http://forums.opensymphony.com/thread.jspa?threadID=23756&tstart=0

        Activity

        Hide
        tm_jee added a comment -

        FilterDispatcher needs to wrap up mutipart request earlier before ActionMapper is give a chance to getMapping(...)

        In FilterDispatcher ...

        public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        .....
        ServletContext servletContext = filterConfig.getServletContext();
        try

        { request = du.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; LOG.error(message, e); throw new ServletException(message, e); }
        ActionMapper mapper = ActionMapperFactory.getMapper();
        ActionMapping mapping = mapper.getMapping(request);
        .....
        du.serviceAction(request, response, servletContext, mapping);
        ....
        }


        instead of current

        public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        .....
        ServletContext servletContext = filterConfig.getServletContext();

        ActionMapper mapper = ActionMapperFactory.getMapper();
        ActionMapping mapping = mapper.getMapping(request);
        .....
        ....
        try { request = du.wrapRequest(request, servletContext); }

        catch (IOException e)

        { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; LOG.error(message, e); throw new ServletException(message, e); }

        du.serviceAction(request, response, servletContext, mapping);
        ....
        }

        Show
        tm_jee added a comment - FilterDispatcher needs to wrap up mutipart request earlier before ActionMapper is give a chance to getMapping(...) In FilterDispatcher ... public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { ..... ServletContext servletContext = filterConfig.getServletContext(); try { request = du.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; LOG.error(message, e); throw new ServletException(message, e); } ActionMapper mapper = ActionMapperFactory.getMapper(); ActionMapping mapping = mapper.getMapping(request); ..... du.serviceAction(request, response, servletContext, mapping); .... } instead of current public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { ..... ServletContext servletContext = filterConfig.getServletContext(); ActionMapper mapper = ActionMapperFactory.getMapper(); ActionMapping mapping = mapper.getMapping(request); ..... .... try { request = du.wrapRequest(request, servletContext); } catch (IOException e) { String message = "Could not wrap servlet request with MultipartRequestWrapper!"; LOG.error(message, e); throw new ServletException(message, e); } du.serviceAction(request, response, servletContext, mapping); .... }
        Hide
        tm_jee added a comment -

        Can someone review it and if its ok, patched it into SAF2.0 once the code in Apache inbator stabilized. Thx.

        Show
        tm_jee added a comment - Can someone review it and if its ok, patched it into SAF2.0 once the code in Apache inbator stabilized. Thx.
        Hide
        Benx Shen added a comment -

        I create a new class extending FilterDispatcher and override doFilter() method as above. It seems to work well.

        Show
        Benx Shen added a comment - I create a new class extending FilterDispatcher and override doFilter() method as above. It seems to work well.
        Hide
        Rainer Hermanns added a comment -

        Toby,
        yes will do later this week...
        Thanks

        Show
        Rainer Hermanns added a comment - Toby, yes will do later this week... Thanks
        Hide
        tm_jee added a comment -

        Hi Rainer,

        I've commited the fix into svn when i was working on of my sample app that needs this. Kindly review, if its and resolve this issue if appropriate. Thx

        Show
        tm_jee added a comment - Hi Rainer, I've commited the fix into svn when i was working on of my sample app that needs this. Kindly review, if its and resolve this issue if appropriate. Thx
        Hide
        Rainer Hermanns added a comment -

        Toby, looks good to me...
        Closing it now

        Show
        Rainer Hermanns added a comment - Toby, looks good to me... Closing it now
        Hide
        Timo Kinnunen added a comment -

        This change means that a request is interpreted even when an ActionMapper is going to return null to signal for the FilterDispatcher to pass the request along the filter chain. I cannot use my own file upload servlet further along the chain.

        Cannot work around by overriding FilterDispatcher.doFilter, because FilterDispatcher.actionMapper and ActionContextCleanUp.cleanUp() are not visible.

        Can probably work around by overriding FilterDispatcher.prepareDispatcherAndWrapRequest() and hardcoding the ActionMapper class.

        Show
        Timo Kinnunen added a comment - This change means that a request is interpreted even when an ActionMapper is going to return null to signal for the FilterDispatcher to pass the request along the filter chain. I cannot use my own file upload servlet further along the chain. Cannot work around by overriding FilterDispatcher.doFilter, because FilterDispatcher.actionMapper and ActionContextCleanUp.cleanUp() are not visible. Can probably work around by overriding FilterDispatcher.prepareDispatcherAndWrapRequest() and hardcoding the ActionMapper class.

          People

          • Assignee:
            Rainer Hermanns
            Reporter:
            tm_jee
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development