Solved

Apache-Commons Httpclient MultipartPost (display part values)

Posted on 2004-08-11
8
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

691 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