This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes why service() accepts HttpServletResponse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "why service() accepts HttpServletResponse" Watch "why service() accepts HttpServletResponse" New topic

why service() accepts HttpServletResponse

vianyrajnish rajnish
Ranch Hand

Joined: Apr 22, 2007
Posts: 70

i like to know .. why service() accepts httpservletrequest and httpservletresponse both ....when only httpservletrequest is enough..?

please reply me anyone

vinay rajnish
Vishal Matere
Ranch Hand

Joined: Jan 22, 2008
Posts: 81
Because service() ultimately calls doGet()/doPost() methods which needs response object to send response to client.

Alternatively user can overide service() method and can write his own code to return response.


SCJP <br />SCWCD <br />SCBCD <br />SCEA-1
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63870

If the request is "enough" how would you propose that a servlet writes output to the response and/or set headers?

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: why service() accepts HttpServletResponse
It's not a secret anymore!