You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by jm...@za.safmarine.com on 2003/04/10 11:21:08 UTC
java.lang.ClassCastException: org.apache.struts.upload.MultipartRequestWrapper
I'm opening a file in a jsp which is then read into a form bean
class.In the corresponding Action class I have code that looks like
as shown below:
public class CreateTestSuiteAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String target = "main_direct_jsp";
CreateTestSuiteForm createForm=(CreateTestSuiteForm)form;
System.out.println("File Name :"
+createForm.getMessageXMLFile().getFileName());
/*=======================================
Write some killer code here
=======================================*/
return (mapping.findForward(target));
}
}
The target pointed to by "target" is another jsp.The forwarding isn't
working well because whe I run the app the following exception is
thrown:
java.lang.ClassCastException:
org.apache.struts.upload.MultipartRequestWrapper
>From the info I found it looks like the request object being
forwarded to the target jsp is no longer a plain HttpServletRequest ,
but one wrapped in a MultipartRequestWrapper object .
What's going wrong here?How do fix this?I'm doing my development on
WSAD 5.0
Jeff Mutonho
Developer
Safmarine Computer Services(Pty Ltd)
ph : + 27 21 408 6230
mob : + 27 83 229 1154
web : www.scs.co.za
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: java.lang.ClassCastException: org.apache.struts.upload.MultipartRequestWrapper
Posted by Andrew Hill <an...@gridnode.com>.
What Im about to try (since I dont have time to upgrade to a newer struts
version (im on 1.1b1 still)) is to override the doForward method in the
requestProcessor by copying the following into my requestProcessor class (as
Ive already overriden a few things): Havent done it yet - so it may well not
workm but worth a shot.
protected void doForward(String uri, HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
// Unwrap the multipart request, if there is one.
if (request instanceof MultipartRequestWrapper) {
request = ((MultipartRequestWrapper) request).getRequest();
}
RequestDispatcher rd =
getServletContext().getRequestDispatcher(uri);
if (rd == null) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
getInternal().getMessage
("requestDispatcher", uri));
return;
}
rd.forward(request, response);
}
This code codes from the latest nightly. Dont know if it will help with your
problem since mines slightly different (the error message at least!) - but I
suspect they have the same cause. The important line in this one is request
= ((MultipartRequestWrapper) request).getRequest() - where it "unwraps" the
request before forwarding...
-----Original Message-----
From: Andrew Hill [mailto:andrew.david.hill@gridnode.com]
Sent: Thursday, 10 April 2003 17:35
To: Struts Users Mailing List
Subject: RE: java.lang.ClassCastException:
org.apache.struts.upload.MultipartRequestWrapper
Oh wow. Im looking into a similar issue myself right this moment (on
weblogic).
Maybe this bug report I just came across can give you some more info:
http://issues.apache.org/bugzilla/show_bug.cgi?id=8732
btw: Which struts version are you using?
-----Original Message-----
From: jmutonho@za.safmarine.com [mailto:jmutonho@za.safmarine.com]
Sent: Thursday, 10 April 2003 17:21
To: struts-user@jakarta.apache.org
Subject: java.lang.ClassCastException:
org.apache.struts.upload.MultipartRequestWrapper
I'm opening a file in a jsp which is then read into a form bean
class.In the corresponding Action class I have code that looks like
as shown below:
public class CreateTestSuiteAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String target = "main_direct_jsp";
CreateTestSuiteForm createForm=(CreateTestSuiteForm)form;
System.out.println("File Name :"
+createForm.getMessageXMLFile().getFileName());
/*=======================================
Write some killer code here
=======================================*/
return (mapping.findForward(target));
}
}
The target pointed to by "target" is another jsp.The forwarding isn't
working well because whe I run the app the following exception is
thrown:
java.lang.ClassCastException:
org.apache.struts.upload.MultipartRequestWrapper
>>From the info I found it looks like the request object being
forwarded to the target jsp is no longer a plain HttpServletRequest ,
but one wrapped in a MultipartRequestWrapper object .
What's going wrong here?How do fix this?I'm doing my development on
WSAD 5.0
Jeff Mutonho
Developer
Safmarine Computer Services(Pty Ltd)
ph : + 27 21 408 6230
mob : + 27 83 229 1154
web : www.scs.co.za
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: java.lang.ClassCastException: org.apache.struts.upload.MultipartRequestWrapper
Posted by Andrew Hill <an...@gridnode.com>.
Oh wow. Im looking into a similar issue myself right this moment (on
weblogic).
Maybe this bug report I just came across can give you some more info:
http://issues.apache.org/bugzilla/show_bug.cgi?id=8732
btw: Which struts version are you using?
-----Original Message-----
From: jmutonho@za.safmarine.com [mailto:jmutonho@za.safmarine.com]
Sent: Thursday, 10 April 2003 17:21
To: struts-user@jakarta.apache.org
Subject: java.lang.ClassCastException:
org.apache.struts.upload.MultipartRequestWrapper
I'm opening a file in a jsp which is then read into a form bean
class.In the corresponding Action class I have code that looks like
as shown below:
public class CreateTestSuiteAction extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String target = "main_direct_jsp";
CreateTestSuiteForm createForm=(CreateTestSuiteForm)form;
System.out.println("File Name :"
+createForm.getMessageXMLFile().getFileName());
/*=======================================
Write some killer code here
=======================================*/
return (mapping.findForward(target));
}
}
The target pointed to by "target" is another jsp.The forwarding isn't
working well because whe I run the app the following exception is
thrown:
java.lang.ClassCastException:
org.apache.struts.upload.MultipartRequestWrapper
>>From the info I found it looks like the request object being
forwarded to the target jsp is no longer a plain HttpServletRequest ,
but one wrapped in a MultipartRequestWrapper object .
What's going wrong here?How do fix this?I'm doing my development on
WSAD 5.0
Jeff Mutonho
Developer
Safmarine Computer Services(Pty Ltd)
ph : + 27 21 408 6230
mob : + 27 83 229 1154
web : www.scs.co.za
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org