Aqui se presenta el código de los servlet que determina si el usuario es bloqueado,
en este caso los usuarios que no son estudiantes(se los bloquea)
package DAW;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
*
* @author estudiante
*/
public class controller extends HttpServlet{
/** Creates a new instance of NewClass */
protected void processRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
String usuario=req.getParameter(«usuario»);
String password=req.getParameter(«pasword»);
res.setContentType(«text/html; charset=UTF-8»);
//PrintWriter out = res.getWriter();
if(usuario.equalsIgnoreCase(«estud») && password.equalsIgnoreCase(«estud»)){
String nextJSP = «/pagina3.jsp»;
RequestDispatcher rd = getServletContext().getRequestDispatcher(nextJSP);
rd.forward(req, res);
}else
res.sendError(401,»Usted esta bloqueado»);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, 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, IOException
{
processRequest(request, response);
}
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return «Short description»;
}
}
no comments yet.
Names and email addresses are required (email addresses aren't displayed), url's are optional.
Comments may contain the following xhtml tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>