List of usage examples for javax.servlet.http HttpServletRequest getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path);
From source file:com.example.getstarted.basicactions.CreateBookServlet.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setAttribute("action", "Add"); // Part of the Header in form.jsp req.setAttribute("destination", "create"); // The urlPattern to invoke (this Servlet) req.setAttribute("page", "form"); // Tells base.jsp to include form.jsp req.getRequestDispatcher("/base.jsp").forward(req, resp); }
From source file:eionet.cr.web.action.TabularDataServlet.java
/** * * @param message/*from ww w . j av a 2 s . co m*/ * @param request * @param response * @throws ServletException * @throws IOException */ private void handleFileNotFound(String message, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.info(message); if (Util.isWebBrowser(request)) { request.setAttribute(StripesExceptionHandler.EXCEPTION_ATTR, new CRException(message)); request.getRequestDispatcher(StripesExceptionHandler.ERROR_PAGE).forward(request, response); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:de.egore911.reader.servlets.OpmlImportServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { User user = getUserOrRedirect(resp); if (user == null) { return;//ww w. ja v a 2 s. c o m } prepareTree(req, user); req.getRequestDispatcher("/import.jsp").forward(req, resp); }
From source file:br.org.indt.ndg.servlets.OpenRosaManagement.java
private void dispatchExportResultsForUserPage(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String[] userList = m_openRosaBD.getUserList(); request.setAttribute(USER_IMEI_LIST_ATTR, userList); request.setAttribute(EXPORT_RESULTS_FOR_USER, "export"); request.getRequestDispatcher(FORWARD_FILEPATH).forward(request, response); }
From source file:com.ci6225.marketzone.servlet.seller.ViewProductListServlet.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/*from w w w . j a va 2 s .co m*/ */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { User user = (User) request.getSession().getAttribute("user"); List<Product> productList = productBean.getProductList(user.getUserId()); request.setAttribute("productList", productList); RequestDispatcher rd = request.getRequestDispatcher("./jsp/seller/product_list.jsp"); rd.forward(request, response); } catch (Exception e) { e.printStackTrace(); response.sendRedirect("./"); } }
From source file:TripServlet.java
/** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> * methods.//from w w w.jav a2 s. c o m * * @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"); PrintWriter out = response.getWriter(); try { request.getRequestDispatcher("trips.jsp").forward(request, response); } finally { out.close(); } }
From source file:io.github.benas.todolist.web.servlet.todo.DeleteTodoServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final String id = request.getParameter("todoId"); try {/* ww w.j a v a2 s .c o m*/ long todoId = Long.parseLong(id); Todo todo = todoService.getTodoById(todoId); if (todo != null) { todoService.remove(todo); request.getRequestDispatcher("/todos").forward(request, response); } else { redirectToErrorPage(request, response, id); } } catch (NumberFormatException e) { redirectToErrorPage(request, response, id); } }
From source file:TripServlet.java
void gohome(HttpServletRequest request, HttpServletResponse response) { try {//from ww w . j a v a2 s . c o m JSONObject obj; obj = DataClass.getJSONObject(URLsClass.gettrips, ""); getTripsData(obj); request.setAttribute("trips", alltrips); request.getRequestDispatcher("trips.jsp").forward(request, response);//show only } catch (Exception ex) { Logger.getLogger(TripServlet.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:duoc.cl.dej4501.DejMobile.Presentacion.RegistrarClienteServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession sesion = request.getSession(); String rut = request.getParameter("txtRut"); if (objClienteSessionBeans.validarRut(rut) == false) { sesion.setAttribute("rutInvalidoMsg", "Rut ingresado no es valido"); request.getRequestDispatcher("./RegistroCliente.jsp").forward(request, response); }//from w w w .ja v a 2s . c om if (objClienteSessionBeans.buscaUsuarioXRut(rut) != null) { sesion.setAttribute("rutInvalidoMsg", "Rut ingresado ya se encuentra en el sistema"); request.getRequestDispatcher("./RegistroCliente.jsp").forward(request, response); } String clave = DigestUtils.md5Hex(request.getParameter("txtClave")); String confirmarClave = DigestUtils.md5Hex(request.getParameter("txtConfirmarClave")); if (clave.equals(confirmarClave) == false) { sesion.setAttribute("claveInvalidaMsg", "Password invalida"); response.sendRedirect("RegistroCliente.jsp"); } String nombre = request.getParameter("txtNombre"); String apellidoPaterno = request.getParameter("txtApellidoPaterno"); String apellidoMaterno = request.getParameter("txtApellidoMaterno"); String direccion = request.getParameter("txtDireccion"); int numeracion = Integer.parseInt(request.getParameter("txtNumeracion")); int comuna = Integer.parseInt(request.getParameter("ddlComuna")); int telefono = Integer.parseInt(request.getParameter("txtTelefono")); ClienteDTO infoClienteDTO = new ClienteDTO(rut, clave, nombre, apellidoPaterno, apellidoMaterno, direccion, numeracion, comuna, telefono); try { objClienteSessionBeans.addCliente(infoClienteDTO); sesion.setAttribute("msgCorrecto", "Cliente Ingresado de forma correcta"); response.sendRedirect("Login.jsp"); } catch (Exception ex) { sesion.setAttribute("msgError", "Cliente no pudo ingresar a la base de datos"); response.sendRedirect("RegistroCliente.jsp"); } }
From source file:org.myjerry.evenstar.web.controller.PageNotFoundController.java
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { // extract the request URI // and check to see if this is a blog page URL // if yes - go ahead and display the page String uri = request.getRequestURI(); BlogPost post = this.blogPostService.getPostForURI(uri); if (post != null) { RequestDispatcher dispatcher = request.getRequestDispatcher( "/viewPost.html?postID=" + post.getPostID() + "&blogID=" + post.getBlogID()); dispatcher.forward(request, response); return null; }/* w ww.j a v a2 s . co m*/ ModelAndView mav = new ModelAndView(); mav.setViewName(".page.not.found"); return mav; }