Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTP POST  RSS feed

 
Raj Singh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet which only accepts multipart form-data and data via post only....i need to write a client (JAVA CODE only) to call the servlet by passing multiple pairs of info ex : nam=name, password=pass , i am getting a boundary exception any help
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally would need more information to reply intelligently.
I assume that you have your code in doPost(), right?
 
Mitan Chandihok
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think his solution would be to take a look at the HTTP protocol RFC. You want a client written in Java to hit the servlet and get data back. If I understand properly, you want to POST to a servlet without a web browser but with Java code.
By checking out the RFC you can check what needs to be sent as a standard HTTP request to a server and how the POST should look like when being sent. Also, if you google, or maybe native Java libraries include classes that write requests and POST data for you.
Another solution is if *YOU* have access to the servlet your trying to hit, you can define the doGet method to call the doPost method, and then you can just send a request within Java with your name/value pairs in the querystring.
Good luck!
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.net.HttpURLConnection class has the methods you need to set the type of connection from the client to POST, set headers etc.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!