• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how does a request object transform during process

 
s ravi chandran
Ranch Hand
Posts: 328
Java jQuery
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
s ravi chandran
Ranch Hand
Posts: 328
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, if you want to dig down into the TCP/IP layers. But what for?
 
Paul Clapham
Sheriff
Pie
Posts: 20969
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64715
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. HTTP is a standard.
 
s ravi chandran
Ranch Hand
Posts: 328
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but http is not the only way of client request, right?
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The container "may" support other protocols, as mentioned in the the servlet specification .
 
s ravi chandran
Ranch Hand
Posts: 328
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your explanations. It has really improved my understanding about servlet requests.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic