Solved

Apache-Commons Httpclient MultipartPost (display part values)

Posted on 2004-08-11
8
346 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now