Forward con servlets
Im using tomcat 4.06 and i have some problems with servlets and forwarding:
This is my servlet:
import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
public class NTenant extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String email = request.getParameter("tenant");
//insert new tenant into database.
System.out.println("Redirigiendo");
ServletContext sc = getServletConfig().getServletContext();
RequestDispatcher rdNext = sc.getRequestDispatcher("/tenantForm.html");
rdNext.forward(request, response);
System.out.println("Redirigido");
}
}
I get this error:
type Status report
message Servlet invoker is currently unavailable
Description The requested service (Servlet invoker is currently unavailable) is not currently available.
This is my dir structure:
webapps\form\NewTenant.html
webapps\form\tenantForm.html
webapps\form\WEB-INF\web.xml
webapps\form\WEB-INF\classes\NTenant.class
webapps\form\WEB-INF\classes\TenantServlet.class
The problem is that i cannot find my html, ¿what must i write here? Sc.getRequestDispatcher("/tenantForm.html"); <-----
Thank you very much
This is my servlet:
import java.io.PrintWriter;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
public class NTenant extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
String email = request.getParameter("tenant");
//insert new tenant into database.
System.out.println("Redirigiendo");
ServletContext sc = getServletConfig().getServletContext();
RequestDispatcher rdNext = sc.getRequestDispatcher("/tenantForm.html");
rdNext.forward(request, response);
System.out.println("Redirigido");
}
}
I get this error:
type Status report
message Servlet invoker is currently unavailable
Description The requested service (Servlet invoker is currently unavailable) is not currently available.
This is my dir structure:
webapps\form\NewTenant.html
webapps\form\tenantForm.html
webapps\form\WEB-INF\web.xml
webapps\form\WEB-INF\classes\NTenant.class
webapps\form\WEB-INF\classes\TenantServlet.class
The problem is that i cannot find my html, ¿what must i write here? Sc.getRequestDispatcher("/tenantForm.html"); <-----
Thank you very much
1 Respuesta
Respuesta de todoswing
1