Version 1.0
Version 2.1 (early access)
Version 2.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class firstServlet extends HttpServlet {
public void init(ServletConfig conf) throws ServletException {
super.init(conf);
connections = 0;
}
public void service(HttpServletRequest req, HttpServletResponse res)
throws IOException{
//Get a channel to the Web browser, so we can send output
ServletOutputStream out = res.getOutputStream();
res.setContentType("text/html"); // Required for HTTP
out.println("<HTML><HEAD><TITLE>Servlets 101</TITLE></HEAD>");
out.print("Say hello to Java Servlet Programming, ");
out.println(req.getParameter("userName"));
out.print("<p>You are caller number ");
connections++;
out.println(Integer.toString(connections));
out.close(); //Close the output stream
}
int connections;
}
| 22-feb-2000 holm wegner |