List of usage examples for javax.servlet.http HttpServletRequest getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path);
From source file:com.mockey.ui.ServiceMergeServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setAttribute("services", Util.orderAlphabeticallyByServiceName(store.getServices())); req.setAttribute("plans", store.getServicePlans()); RequestDispatcher dispatch = req.getRequestDispatcher("service_merge.jsp"); dispatch.forward(req, resp);// w w w.j ava2 s . c o m }
From source file:com.parallax.server.blocklyprop.servlets.PasswordResetServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String token = req.getParameter("token"); String email = req.getParameter("email"); req.setAttribute("token", token == null ? "" : token); req.setAttribute("email", email == null ? "" : email); req.getRequestDispatcher("WEB-INF/servlet/password-reset/do-reset.jsp").forward(req, resp); }
From source file:com.thoughtworks.go.server.controller.ArtifactsController.java
@RequestMapping(value = "/repository/restful/artifact/GET/*", method = RequestMethod.GET) public void fetch(HttpServletRequest request, HttpServletResponse response) throws Exception { request.getRequestDispatcher("/repository/restful/artifact/GET/html").forward(request, response); }
From source file:org.sakaiproject.metaobj.shared.control.ForwardView.java
/** * Subclasses must implement this method to render the view. * <p>The first take will be preparing the request: This may include setting * the model elements as request attributes, e.g. in the case of a JSP view. * * @param model combined output Map, with dynamic values taking precedence * over static attributes * @param request current HTTP request/*from w w w .j av a 2 s . c o m*/ * @param response current HTTP response * @throws Exception if rendering failed */ protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("action", getUrl()); for (Iterator i = model.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); request.setAttribute((String) entry.getKey(), entry.getValue()); } request.getRequestDispatcher(getUrl()).forward(request, response); }
From source file:com.ci6225.marketzone.servlet.seller.ViewProductDetailServlet.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response)/* w ww . jav a 2s .c o m*/ */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { int productId = Integer.parseInt(request.getParameter("productId")); Product product = productBean.getProduct(productId); request.setAttribute("product", product); RequestDispatcher rd = request.getRequestDispatcher("./jsp/seller/update_product.jsp"); rd.forward(request, response); } catch (Exception e) { e.printStackTrace(); response.sendRedirect("./"); } }
From source file:com.parallax.server.blocklyprop.servlets.PasswordResetRequestServlet.java
public void showTextilePage(HttpServletRequest req, HttpServletResponse resp, PasswordResetPage passwordResetPage) throws ServletException, IOException { String html = textileFileReader.readFile("password-reset/" + passwordResetPage.getPage(), ServletUtils.getLocale(req), req.isSecure()); req.setAttribute("html", html); req.getRequestDispatcher("/WEB-INF/servlet/html.jsp").forward(req, resp); }
From source file:eionet.cr.web.action.TabularDataServlet.java
/** * * @param exception/*w w w .j a v a2s . com*/ * @param request * @param response * @throws ServletException * @throws IOException */ private void handleException(Exception exception, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.error(exception); if (Util.isWebBrowser(request)) { request.setAttribute(StripesExceptionHandler.EXCEPTION_ATTR, exception); request.getRequestDispatcher(StripesExceptionHandler.ERROR_PAGE).forward(request, response); } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
From source file:ccp.rtd.controllers.PrisonerReceiveController.java
protected void doService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); try {//from w ww. j ava 2s . c o m if (request.getParameter("btnSubmit") == null || request.getParameter("btnSubmit").equals(null)) { request.getRequestDispatcher("rcp/prisonerReceive.jsp").forward(request, response); } else { ProcessInstance pi = JbpmManager.getNewProcessInstance(); System.out.println( "################################################################################"); System.out.println("### Start process processInstance Id : " + pi.getId() + " Task is :" + JbpmManager.findProcessInstance(pi.getId()).getRootToken().getNode().getName()); System.out.println( "################################################################################"); String cardId = request.getParameter("txtCardId"); String isHasType = request.getParameter("chkPrisonerStaCase"); if (isHasType == null) { isHasType = "no"; } else { isHasType = "yes"; } if ("createReceiveProfile" .equals(JbpmManager.findProcessInstance(pi.getId()).getRootToken().getNode().getName())) { JbpmManager.saveVariable(pi.getId(), "cardId", cardId); JbpmManager.saveVariable(pi.getId(), "hasType", isHasType); boolean isSave = new ReceivePrisonerManager().saveReceivePrisoner( request.getParameter("txtCardId"), request.getParameter("txtCourtFName"), request.getParameter("txtCourtLName"), request.getParameter("txtLicenseFName"), request.getParameter("txtLicenseLName"), isHasType); JbpmManager.signalProcessInstance(pi.getId()); } session.setAttribute("pID", (Long) pi.getId()); session.setAttribute("cardID", cardId); if (isHasType.equals("no")) { System.out.println("go to: PrisonerInfoController"); request.getRequestDispatcher("PrisonerInfoController").forward(request, response); } else if (isHasType.equals("yes")) { System.out.println("go to: PrisonerSpecialTypeController"); request.getRequestDispatcher("PrisonerSpecialTypeController").forward(request, response); } else { request.getRequestDispatcher("rcp/rcpfailed.jsp").forward(request, response); } } } catch (Exception ex) { System.out.println("ERROR : " + ex.getMessage()); } }
From source file:de.goldbachinteractive.gbi.redirecthandler.client.Error404HandlerServlet.java
/** * if there is no redirect found, use the configured default 404 page * /*from w w w .j a v a 2s .c o m*/ * @param req * The original request. * @param resp * The original response. */ private void redirectDefault404Page(HttpServletRequest req, HttpServletResponse resp) { if (default404Page != null) { try { req.getRequestDispatcher(default404Page).forward(req, resp); } catch (Exception e) { // ensure your default 404 page is always up } } else { // you should have a default 404 page } }
From source file:com.example.appengine.UrlFetchServlet.java
@Override public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException { String id = req.getParameter("id"); String text = req.getParameter("text"); if (id == null || text == null || id == "" || text == "") { req.setAttribute("error", "invalid input"); req.getRequestDispatcher("/main.jsp").forward(req, resp); return;/* w w w . ja v a2 s .co m*/ } JSONObject jsonObj = new JSONObject().put("userId", 33).put("id", id).put("title", text).put("body", text); // [START complex] URL url = new URL("http://jsonplaceholder.typicode.com/posts/" + id); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setRequestMethod("PUT"); OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); writer.write(URLEncoder.encode(jsonObj.toString(), "UTF-8")); writer.close(); int respCode = conn.getResponseCode(); // New items get NOT_FOUND on PUT if (respCode == HttpURLConnection.HTTP_OK || respCode == HttpURLConnection.HTTP_NOT_FOUND) { req.setAttribute("error", ""); StringBuffer response = new StringBuffer(); String line; BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); while ((line = reader.readLine()) != null) { response.append(line); } reader.close(); req.setAttribute("response", response.toString()); } else { req.setAttribute("error", conn.getResponseCode() + " " + conn.getResponseMessage()); } // [END complex] req.getRequestDispatcher("/main.jsp").forward(req, resp); }