17/07/2011, 16:24
|
| | Fecha de Ingreso: junio-2011
Mensajes: 151
Antigüedad: 13 años, 6 meses Puntos: 2 | |
Respuesta: Servlet no me redirije Pero y eso no lo consigo con el ServletBase que tengo??? el ServletLogin extiende de ServletBase que a su vez extiende de HttpServlet. Este es el código de ServletBase:
Código:
package Servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public abstract class ServletBase extends HttpServlet {
Error[] errors;
abstract void execute(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
//egin behar duena
abstract Error[] validate(HttpServletRequest req, HttpServletResponse resp);
//formularioko kontuak ondo idatzita dauden, Error[]-en jartzen ditu validapenen bat gaizki dagon
abstract void forwardErrors(HttpServletRequest req, HttpServletResponse resp,Error[] errors) throws ServletException, IOException;
//erroreak detektatzen ditu eta dispatch egiten du error pagina batera
//errors arrayan idazten ditu dauden erroreak
public abstract boolean securityRedirect(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
//segurtasun kontuak. bakarrik sartu al dira logeatuta daudenak...
abstract void forwardSecurity(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
//zer egin segurtasun barrera pasatzen ez badu
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {process(req,resp);}
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {process(req,resp);}
protected void process (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException{
if(securityRedirect(req,resp) == true){
System.out.println("security");
errors = validate(req,resp);
/* for(int i=0;i<errors.length;i++)
{
if(errors[i]!=null)System.out.println("name: "+errors[i].name+" value: "+errors[i].value);
}*/
if(errors!=null){
System.out.println("forward errors");
forwardErrors(req,resp,errors);//setAttribute de mensaje de error y redireccionar
}else{
System.out.println("execute");
execute(req, resp);
}
}else{
forwardSecurity(req,resp);
}
}
}
|