本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}