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


Java HttpServletRequest.getRequestDispatcher方法代碼示例

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


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

示例1: doGet

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

    HttpSession sessao = request.getSession();
    ArrayList<Produto> Lista = new ArrayList();
    ServicoProduto sc = new ServicoProduto();
    String codigoempresa = (String) sessao.getAttribute("Empresa");

    try {
        Lista = (ArrayList<Produto>) sc.procurarProduto(codigoempresa, Integer.parseInt(codigoempresa));
    } catch (Exception e) {

    }

    sessao.setAttribute("ListaProduto", Lista);

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

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

示例2: editar

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

        CategoriaBO categoriaBO = new CategoriaBO();
        Categoria categoria = categoriaBO.selecionar(id);

        request.setAttribute("categoria", categoria);

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

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

示例3: doPost

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	
	// get the data
		String name = request.getParameter("name");
		String title = request.getParameter("title");
		String credits = request.getParameter("credits"); 
		String division= request.getParameter("division");
		
		
		
		// set up a Course object
		Course course = new Course(name, title, credits, division);
		
		// set up an addQuery object
		AddQuery aq = new AddQuery("chemistrydatabase", "root", "root");   //Removed password for security reasons
		
		// pass the Course to addQuery to add to the database
		aq.doAddCourse(course);
		
		// pass the execution control to the ReadServlet
		String url = "/CourseServlet";
		
		RequestDispatcher dispatcher = request.getRequestDispatcher(url);
		dispatcher.forward(request, response);
}
 
開發者ID:theBusBoy,項目名稱:ChemistryAdministrativePortal,代碼行數:29,代碼來源:AddCourseServlet.java

示例4: cadastrar

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * Cadastra uma atividade no banco de dados
 * @param request
 * @param response
 * @throws Exception
 */
private void cadastrar(HttpServletRequest request, HttpServletResponse response) throws Exception{
    TiposAtividades tiposAtividades = new TiposAtividades ();

    if (!"".equals(request.getParameter("id").trim())){
        tiposAtividades.setId(Integer.parseInt(request.getParameter("id")));
    }

    tiposAtividades.setNome(request.getParameter("nome"));
    

    request.setAttribute("nome", tiposAtividades);

    if (tiposAtividades.getId() == null){
        this.inserir(tiposAtividades, request, response);
    } else {
        this.alterar(tiposAtividades, request, response);
    }
    
    RequestDispatcher rd = request.getRequestDispatcher("paginas/tiposAtividades.jsp");
    rd.forward(request, response);
}
 
開發者ID:Ronneesley,項目名稱:redesocial,代碼行數:28,代碼來源:TiposAtividadesControle.java

示例5: cadastrar

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void cadastrar(HttpServletRequest request, HttpServletResponse response) throws Exception{
    Artigo artigo = new Artigo();

    if (!"".equals(request.getParameter("id").trim())){
        artigo.setId(Integer.parseInt(request.getParameter("id")));
    }

    artigo.setIdioma(request.getParameter("idioma"));
    artigo.setRevista(request.getParameter("revista"));
    artigo.setISSN(request.getParameter("issn"));
    
    artigo.setData(new Date());
    
    artigo.setAreaConhecimento(request.getParameter("area_conhecimento"));
    artigo.setTitulo(request.getParameter("titulo"));
    artigo.setResumo(request.getParameter("resumo"));
    artigo.setURL(request.getParameter("url"));
    artigo.setArtigo(new byte[]{});
    
    int idCategoria = Integer.parseInt( request.getParameter("categoria") );
    CategoriaBO categoriaBO = new CategoriaBO();
    Categoria categoria = categoriaBO.selecionar(idCategoria);
    artigo.setCategoria(categoria);

    request.setAttribute("artigo", artigo);
    
    List categorias = categoriaBO.listar();            
    request.setAttribute("categorias", categorias);

    if (artigo.getId() == null){
        this.inserir(artigo, request, response);
    } else {
        this.alterar(artigo, request, response);
    }

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

示例6: doGet

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	 String path = request.getParameter("jsp");
	 String switchPath="LogIn.jsp";
	/* switch(path) {
	 case ("welcome.jsp"): switchPath=path;
	 case (""):
	//this change is done by Daniel, sorry if I ruined something, trying to increase security 
	 }*/
	 RequestDispatcher req=request.getRequestDispatcher("Home.jsp");
	 req.forward(request, response);	   
}
 
開發者ID:shalomweiss,項目名稱:mm-system-2017,代碼行數:15,代碼來源:ForwardPath.java

示例7: doGet

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

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

示例8: doPost

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

    HotelService service = new HotelService();
    HotelDAO dao = new HotelDAO();

    RelatorioDAO relatorioDAO = new RelatorioDAO();
    RelatorioMudancas relatorio = new RelatorioMudancas();

    String nome_hotel = request.getParameter("nome_hotel");
    String data_entrada = request.getParameter("data_entrada");
    String data_saida = request.getParameter("data_saida");
    int quantidade_quartos = Integer.parseInt(request.getParameter("quantidade_quartos"));
    int quantidade_hospedes = Integer.parseInt(request.getParameter("quantidade_hospedes"));
    float preco = Float.parseFloat(request.getParameter("preco"));

    request.setAttribute("erroNome_hotel", service.validaNome(nome_hotel));
    request.setAttribute("erroData_entrada", service.validaEntrada(data_entrada));
    request.setAttribute("erroData_saida", service.validaSaida(data_saida));
    request.setAttribute("erroQuantidade_quartos", service.validaQuantidade_quartos(quantidade_quartos));
    request.setAttribute("erroQuantidade_hospedes", service.validaQuantidade_hospedes(quantidade_hospedes));
    request.setAttribute("erroPreco", service.validaPreco(preco));

    Hotel hotel = new Hotel(nome_hotel.trim(), data_entrada.trim(), data_saida.trim(),
            quantidade_quartos, quantidade_hospedes, preco, true);

    if (service.validaHotel(nome_hotel, quantidade_quartos, data_entrada, data_saida, quantidade_hospedes, preco)) {
        RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/CadastroHotel.jsp");
        dispatcher.forward(request, response);
    } else {
        try {

            dao.inserir(hotel);
            HttpSession sessao = request.getSession();
            int identificacaoF = (int) sessao.getAttribute("id_func");
            relatorio.setId_func(identificacaoF);
            relatorio.setMudanca("Cadastro de hotel efetuado!");
            relatorioDAO.inserir(relatorio);
            response.sendRedirect(request.getContextPath() + "/inicio");

        } catch (Exception ex) {

            Logger.getLogger(CadastroHotelServlet.class.getName()).log(Level.SEVERE, null, ex);

        }
    }
}
 
開發者ID:ArtCouSan,項目名稱:Projeto_Integrador_3_Semestre,代碼行數:49,代碼來源:CadastroHotelServlet.java

示例9: doGet

import javax.servlet.http.HttpServletRequest; //導入方法依賴的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,代碼行數:8,代碼來源:AlterarProdutoServlet.java

示例10: doPost

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

	HttpSession session;
	session = request.getSession();
	if (session.isNew()) {
		redirectToLogin(request, response);
	} else {
		Patient patient = new DatabaseHelper().getPatient((int) session.getAttribute("UserID"));
		Appointment appointment = new Appointment(patient, (String) request.getParameter("symptons"),
				(String) request.getParameter("disease"),
				DateUtils.getLongFromDate((String) request.getParameter("preferredDate")),
				(String)request.getParameter("title"));


		// insert in DB
		int status = new DatabaseHelper().createAppointment(appointment);
		if (status > 0) {
			// successfully inserted
			// redirect to patient dashboard
			RequestDispatcher rs;
			rs = request.getRequestDispatcher("patient");
			request.setAttribute("personId", appointment.getPatient().getId());
			rs.forward(request, response);
		} else {
			// error 
			//redirect to login
			redirectToLogin(request, response);
		}
	}
}
 
開發者ID:jainkuniya,項目名稱:central-medic-center,代碼行數:36,代碼來源:BookAppointment.java

示例11: doGet

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
	
	Integer id = Integer.parseInt(req.getParameter("id"));
	Client c = clientService.retrieveClient(id);
	req.setAttribute("client", c);

	RequestDispatcher dispatcher = req.getRequestDispatcher(VUE_UPDATE_CLIENT);
	dispatcher.forward(req, resp);

}
 
開發者ID:DTAFormation,項目名稱:112016.pizzeria-app,代碼行數:12,代碼來源:UpdateClientController.java

示例12: redirectToLogin

import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private void redirectToLogin(HttpServletRequest request, HttpServletResponse response)
		throws ServletException, IOException {
	RequestDispatcher rs = request.getRequestDispatcher("login.jsp");
	request.setAttribute("error", "Please login again");
	rs.forward(request, response);
}
 
開發者ID:jainkuniya,項目名稱:central-medic-center,代碼行數:7,代碼來源:CloseAppointment.java

示例13: processRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的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");
    RequestDispatcher rd = request.getRequestDispatcher("JSP/RessurserM12.jsp");
        rd.include(request, response);    
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:16,代碼來源:RessurserM12.java

示例14: processRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的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");
    RequestDispatcher rd = request.getRequestDispatcher("JSP/RessurserM2.jsp");
        rd.include(request, response);    
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:16,代碼來源:RessurserM2.java

示例15: processRequest

import javax.servlet.http.HttpServletRequest; //導入方法依賴的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/DeleteUser.jsp");
            rd.forward(request, response);
    }
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:18,代碼來源:DeleteUser.java


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