File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Sending request headers manually Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Sending request headers manually" Watch "Sending request headers manually" New topic
Author

Sending request headers manually

Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Hello all,

I understand that when a resource on the webserver is requested, the browser sends the request headers and initiates a request to the web server. I wanted to know if we can trigger a GET or POST request manually to a servlet.(Not through browser or any other means).Please let me know if there is a possibility.


Success is never ending and Failure is neve Final
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
You can use telnet for this.Establish a TCP connection with your server (and the correct port)and then use GET to fetch page , You can pass parameters using query string appending to the URL.


Rahul Bhattacharjee
LinkedIn - Blog
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41592
    
  55
The commands for this would be:

to start Telnet (replace the server name and port as appropriate), and then

and hit return twice. That should print out the start page, and then close the connection.


Ping & DNS - my free Android networking tools app
Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Hi Rahul,

Thanks for the reply. I did the following to use telnet. Please correct me if I am missing something

(1)Opened telnet client from Start->Run->Telnet from windows.
(2)Tried connecting to Tomcat server on the same machine as follows
(i)telnet 172.24.17.22 8080. This showed me blank window
(ii)telnet and then at the telnet prompt issued telnet command "o 172.24.17.22 8080". This said connecting to 172.24.... and then showed me a blank window.

I also tried replacing my machine IP address above by "localhost" and
"md-bhaskar"(my machine hostname) but in vain. Please let me know if I need to do anything further.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
That is all good and expected.

Did you try what ULF suggested ?

Once a successful connection is established , you will get a blank screen as you are getting now.

Paste the following code to get the home page of ROOT application of Tomcat.

Bachi Taurean
Greenhorn

Joined: Aug 03, 2006
Posts: 26
Thank you Rahul and Ulf, it is working now.Appreciate your immediate reply and help
 
Consider Paul's rocket mass heater.
 
subject: Sending request headers manually