File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring 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: 63540

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]
It is sorta covered in the JavaRanch Style Guide.
subject: why service() accepts HttpServletResponse
It's not a secret anymore!