List of usage examples for javax.servlet.http HttpServletRequest getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String path);
From source file:com.ikon.servlet.admin.PropertyGroupsServlet.java
/** * Edit property groups/*from ww w.j ava 2 s .c om*/ * @throws RepositoryException * @throws ParseException */ private void edit(String pgLabel, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, DatabaseException, ParseException, RepositoryException { log.debug("edit({}, {})", new Object[] { request, response }); String pgName = "okg:" + pgLabel.toLowerCase().replace(" ", ""); List<FormElement> mData = OKMPropertyGroup.getInstance().getPropertyGroupForm(null, pgName); List<Map<String, String>> propertyMap = new ArrayList<Map<String, String>>(); for (FormElement fe : mData) { propertyMap.add(FormUtils.toString(fe)); } ServletContext sc = getServletContext(); sc.setAttribute("propertyMap", propertyMap); sc.setAttribute("pgLabel", pgLabel); request.getRequestDispatcher("/admin/property_groups_edit.jsp").forward(request, response); log.debug("edit: void"); }
From source file:edu.isi.wings.portal.classes.config.Config.java
public void showError(HttpServletRequest request, HttpServletResponse response, String message) { try {/*from w w w. j ava 2s. c om*/ response.setContentType("text/html"); request.setAttribute("message", message); request.setAttribute("nohome", true); request.getRequestDispatcher("/").forward(request, response); } catch (Exception e) { e.printStackTrace(); } }
From source file:controller.KlantController.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String forward = ""; String action = request.getParameter("action"); if (action.equalsIgnoreCase("delete")) { int idKlant = Integer.parseInt(request.getParameter("idKlant")); dao.deleteKlantById(idKlant);/* w ww . j av a 2s .c o m*/ forward = LIST_KLANT; request.setAttribute("klanten", dao.readAlleKlanten()); } else if (action.equalsIgnoreCase("edit")) { forward = INSERT_OR_EDIT; int idKlant = Integer.parseInt(request.getParameter("idKlant")); Klant klant = dao.readKlantOpId(idKlant); request.setAttribute("klant", klant); } else if (action.equalsIgnoreCase("listKlant")) { forward = LIST_KLANT; request.setAttribute("klanten", dao.readAlleKlanten()); } else { forward = INSERT_OR_EDIT; } RequestDispatcher view = request.getRequestDispatcher(forward); view.forward(request, response); }
From source file:com.sbu.controller.ServletPersonalStartupController.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response);//from w w w.j av a 2 s .co m response.setContentType("text/html;charset=UTF-8"); request.setCharacterEncoding("UTF-8"); String id = request.getParameter("id"); Startup SearchQueries = null; List<Startup> sta = startupService.getAllStartups(); List<Member1> mem = memberService.getAllMembers(); for (int i = 0; i < sta.size(); i++) { if (sta.get(i).getIdStartup() == Integer.parseInt(id)) { SearchQueries = sta.get(i); break; } } for (int i = 0; i < mem.size(); i++) { if (mem.get(i).getStartupidStartup().equals(SearchQueries)) { members.add(mem.get(i)); } } request.setAttribute("SearchQueries", SearchQueries); request.setAttribute("members", members); request.getRequestDispatcher("Personal_Startup.jsp").forward(request, response); }
From source file:com.netcracker.financeapp.controller.transaction.TransactionServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String currentOption = request.getParameter("optionListVal"); ArrayList<TransactionObject> transList = null; if (currentOption != null) { switch (currentOption) { case "Select all incomes": transList = getAllFinance(FINANCE_TYPE.INCOME); break; case "Select all spendings": transList = getAllFinance(FINANCE_TYPE.SPENDING); break; }//w w w. ja v a 2 s . c o m } ArrayList<String> optionList = new ArrayList(); optionList.add("Select all incomes"); optionList.add("Select all spendings"); String clearOption = "Select option"; request.setAttribute("clearOption", clearOption); request.setAttribute("optionList", optionList); request.setAttribute("transList", transList); request.getRequestDispatcher("transaction/transactionPage.jsp").forward(request, response); }
From source file:org.slc.sli.dashboard.security.SLIAuthenticationEntryPoint.java
private void completeAuthentication(HttpServletRequest request, HttpServletResponse response, HttpSession session, Object token, boolean cookieFound) throws ServletException, IOException { // Complete Spring security integration SLIPrincipal principal = completeSpringAuthentication((String) token); LOG.info(LOG_MESSAGE_AUTH_COMPLETED, new Object[] { principal.getName(), request.getRemoteAddr() }); // Save the cookie to support sessions across multiple dashboard servers saveCookieWithToken(request, response, (String) token); // AJAX calls OR cookie sessions should not redirect if (isAjaxRequest(request) || cookieFound) { RequestDispatcher dispatcher = request.getRequestDispatcher(request.getServletPath()); dispatcher.forward(request, response); } else {/*from w ww . ja v a2 s. com*/ LOG.info(LOG_MESSAGE_AUTH_REDIRECTING, new Object[] { principal.getName(), request.getRemoteAddr() }); response.sendRedirect(request.getRequestURI()); } }
From source file:info.magnolia.cms.util.RequestDispatchUtil.java
/** * Returns true if processing took place, even if it fails. *//*from ww w. ja v a 2 s . c o m*/ public static boolean dispatch(String targetUri, HttpServletRequest request, HttpServletResponse response) { if (targetUri == null) { return false; } if (targetUri.startsWith(REDIRECT_PREFIX)) { String redirectUrl = StringUtils.substringAfter(targetUri, REDIRECT_PREFIX); try { if (isInternal(redirectUrl)) { redirectUrl = request.getContextPath() + redirectUrl; } response.sendRedirect(response.encodeRedirectURL(redirectUrl)); } catch (IOException e) { log.error("Failed to redirect to {}:{}", targetUri, e.getMessage()); } return true; } if (targetUri.startsWith(PERMANENT_PREFIX)) { String permanentUrl = StringUtils.substringAfter(targetUri, PERMANENT_PREFIX); try { if (isInternal(permanentUrl)) { if (isUsingStandardPort(request)) { permanentUrl = new URL(request.getScheme(), request.getServerName(), request.getContextPath() + permanentUrl).toExternalForm(); } else { permanentUrl = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), request.getContextPath() + permanentUrl).toExternalForm(); } } response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); response.setHeader("Location", permanentUrl); } catch (MalformedURLException e) { log.error("Failed to create permanent url to redirect to {}:{}", targetUri, e.getMessage()); } return true; } if (targetUri.startsWith(FORWARD_PREFIX)) { String forwardUrl = StringUtils.substringAfter(targetUri, FORWARD_PREFIX); try { request.getRequestDispatcher(forwardUrl).forward(request, response); } catch (Exception e) { log.error("Failed to forward to {} - {}:{}", new Object[] { forwardUrl, ClassUtils.getShortClassName(e.getClass()), e.getMessage() }); } return true; } return false; }
From source file:com.alfaariss.oa.authentication.identifying.IdentifyingAuthenticationMethod.java
private void forwardUser(HttpServletRequest oRequest, HttpServletResponse oResponse, ISession oSession, List<Enum> warnings) throws OAException { try {// w ww . ja v a2 s .c om oRequest.setAttribute(ISession.ID_NAME, oSession.getId()); oRequest.setAttribute(ISession.LOCALE_NAME, oSession.getLocale()); if (warnings != null) { oRequest.setAttribute(DetailedUserException.DETAILS_NAME, warnings); } oRequest.setAttribute(IWebAuthenticationMethod.AUTHN_METHOD_ATTRIBUTE_NAME, _sFriendlyName); oRequest.setAttribute(Server.SERVER_ATTRIBUTE_NAME, _oaEngine.getServer()); RequestDispatcher oDispatcher = oRequest.getRequestDispatcher(_sTemplatePath); if (oDispatcher == null) { _logger.warn("There is no request dispatcher supported with name: " + _sTemplatePath); throw new OAException(SystemErrors.ERROR_INTERNAL); } _logger.debug("Forward user to: " + _sTemplatePath); oSession.persist(); oDispatcher.forward(oRequest, oResponse); } catch (OAException e) { throw e; } catch (Exception e) { if (oSession != null) _eventLogger.info(new UserEventLogItem(oSession, oRequest.getRemoteAddr(), UserEvent.INTERNAL_ERROR, this, null)); else _eventLogger.info(new UserEventLogItem(null, null, null, UserEvent.INTERNAL_ERROR, null, oRequest.getRemoteAddr(), null, this, null)); _logger.fatal("Internal error during forward", e); throw new OAException(SystemErrors.ERROR_INTERNAL); } }
From source file:cn.vlabs.umt.ui.servlet.AddClientServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String act = req.getParameter("act"); resp.setCharacterEncoding("utf-8"); if ("add".equals(act)) { addClient(req, resp);/*from w w w .j a v a 2s. co m*/ return; } else if ("clientIdUsed".equals(act)) { clientIdUsed(req, resp); return; } else if ("update".equals(act)) { updateClient(req, resp); return; } else if ("getClientInfo".equals(act)) { getClientInfo(req, resp); return; } else if ("delete".equals(act)) { deleteClient(req, resp); } else if ("refresh".equals(act)) { refreshClient(req); } req.setAttribute("clients", getAllClient()); req.getRequestDispatcher("/admin/oauthaddcliend.jsp").forward(req, resp); }
From source file:Controller.UpLoadFile.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception { response.setContentType("text/html;charset=UTF-8"); boolean isMultipart = ServletFileUpload.isMultipartContent(request); // process only if its multipart content if (isMultipart) { // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); // Parse the request List<FileItem> multiparts = upload.parseRequest(request); for (FileItem item : multiparts) { if (!item.isFormField()) { String name = new File(item.getName()).getName(); item.write(new File(UPLOAD_DIRECTORY + File.separator + name)); }/*from w w w .j a v a 2 s . co m*/ } } RequestDispatcher rd = request.getRequestDispatcher("loadimage.jsp"); rd.forward(request, response); }