aspose file tools*
The moose likes Struts and the fly likes problem while reading multipart/form-data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem while reading multipart/form-data " Watch "problem while reading multipart/form-data " New topic
Author

problem while reading multipart/form-data

nithya Xavier
Greenhorn

Joined: Dec 08, 2009
Posts: 6
Hi,

I am using some validation on the input data.I am handiling this validation through the fiklter class.
For the GET request, getting all the values from the 'form bean' using 'request.getParameterNames()'
method. But in 'multipart/form-data' the 'form bean' values are not geeting from the normal request.
Inorder to solve this problem I used the 'BufferedRequestWrapper' class which extends 'HttpServletRequestWrapper'
class. Through this class I am able to get all the form bean values in both filter class as well as in the ActionForm class.
But now I am getting error after doing all the database operations. ie, it is doing the validation and redirect to the action class and saving the data in DB.
but coming back to the browser, it is displaying errors. It is throwing the errors like this.

java.lang.IllegalArgumentException: Cannot invoke Form.setCompanyLogo - argument type mismatch.

The following code snippet Iam using in filter class to handle the 'multipart/form-data'

public void doFilter(ServletRequest req, ServletResponse res, FilterChain fc)throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(request);
fc.doFilter(bufferedRequest, res);
}


Please help me to solve this problem....

Thanks in advance..
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

This seems like a struts problem to me, so I'll move it there...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
krishna prakash
Greenhorn

Joined: Apr 02, 2009
Posts: 7
add it line as <html:form action="/" enctype="multipart/form-data">
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

java.lang.IllegalArgumentException: Cannot invoke Form.setCompanyLogo - argument type mismatch.

Can you show us the code of the Form class. Also the code of the JSP which submits values to the action. Also which BufferedRequestWrapper class are you using??
nithya Xavier
Greenhorn

Joined: Dec 08, 2009
Posts: 6
the issue happens when the input type multipart and when using request wrapper.

filter has following code



JSP code is



The above jsp has an image upload. On submit, this action is completed and stores info and image successfully. then redirect to page which include global page which has a tile def. the tile def has following struts config entry



form bean is




Now its throws MPForm.setCompanyLogo - argument type mismatch' . and someaction is never getting called


nithya Xavier
Greenhorn

Joined: Dec 08, 2009
Posts: 6
Request wrapper has following code

nithya Xavier
Greenhorn

Joined: Dec 08, 2009
Posts: 6
This is error thrown

19:49:22,785 ERROR [PropertyUtils] Method invocation failed.
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773)
at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1759)
at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)
at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:1022)
at org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)



This exception is thrown when struts trying to populate form beam MPForm. However, there is no need to populate form, as we are displaying a page with form bean MPForm. Why struts tries to populate form bean in this case? (This happens when we wrap request for multipart request)

nithya Xavier
Greenhorn

Joined: Dec 08, 2009
Posts: 6
please help
nithya Xavier
Greenhorn

Joined: Dec 08, 2009
Posts: 6
Can anyone help me please?

thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem while reading multipart/form-data
 
Similar Threads
Post parameters are becoming null (at random)
generic Validation class with optional parameters
Problem in redirecting to the index screen
enctype="multipart/form-data" request.getParameter() issue
Session Management with Ajax