File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlets(networking & http) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets(networking & http)" Watch "Servlets(networking & http)" New topic

Servlets(networking & http)

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
We are writing a search engine, which takes information from other search engines.
For this we need to send information to server side scripts of other web sites.
We accomplished this using GET method, but how to do it, when the server side script on the other site is expecting data from POST method.
Finally, is it legal to take information from other sites like this.
Please consider the matter very very urgent
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Yes you can, get the servlet to open a Socket to the server as if you were making a request, send the request and read the response.
The difficulty is getting the HTTP Header right. It's just a matter of writing some text and I have an example of a POSTed header around I'll just go look for it...
OK, here's an example of the HTTP header of a page I sumbitted to myself:

Most of the fields can be ignored, it's mostly the first line and the 'hideme=124&hideme2=124' that's important bit.
Also remeber that you need to send an extra CR at the end of your request (basically send an extra empty line) to tell the server that the request is finished otherwise it'll just sit there waiting...
I agree. Here's the link:
subject: Servlets(networking & http)
It's not a secret anymore!