This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Servlets and the fly likes HttpServletResponse& HttpServletRequest Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServletResponse& HttpServletRequest" Watch "HttpServletResponse& HttpServletRequest" New topic

HttpServletResponse& HttpServletRequest

S Varana

Joined: Feb 04, 2004
Posts: 18
public class SimpleServlet extends HttpServlet
* Handle the HTTP GET method by building a simple web page.
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
Stringtitle = "Simple Servlet Output";
// set content type and other response header fields first
// then write the data of the response
out = response.getWriter();
out.println("<H1>" + title + "</H1>");
out.println("<P>This is output from SimpleServlet.");
HttpServletResponse & HttpServletRequest
In the Java API they are defined as interfaces
but i do not find the method "setContentType"
From where is the method "setContentType"
Please explain me.
Ashish Thakur

Joined: Mar 18, 2000
Posts: 22
The HttpServletResponse & Request are extended from the ServletRequest and Response in the javax.servlet package.
It is from here that the setContentType is taken.
Good Luck ,
Ashish T.
I agree. Here's the link:
subject: HttpServletResponse& HttpServletRequest
It's not a secret anymore!