當前位置: 首頁>>代碼示例>>Java>>正文


Java RequestDispatcher.forward方法代碼示例

本文整理匯總了Java中javax.servlet.RequestDispatcher.forward方法的典型用法代碼示例。如果您正苦於以下問題:Java RequestDispatcher.forward方法的具體用法?Java RequestDispatcher.forward怎麽用?Java RequestDispatcher.forward使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.RequestDispatcher的用法示例。


在下文中一共展示了RequestDispatcher.forward方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String destino;
    request.setCharacterEncoding("UTF-8");
    HttpSession sessao = request.getSession();
    if (sessao.getAttribute("usuario") != null) {
        request.setAttribute("usuario", sessao.getAttribute("usuario"));
        // Remove o atributo da sessao para usuario nao ficar preso na tela de resultados           

        destino = "alterarUsuario.jsp";
    } else {
        destino = "alterarUsuario.jsp";
    }

    RequestDispatcher dispatcher = request.getRequestDispatcher(destino);
    dispatcher.forward(request, response);

}
 
開發者ID:Dinossaura,項目名稱:LojaDeInstrumentosMusicais,代碼行數:20,代碼來源:EditarUsuarioServlet.java

示例2: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String destino;
    
    HttpSession sessao = request.getSession();
    if (sessao.getAttribute("cliente") != null) {
        request.setAttribute("cliente", sessao.getAttribute("cliente"));
        // Remove o atributo da sessao para usuario nao ficar preso na tela de resultados
        sessao.removeAttribute("cliente");
        
        destino = "/clientes";
    } else {
        destino = "cadastroCliente.jsp";
    }
    
    RequestDispatcher dispatcher = request.getRequestDispatcher(destino);
    dispatcher.forward(request, response);
    
}
 
開發者ID:Dinossaura,項目名稱:LojaDeInstrumentosMusicais,代碼行數:21,代碼來源:CadastrarClienteServlet.java

示例3: logar

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
private void logar(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String email = request.getParameter("email");
    String senha = request.getParameter("senha");
    
    UsuarioBO bo = new UsuarioBO();
    Usuario usuario = bo.logar(email, senha);
    
    if (usuario != null){
        request.setAttribute("usuario", usuario);
        
        request.getSession().setAttribute("usuario", usuario);
        
        response.sendRedirect("./FeedControle?operacao=Atualizar");
    } else {
        request.setAttribute("mensagem", "Usuário ou senha inválidos");
        
        RequestDispatcher rd = request.getRequestDispatcher("index.jsp");
        rd.forward(request, response);
    }
}
 
開發者ID:Ronneesley,項目名稱:redesocial,代碼行數:21,代碼來源:LoginControle.java

示例4: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
      HttpSession sessao = request.getSession();  
      ArrayList<Cliente> Lista = new ArrayList();
      ServicoCliente sc = new ServicoCliente();
      String codigoempresa = (String) sessao.getAttribute("Empresa");
      
      try {
        Lista = (ArrayList<Cliente>) sc.procurarCliente("", Integer.parseInt(codigoempresa));
    } catch (Exception e) {
    }
    
      sessao.setAttribute("ListaClientes", Lista);
      
      RequestDispatcher dispatcher
 = request.getRequestDispatcher("/consultarCliente.jsp");
dispatcher.forward(request, response);
}
 
開發者ID:Dinossaura,項目名稱:LojaDeInstrumentosMusicais,代碼行數:20,代碼來源:ConsultaClienteServlet.java

示例5: processRequest

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    HttpSession session = request.getSession(true);
    String bruker = (String)session.getAttribute("bruker");
    String Foreleser = "Foreleser";
    try (PrintWriter out = response.getWriter()) {
        if(bruker.equals(Foreleser)) {
        RequestDispatcher rd = request.getRequestDispatcher("JSP/AddUser.jsp");
            rd.forward(request, response);
        }
        else
            out.println("Feil bruker, du er logget inn som " + bruker);
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:25,代碼來源:AddUser.java

示例6: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {


    List<ClientVersion> clientVersionList;
    try {
        clientVersionList =
                new ClientVersionDao(Utility.getDBConnection(this.getServletContext())).getClientVersionList();
        if (log.isDebugEnabled())
            log.debug("out->: clientVersionList" + clientVersionList);
        request.setAttribute("clientVersionList", clientVersionList);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        throw new KiteSQLException(e.getLocalizedMessage());
    }

    // get UI
    if (log.isDebugEnabled())
        log.debug("Displaying: client_version.vm");
    RequestDispatcher requestDispatcher = request.getRequestDispatcher("client_version.vm");
    requestDispatcher.forward(request, response);
}
 
開發者ID:webrtc,項目名稱:KITE,代碼行數:27,代碼來源:ClientVersionServlet.java

示例7: editar

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
private void editar(HttpServletRequest request, HttpServletResponse response) throws Exception{
    try {
        Integer id = Integer.parseInt(request.getParameter("id"));

        PaisBO paisBO = new PaisBO();
        Pais pais = paisBO.selecionar(id);

        request.setAttribute("pais", pais);

        request.setAttribute("mensagem", "Registro selecionado com sucesso");
    } catch (Exception ex){
        request.setAttribute("erro", ex.getMessage());
    }

    RequestDispatcher rd = request.getRequestDispatcher("paginas/paises/cadastro_paises.jsp");
    rd.forward(request, response);
}
 
開發者ID:Ronneesley,項目名稱:redesocial,代碼行數:18,代碼來源:PaisControle.java

示例8: processRequest

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        RequestDispatcher rd = request.getRequestDispatcher("JSP/MinSide.jsp");
            rd.forward(request, response);
   
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:19,代碼來源:MinSide.java

示例9: forwardToErrorPage

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
/**
 * Called to forward to the error page
 * 
 * @param request Request we are processing
 * @param response Response we are creating
 * @param config    Login configuration describing how authentication
 *              should be performed
 */
protected void forwardToErrorPage(Request request, Response response, LoginConfig config) {
    RequestDispatcher disp =
        context.getServletContext().getRequestDispatcher
        (config.getErrorPage());
    try {
        disp.forward(request.getRequest(), response.getResponse());
    } catch (Throwable t) {
        log.warn("Unexpected error forwarding to error page", t);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:19,代碼來源:FormAuthenticator.java

示例10: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	HttpSession session=request.getSession();
	RequestDispatcher rs;
	try{
		int patientId = (int)session.getAttribute("UserID");
		if(patientId>0)
		{
			DatabaseHelper databaseHelper = new DatabaseHelper();
			Patient patient = databaseHelper.getPatient(patientId);
			ArrayList<ArrayList<Appointment>> appointments = databaseHelper.getAppointments(patientId, "patientId");
			if(patient!=null && appointments!=null)
			{
				rs = request.getRequestDispatcher("bookAppointment.jsp");
				request.setAttribute("patient", patient);
				request.setAttribute("appointments", appointments);
				rs.forward(request, response);
			}else
			{
				//redirect to login
				redirectToLogin(request,response);
			}
		}else
		{
			//redirect to login
			redirectToLogin(request,response);
		}
	}catch(Exception e){
		e.printStackTrace();
		//redirect to login
		redirectToLogin(request,response);
		
	}
}
 
開發者ID:jainkuniya,項目名稱:central-medic-center,代碼行數:37,代碼來源:OpenBookAppointment.java

示例11: doPost

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	HttpSession session = request.getSession();
	String email = request.getParameter("email");
	String password = request.getParameter("password");
	Utilisateur user = utilisateurService.connexion(email, password);
	if(user != null) {
		session.setAttribute("user", user);
		response.sendRedirect(response.encodeRedirectURL("./admin/home"));			
	} else {
		request.setAttribute("erreur", "Email ou mot de passe incorect");
		RequestDispatcher dispatcher = request.getRequestDispatcher("/WEB-INF/views/login.jsp");
		dispatcher.forward(request, response);
	}
}
 
開發者ID:DTAFormation,項目名稱:112016.pizzeria-app,代碼行數:16,代碼來源:LoginController.java

示例12: handleHome

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
private void handleHome(HttpServletRequest request,
		HttpServletResponse response) throws ServletException, IOException {

	RequestDispatcher requestDispatcher = request
			.getRequestDispatcher("bankhomepage.jsp");
	requestDispatcher.forward(request, response);

}
 
開發者ID:Illusionist80,項目名稱:SpringTutorial,代碼行數:9,代碼來源:ControllerServlet.java

示例13: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HttpSession sessao = request.getSession(false);
    if (sessao != null && sessao.getAttribute("usuario") != null) {
        response.sendRedirect(request.getContextPath() + "/inicio");
        return;
    }

    RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/login.jsp");
    dispatcher.forward(request, response);
}
 
開發者ID:ArtCouSan,項目名稱:Projeto_Integrador_3_Semestre,代碼行數:12,代碼來源:LoginServlet.java

示例14: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

      RequestDispatcher dispatcher
 = request.getRequestDispatcher("/cadastroProduto.jsp");
    dispatcher.forward(request, response);

}
 
開發者ID:Dinossaura,項目名稱:LojaDeInstrumentosMusicais,代碼行數:10,代碼來源:CadastrarProdutoServlet.java

示例15: doGet

import javax.servlet.RequestDispatcher; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    RequestDispatcher rd = req.getRequestDispatcher(dispatchPath);
    if (rd == null) {
        resp.setContentType("text/plain");
        resp.setCharacterEncoding("UTF-8");
        resp.getWriter().print(NULL);
    } else {
        rd.forward(req, resp);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:14,代碼來源:TestApplicationContextGetRequestDispatcher.java


注:本文中的javax.servlet.RequestDispatcher.forward方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。