JSP and Servlets
I'm new to Java, JSP, and servlets. I'm using NetBeans as my development platform with Tomcat as the container. I have a simple JSP page that I'm trying to execute my servlet with. Listed below is both the JSP page and the servlet code. The servlet never seems to be executed. I'm not sure if I've coded it wrong or I have the package setup wrong. When I test the JSP page in NetBeans the only message I receive is that the the document is rendered.
Thanks for the help!!
Gary
--JSP Page -
<%@page contentType="text/html"%>
<html>
<head><title>JSP Page</title></head>
<body>
<jsp:forward page="/EdrTest2" />;
</body>
</html>
Servlet --
/*
* EdrTest2.java
*
* Created on August 1, 2001, 10:00 AM
*/
package Edr;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
* @author gary_monk
* @version
*/
public class EdrTest2 extends HttpServlet {
/** Initializes the servlet.
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/** Destroys the servlet.
*/
public void destroy() {
}
/** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
*/
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>");
out.println("This is a test of a servlet");
out.println("</body>");
out.println("</html>");
out.close();
}
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/** Returns a short description of the servlet. */
public String getServletInfo() {
return "Short description";
}
}

