Solved

Apache-Commons Httpclient MultipartPost (display part values)

Posted on 2004-08-11
8
351 Views
Last Modified: 2010-03-31
I am trying to use Apache-Commons Httpclient to send a MultipartPost request to a web server!  The server is not receiving the file I am sending!  I would like to know how to look at a trace of everything being sent by my MultipartPost!  That shows all the parts of the MultipartPost!  With each part's value exactly as the server sees the request coming to it!

The server is using Struts to receive the file!
0
Comment
Question by:Tgerdes
  • 4
  • 3
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 11779097
iterate thru each part and display its content.
0
 
LVL 1

Author Comment

by:Tgerdes
ID: 11786845
I did create a Part[] array and ran the ".getparts" method to copy the part attributes into an array!  The problem is that I do not know how to display its content.  What method do I use!  I can get all sorts of attributes about the part but not the content!
0
 
LVL 1

Author Comment

by:Tgerdes
ID: 11786899
I meant I do not know how to display an individual part's content.  The Part[] array contains attributes of the part... yet there is no method to display the content or value of each individual part!  
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Expert Comment

by:kumvjuec
ID: 11787435
Better use HTTPLook. It can give you all u want without programming to do.
You will find that using HTTPClient, the request contains much lesser attributes and a different data when u send a multipart request.

http://www.shareup.com/HTTPLook-download-3133.html
0
 
LVL 3

Expert Comment

by:kumvjuec
ID: 11787676
There is another way also, to see the content of your Part objects.
Download cocoon.jar from
http://cvs.sourceforge.net/viewcvs.py/krysalis/krysalis-wings/lib/core/Attic/cocoon.jar?rev=1.2

Then include it in your classpath and then this code will work :)
####
byte[] partContent = org.apache.cocoon.utils.IOUtil.objectToBytes(Part[0]);
System.out.println(partContent.toString());
####
0
 
LVL 1

Author Comment

by:Tgerdes
ID: 11796746
I tried adding the cocoon.jar to my classpath and I got the error below:

Attaching Java program to /pospay/JavaHttpClient/classes/cocoon.JAR.                        
java.io.NotSerializableException: org.apache.commons.httpclient.methods.multipart.StringPart
        at java/lang/Throwable.<init>(Throwable.java:195)                                  
        at java/io/IOException.<init>(IOException.java:40)                                  
        at java/io/ObjectStreamException.<init>(ObjectStreamException.java:24)              
        at java/io/NotSerializableException.<init>(NotSerializableException.java:26)        
        at java/io/ObjectOutputStream.writeObject0(ObjectOutputStream.java:1054)            
        at java/io/ObjectOutputStream.writeObject(ObjectOutputStream.java:278)              
        at org/apache/cocoon/util/IOUtils.objectToBytes(IOUtils.java:373)                  
        at TESTMEJ.main(TESTMEJ.java:162)                                                  
                                                                                           
0
 
LVL 3

Accepted Solution

by:
kumvjuec earned 300 total points
ID: 11796858
hi,

ok, Part doesn't implement serializable interface.
You can do this to see all the content your parts have. Try this

part[index].send(System.out);

All the data with header will print on console. Tell me if that helped or not..:)
0
 
LVL 1

Author Comment

by:Tgerdes
ID: 11853191
Thanks! this last solution allowed me to view the data being sent to the server in the exact same format that the server sees it!  This worked well for me!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question