I'm developping a little website for school with JSP and servlets, but i'm having a problem. I'm trying to restrict the access to the toolbox page, so only someone with the admin password could access to it.
So i put a little form (with post method) to get the password, and in my servlet i get it and check if it's the good one. But it seems like it always consider it's a wrong password and always redirect me to the wrong page ...
Content of my FiltreAdmin servlet :
public class FiltreAdmin extends HttpServlet {
public static final String VUE = "/WEB-INF/filtreAdmin.jsp";
public static final String ACCES_PUBLIC = "/restreintAdmin.jsp";
public static final String ACCES_RESTREINT = "/WEB-INF/toolbox.jsp";
public void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
this.getServletContext().getRequestDispatcher( VUE ).forward( request, response );
}
public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
if ( request.getAttribute("passwd") != "freebeer" ) {
/* Redirection vers la page publique */
response.sendRedirect( request.getContextPath() + ACCES_PUBLIC );
} else {
/* Affichage de la page restreinte */
this.getServletContext().getRequestDispatcher( ACCES_RESTREINT ).forward( request, response );
}
}
}
Would someone have an idea ?