1. Take the following Servlet :
import javax.servlet.*;
import javax.servlet.http.*;
public class MyHelloWorld extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
public void destroy() {
}
protected void processRequest
(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet</title>");
out.println("</head>");
out.println("<body><h1>My Hello World</H1>");
out.println("</body>");
out.println("</html>");
out.close();
}
protected void doGet
(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
protected void doPost
(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
public String getServletInfo() {
return "Hello world servlet";
}
}
Another way is to install the Servlet through Jaguar Manager
Note : this way you can have init parameters, give a nice name to the servlet, etc...
The best way to deploy a Servlet is to use a Web application defined in a WAR file. Habitually, you build the WAR file with your IDE (like Netbeans or Forté). Then you deploy the WAR file to Jaguar with the Jaguar Manager ( RMB on Web Application - Deploy). You have to stop/start Jaguar after the deployment because the Refresh seems to be broken.
Written and compiled by Réal Gagnon ©1998-2005
[ home ]