Deploy a Servlet(this howto is deprecated)Tag(s): DEPRECATED
Here the simplest way to execute a servlet through Jaguar.
Note : this way you can't control the servlet through Jaguar manager.
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";
}
}3. Copy the class into %jaguar%\html\classes
4. in IE : http://localhost:8080/servlet/MyHelloWorld
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...
- same servlet
- compile
- Same copy
- In Jaguar Manager, Servlets -> new Servlet , give MyServletHelloWorld as the name, the fully qualified name is MyHelloWorld
- In Jaguar Manager, Jaguar -> Installed Servlets -> Install Servlet -> Intall an Existing Servlet , select MyServletHelloWorld
- On Installed Servlets, refresh with RMB (right mouse button)
- start MyServletHelloWorld servlet with the MRB (mouse right button)
- in IE : http://localhost:8080/servlet/MyServletHelloWorld
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.
mail_outline
Send comment, question or suggestion to howto@rgagnon.com
Send comment, question or suggestion to howto@rgagnon.com