Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where is the response object in page71

 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
small doubt if you see the diagram.....

In HDFC jsp and serv
page 71

at step 7 they say servlets add to request obj

but then where is response obj is there actually will there be no response object at all please clarify me

as i new to this......

thank you very
much bye....
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and When we see page 42

they say that

container creates the request and response object.....

can any one explain this

please
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For HTTP - each request received from a client is converted by the container into two objects which implement the HttpServletRequest and HttpServletResponse interfaces.

Page 42 explains this (showing the two objects). These are passed into your servlet through the service method.

Page 71 doesn't appear to show the response object, but it will be there.
It will later be passed to the JSP page (result.jsp) using a RequestDispatcher (which takes both the request/response objects) for the new component (the JSP).
The JSP will then write the output to the client using the request object.
 
kajal mukergi
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok
thank you very much
but here we will never use the... response object....
.why so...???
 
Mark Garland
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*You* don't use the response object in the servlet, because you are going to dispatch the request to the JSP.

when you dispatch the request, you will give it the response object, and it will use it to write the response to.

It's just not shown on that diagram.


Bits of the code could look like:

(The response comes in)
public void doGet(HttpServletRequest request, HttpServletResponse response) { ....

(The request is dispatched)
requestDispatcher.forward (request, response);

The JSP would then write to that response.

Put it this way - if you didn't pass the response object on, how would the contents of the JSP ever get back to the client?
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sudhakar,

Actually it is following MVC architecture.

BeerExpertComponent returns the business logic output to the servlet, servlet
has not to prepare the view for the client, it simply adds the result to
the request object and forwards it to the jsp that will use the response
object that is implicit to the jsp.


Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic