Hello World Servlet HelloWorld.java


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.io.IOException;

public class HelloWorld  extends HttpServlet{

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{

response.setContentType(“text/html”);
PrintWriter out = response.getWriter();

out.println(“<html>”);
out.println(”  <head>”);
out.println(”    <title>SimpleServlet</title>”);
out.println(”  </head>”);
out.println(”  <body>”);
out.println(”    Hello, World”);
out.println(”  </body>”);
out.println(“</html>”);

}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s