[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Apache-Commons Httpclient MultipartPost (display part values)

Posted on 2004-08-11
8
Medium Priority
?
373 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.
Suggested Courses

649 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