controller2

Posted on enero 8, 2010 by rpoveda.
Categories: Desarrollo de Aplicaciones Web.

Aqui se presenta el código de los servlet que determina si el usuario es bloqueado,
en este caso los usuarios que no son administradores(se los bloquea)

package DAW;

import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

/**
*
* @author estudiante
*/
public class controller2 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(«admin») && password.equalsIgnoreCase(«admin»)){
String nextJSP = «/pagina4.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.

Leave a comment

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>





Ir a la barra de herramientas