Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Sockets and Internet Protocols and the fly likes Mutiple Http Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Mutiple Http Request" Watch "Mutiple Http Request" New topic
Author

Mutiple Http Request

Aiyush Kumar
Greenhorn

Joined: Aug 01, 2011
Posts: 5
Hi All,

I am using http handler to handle http request. but i am getting problem when i am sending multiple request from different client then request are process in sequence. and there is delay in request processing. can any body please help me that how can i process multiple http request parallel.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41184
    
  45
This code seems to handle only a single response. How are you using it that you think it should handle multiple simultaneous requests?


Ping & DNS - my free Android networking tools app
Aiyush Kumar
Greenhorn

Joined: Aug 01, 2011
Posts: 5
so please tell me what will i use to handle multiple request simultanious.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41184
    
  45
We can't know that - what kind of software is this: part of a web app? A desktop app? A standalone server? Something else?

If you're trying to design a multi-threaded Java server, start here: http://download.oracle.com/javase/tutorial/networking/sockets/index.html
Aiyush Kumar
Greenhorn

Joined: Aug 01, 2011
Posts: 5
actually i m trying to make a standalone server. which handle the http request from multiple client at same time. and i am using http handler to handle the request. but it is processing only one request at a time, and i want to access multiple http request at same time. the link provide by you is only for simple socket programming where a client sends request to server. please help me out that how i can i access multiple requests at same time.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41184
    
  45
Have you worked through the tutorial I pointed you to? It contains an example of a multi-threaded server.
Aiyush Kumar
Greenhorn

Joined: Aug 01, 2011
Posts: 5
thanks Ulf. but go through your suggested link but that explain only single thread application not for multi-threaded. please can you give me some example to my problem. because i am handling request generated on an particular ip and port.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41184
    
  45
Apparently you missed the part where the multi-threaded server is discussed; it's in the "Supporting Multiple Clients" section.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

For multi-threaded responses, you'll need multiple connections (sockets) and one thread per connection. This thread will execute the handle method. This is explained at the bottom of the page Ulf linked to.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Aiyush Kumar
Greenhorn

Joined: Aug 01, 2011
Posts: 5
Ulf, actually i want to handle the http request by getRequestHeader or requestBody methods. otherwise i have to split the data from URl. and with serversocket i can't access HttpExchange which directly get the header and body part of data from request. and with httpExchange i can't access multi-threading. can you please help me by providing any other solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mutiple Http Request
 
Similar Threads
I want observer/observable implemented in Servlet/Applet
Thread Concept
GET html contents from a web server
Trying to emulate HTTP file upload with an applet
setrequestheader() - User-Agent - no good?