Simple program to access a servlet and display a welcome message
import
javax.servlet.http.*;
import
javax.servlet.*;
import
java.io.*;
public
class WelcomeServlet extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException, IOException
{
//setting the content type
res.setContentType("text/html");
//create the stream to write the
data
PrintWriter
pw=res.getWriter();
//writing html in the stream
pw.println("<html><body>");
pw.println("<center><h2>Welcome to servlet</h2></center>");
pw.println("</body></html>");
//closing the stream
pw.close();
}
}
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu