Reputation: 3433
I am curious to know who create HttpResponse
object for a servlet, since inside service method we got this as argument which are already instantiated.
Upvotes: 3
Views: 4137
Reputation: 12993
who create HTTPResponse object for a servlet
From Java docs HttpServletResponse
The servlet container creates an HttpServletResponse object and passes it as an argument to the servlet's service methods (doGet, doPost, etc).
public interface HttpServletResponse
extends ServletResponse
Extends the ServletResponse
interface to provide HTTP-specific functionality in sending a response. For example, it has methods to access HTTP headers and cookies.
public interface ServletResponse
Defines an object to assist a servlet in sending a response to the client. The servlet container creates a ServletResponse object and passes it as an argument to the servlet's service method.
Upvotes: 2
Reputation: 745
Servlet is created either when URL is initiated or when your server(servlet container) starts. The servlet container creates an HttpServletResponse object and passes it as an argument to the servlet's service methods.
Upvotes: 1