import
java.io.*
HelloWorld
<html> <head> <title>Hello, World!</title> </head> <body> <h1>Hello, World!</h1> This output was generated by my own servlet. </body> </html>
HelloWorld.java
// The path below is legacy path from year 1999 c:\jsdk2.1\examples\WEB.INF\servlets.
http://localhost:8080/servlet/HelloWorld
doGet()
public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
res.setContentType("text/html"); PrintWriter out = res.getWriter();
out.println("<html><head><title>Hello, World!</title></head>");