File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

http request through java code

 
swapnel surade
Ranch Hand
Posts: 129
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm building an application in which I'm sending HTTP request through java code.



but when I'm listening in thread at given port I'm getting 2 request for single button click.

is there any problem in the code...

thanks
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything obviously wrong. Does this code get called twice?
 
Pat Farrell
Rancher
Posts: 4660
5
Linux Mac OS X VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While it is not hard to get a basic GET or POST to work using just the Java libraries, there is a lot more to doing it properly and completely.

Things like "chunked" responses must be supported, and my code was in production for several months before I even knew that it could happen.

I strongly recommend just using the Apache Http client library. Its easy to use, does all the edge cases properly, handles normal and SSL, etc.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic