Java Reference
In-Depth Information
HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("Hello World");
out.close();
}
}
D Print writer prints HTML responses
E Printing response for the end user
B This servlet inherits from HTTPServlet , which is the standard communication
between the client and server for this class of application.
C This program is triggered by an HTTP GET request. The other common HTTP
command is POST . Many times, both GET s and POST s are sent to a common
method. These examples consolidate them in a method called performTask .
Server
Web app server
Servlet
F
HTML
E
D
Web server
C g
Hardware
Client
B
Browser
System software
Program artifact
Figure 3.4 B The user makes a request for a servlet. C The browser does an HTTP POST .
D The web server passes the request through to the application server, possibly installed as a
web server plug-in. E The application server invokes the servlet. F The servlet executes and
prints out an HTML page that G is returned to the user.
Search WWH ::




Custom Search