hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anuj Jain" <anuj.j...@ness-gsg.com>
Subject File Upload Problem
Date Wed, 09 Feb 2005 20:11:49 GMT
Hi Guys ,
 
 A file upload problem has eaten couple of hours. Please suggest me
something. We are writing a testing framework using httpclient for client
server application. Our application is already coded. Now we want to perform
all possible actions with the httprequest using httpclient
 
This problem is related to file upload on server. I have written my code as 
 
and post parameter as 
 
 String url = "
<http://localhost:8080/MYAPP/enterprise11/desktoplaunch/InfoView/common/uplo
ad.object>
http://localhost:8080/MYAPP/enterprise11/desktoplaunch/InfoView/common/uploa
d.object";
 String filename = "c:\\a.rpt";
    File f = new File(filename);
 
     NameValuePair[] data = {
        new NameValuePair("folderId" ,"198"),
      new NameValuePair("cmd" ,"198"),
      new NameValuePair("corpCategories" ,""),
      new NameValuePair("personalCategories" ,""),
      new NameValuePair("extension" ,"rpt"),
      new NameValuePair("progID" ,"CrystalEnterprise.Report"),
      new NameValuePair("docName" ,"Report"),
      new NameValuePair("description" ,""),
    new NameValuePair("keywords" ,""),
    new NameValuePair("filename" ,f.getAbsolutePath()),    
          }; 
     
  MultipartPostMethod filePost =  new MultipartPostMethod(url);
     
     filePost.setQueryString(data);
     
        
        client.setConnectionTimeout(5000);
        try {
            client.executeMethod(filePost);
            String response = filePost.getResponseBodyAsString(); 
            }
           catch (IOException e) {
                System.err.println("Failed to download file.");
                e.printStackTrace();
           }
           filePost.releaseConnection();
           return 0;

 
But after executing i am getting 500 internal server err with the following
stack
 
javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:774)
 
org.apache.struts.action.ActionServlet.processPopulate(ActionServlet.java:20
61)
 org.apache.struts.action.ActionServlet.process(ActionServlet.java:1564)
 
com.crystaldecisions.webapp.struts.framework.CrystalUTF8InputActionServlet.p
rocess(CrystalUTF8InputActionServlet.java:29)
 org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 com.filter.TestFilter.doFilter(TestFilter.java:54)
</pre></p><p><b>root cause</b> <pre>java.lang.IllegalArgumentException:
argument type mismatch
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
 sun.reflect.Delegatin
 
I am not able to understand what else needs to be setted up to get this
operation done. Help me out. Apart from that I also want to know that if I
am dealing with httpclient classes how can I get to know is there any
problem with the http request itself or which post parameter is creating the
problem. I just want to know what went wrong and where?
 
your help will be highly appreciated.
 
Thanks
Anuj

 
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message