aspose file tools*
The moose likes Servlets and the fly likes how does a request object transform during process Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how does a request object transform during process" Watch "how does a request object transform during process" New topic
Author

how does a request object transform during process

s ravi chandran
Ranch Hand

Joined: Dec 20, 2010
Posts: 149
hi,
i was recently asked a tricky question. the question was, how does a user request from a browser become a request object in a servlet? it has something to do with the lifecycle of the request object, but it seems, there are many lifecycles involved in this. would anyone explain the working?

thanks
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2713
    
    5

I am not getting what is the trick here. The container gets the HTTP request, pulls out information from it and populates an object which is called the ServletRequest.
Am I not getting the question?


SCJP, SCWCD.
|Asking Good Questions|
s ravi chandran
Ranch Hand

Joined: Dec 20, 2010
Posts: 149
Amit Ghorpade wrote:I am not getting what is the trick here. The container gets the HTTP request, pulls out information from it and populates an object which is called the ServletRequest.
Am I not getting the question?


actually from the container, i know the process. but is there something before the client request reaches to the container? i mean some transition in request object.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Sure, if you want to dig down into the TCP/IP layers. But what for?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18155
    
    8

There isn't anything like a "transition in the request object". First of all an HTTP request is a stream of bytes which is sent over the network and received by the server. The server instantiates an HttpRequest object and populates it with information extracted from that stream of bytes, as Amit said. You could think of this as a "transition" if you liked, but it isn't a transition in any kind of object. It's simply a process which takes some input and creates an object.

You seem to be imagining that the HTTP request (that stream of bytes) and the request object which your servlet receives are one and the same thing. That isn't the case.
s ravi chandran
Ranch Hand

Joined: Dec 20, 2010
Posts: 149
Paul Clapham wrote:There isn't anything like a "transition in the request object". First of all an HTTP request is a stream of bytes which is sent over the network and received by the server. The server instantiates an HttpRequest object and populates it with information extracted from that stream of bytes, as Amit said. You could think of this as a "transition" if you liked, but it isn't a transition in any kind of object. It's simply a process which takes some input and creates an object.

You seem to be imagining that the HTTP request (that stream of bytes) and the request object which your servlet receives are one and the same thing. That isn't the case.

okay, so any client browser will send a request which any j2ee container can process and extract relevant information, is it right?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Yes. HTTP is a standard.
s ravi chandran
Ranch Hand

Joined: Dec 20, 2010
Posts: 149
but http is not the only way of client request, right?
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2713
    
    5

s ravi chandran wrote:but http is not the only way of client request, right?

No there can be other ways like FTP, but HTTP servlets do not handle them.
You can use the generic servlet implementation to handle FTP or any other protocol, but I have not seen such a requirement ever.
s ravi chandran
Ranch Hand

Joined: Dec 20, 2010
Posts: 149
Amit Ghorpade wrote:
s ravi chandran wrote:but http is not the only way of client request, right?

No there can be other ways like FTP, but HTTP servlets do not handle them.
You can use the generic servlet implementation to handle FTP or any other protocol, but I have not seen such a requirement ever.

Not the Servlet, i was actually talking about the container. does it also has the limitation of a servlet? i mean mainly it supports HTTP, else uses Generic protocol which needs to be implemented in order to use it for any particular protocol?
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2713
    
    5

The container "may" support other protocols, as mentioned in the the servlet specification .
s ravi chandran
Ranch Hand

Joined: Dec 20, 2010
Posts: 149
Thanks guys for your explanations. It has really improved my understanding about servlet requests.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how does a request object transform during process
 
Similar Threads
MultipartRequest help needed!
java bean question
struts & using js to change label text to red
How do clients always end up with the same Stateful bean
Struts2 and setting data before a form is displayed.