aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpServletResponse& HttpServletRequest" Watch "HttpServletResponse& HttpServletRequest" New topic
Author

HttpServletResponse& HttpServletRequest

S Varana
Greenhorn

Joined: Feb 04, 2004
Posts: 18
<pre>
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
{
PrintWriterout;
Stringtitle = "Simple Servlet Output";
// set content type and other response header fields first
response.setContentType("text/html");
// then write the data of the response
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY>");
out.println("<H1>" + title + "</H1>");
out.println("<P>This is output from SimpleServlet.");
out.println("</BODY></HTML>");
out.close();
}
}
</pre>
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"
coming
Please explain me.
Ashish Thakur
Greenhorn

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 ,
Bye
Ashish T.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpServletResponse& HttpServletRequest
 
Similar Threads
how to set up weblogic for servlet
Compiling the servlet
new, need help!!!
HTTP servlet problem
Basic Servlet Problem