List of usage examples for javax.servlet RequestDispatcher forward
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;
From source file:m.c.m.proxyma.ProxymaConsoleServlet.java
/** * Utility method to forward the flow to a jsp.. * * @param httpservletrequest the request * @param httpservletresponse the response * @param page the page to forward * @param proxymaInstanceContext the proxymaContextPath *//*from w w w . j a v a 2s . co m*/ private void forwardToJsp(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse, String page, ProxymaContext context) throws IOException, ServletException { httpservletrequest.setAttribute(GlobalConstants.CONTEXT_REQUEST_ATTRIBUTE, context); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(page); dispatcher.forward(httpservletrequest, httpservletresponse); }
From source file:de.iteratec.turm.servlets.TurmServlet.java
@Override protected final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.debug("============================== GET REQUEST =============================="); logRequestParameters(request);//from ww w. ja v a 2s . c o m setAndStoreCurrentLocale(request); storeServletPath(request); try { doTurmGet(request); } catch (TurmException e) { saveErrors(e, request); } catch (Exception e) { saveErrors(new TurmException("error.internalError", e), request); } RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(getJsp()); dispatcher.forward(request, response); }
From source file:de.iteratec.turm.servlets.TurmServlet.java
@Override protected final void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOGGER.debug("============================== POST REQUEST =============================="); logRequestParameters(request);//from www .ja va 2 s . co m setAndStoreCurrentLocale(request); storeServletPath(request); try { doTurmPost(request); } catch (TurmException e) { saveErrors(e, request); } catch (Exception e) { saveErrors(new TurmException("error.internalError", e), request); } RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(getJsp()); dispatcher.forward(request, response); }
From source file:com.squid.kraken.v4.auth.LostServlet.java
/** * Display the input screen./*from w w w . j a v a 2s . c o m*/ * * @param request * @param response * @throws ServletException * @throws IOException */ private void show(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher rd; request.setAttribute(CUSTOMER_ID, request.getParameter(CUSTOMER_ID)); request.setAttribute(CLIENT_ID, KrakenClientConfig.get("signin.default.clientid", "admin_console")); rd = getServletContext().getRequestDispatcher(LOST_JSP); rd.forward(request, response); }
From source file:com.gisgraphy.webapp.filter.StaticFilter.java
/** * This method checks to see if the current path matches includes or * excludes. If it matches includes and not excludes, it forwards to the * static resource and ends the filter chain. Otherwise, it forwards to the * next filter in the chain.//from w ww. j av a 2s. co m * * @param request * the current request * @param response * the current response * @param chain * the filter chain * @throws ServletException * when something goes wrong * @throws IOException * when something goes terribly wrong */ @Override public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { UrlPathHelper urlPathHelper = new UrlPathHelper(); String path = urlPathHelper.getPathWithinApplication(request); boolean pathExcluded = PatternMatchUtils.simpleMatch(excludes, path); boolean pathIncluded = PatternMatchUtils.simpleMatch(includes, path); if (pathIncluded && !pathExcluded) { if (logger.isDebugEnabled()) { logger.debug("Forwarding to static resource: " + path); } if (path.contains(".html")) { response.setContentType("text/html"); } RequestDispatcher rd = getServletContext().getRequestDispatcher(path); rd.include(request, response); return; } if (servletName != null) { RequestDispatcher rd = getServletContext().getNamedDispatcher(servletName); rd.forward(request, response); return; } chain.doFilter(request, response); }
From source file:net.sourceforge.hunterj.javadocViewer.JavadocViewerServlet.java
/** * // w ww . j a v a 2s .c om * @param request * @param response * @throws IOException * @throws ServletException */ private void dispatchToView(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); request.setAttribute(JVConst.DOCHOME_ATTR.value, session.getAttribute(JVConst.DOCHOME_ATTR.value)); String docHomeOpts = (String) request.getSession().getAttribute(JVConst.DOCHOME_OPTS.value); if (docHomeOpts == null) { docHomeOpts = this.getJavadocHomeOpts(Paths.get(this.saveFilePathStr)); session.setAttribute(JVConst.DOCHOME_OPTS.value, docHomeOpts); } request.setAttribute(JVConst.DOCHOME_OPTS.value, docHomeOpts); RequestDispatcher dispatch = request.getRequestDispatcher(response.encodeURL(JVConst.MAIN_JSP.value)); dispatch.forward(request, response); }
From source file:RestrictedService.java
/** * When the servlet receives a GET request. *///w ww . ja v a 2s .c om protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher view = request.getRequestDispatcher(SERVICE_JSP); view.forward(request, response); }
From source file:com.pureinfo.tgirls.sns.servlet.SNSEntryServlet.java
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { logger.debug("tgirls sns entry."); String taobaoUserId = null;/*w ww .j a va 2 s . c om*/ String taobaoUserName = null; String topSession = request.getParameter(APPConstants.REQ_PARAMETER_SESSION); String topParameters = request.getParameter(APPConstants.REQ_PARAMETER_PARAMETERS); String topSign = request.getParameter(APPConstants.REQ_PARAMETER_SIGN); TipBean tb = null; try { tb = TipUtil.beforeFetch(topSession, topParameters, topSign, APPConstants.SECRET); if (!tb.isOk()) { logger.error("top api failed." + tb.getErrMsg()); throw new Exception("TOP API failed:" + tb.getErrMsg()); } taobaoUserId = tb.getUserId() + ""; taobaoUserName = tb.getUserNick(); logger.debug("id:" + taobaoUserId); logger.debug("name:" + taobaoUserName); logger.debug("session:" + topSession); if ("0".equals(taobaoUserId) || StringUtils.isEmpty(taobaoUserId) || StringUtils.isEmpty(taobaoUserName)) { throw new Exception("parameter empty."); } } catch (Exception e) { logger.error("error when call top API.", e); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "top system error." + e.getMessage()); return; } HttpSession session = request.getSession(true); session.removeAttribute(ArkHelper.ATTR_LOGIN_USER); User loginUser = null;//(User) session.getAttribute(ArkHelper.ATTR_LOGIN_USER); //loginUser = CookieUtils.getLoginUser(request, response); if (loginUser != null && loginUser.getTaobaoID().equals(taobaoUserId)) { logger.debug("user " + taobaoUserId + " already logined."); } else { try { userMgr = (IUserMgr) ArkContentHelper.getContentMgrOf(User.class); if (!userMgr.isUserExists(taobaoUserId)) { loginUser = createUser(taobaoUserId, topSession); //ScriptWriteUtils.reBuildUserInfoScript(loginUser); try { //ScriptWriteUtils.reBuildUserBuyPhotosScript(loginUser); //ScriptWriteUtils.reBuildUserUploadPhotosScript(loginUser); } catch (Exception e) { logger.error("error when rebuild buy and upload scripts.", e); } } else { loginUser = userMgr.getUserByTaobaoId(taobaoUserId); } } catch (PureException e) { logger.error("tgirls system error.", e); response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "tgirls system error." + e.getMessage()); return; } catch (NumberFormatException e) { logger.error("number format error.", e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); return; } catch (TaobaoApiException e) { logger.error("top system error.", e); response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "top system error." + e.getMessage()); return; } } if (loginUser == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "can not find current user."); return; } if (loginUser.getFunds() <= UserConstants.DISUSE_FUNDS || loginUser.getAssets() <= UserConstants.DISUSE_ASSETS) { response.sendRedirect(request.getContextPath() + "/disable.html"); return; } updateUserHeadImg(loginUser, topSession); session.setAttribute(ArkHelper.ATTR_LOGIN_USER, loginUser); session.setAttribute(SessionConstants.TAOBAO_SESSION_ID, topSession); LocalContextHelper.setAttribute(SessionConstants.TAOBAO_SESSION_ID, topSession); addCookie(loginUser, request, response); // System.out.println("========================"); // // // Cookie[] cs = request.getCookies(); // for (int i = 0; i < cs.length; i++) { // Cookie c = cs[i]; // System.out.println("cookie[" + c.getName() + "]:" + c.getValue()); // } // RequestDispatcher rd = request.getRequestDispatcher("/index.html"); rd.forward(request, response); //response.sendRedirect(request.getContextPath()); return; }
From source file:com.silverpeas.authentication.AuthenticationServlet.java
/** * Centralization./*from w w w. j a v a 2 s . c om*/ * * @param request * @param response * @param destination */ private void forward(HttpServletRequest request, HttpServletResponse response, String destination) throws ServletException, IOException { RequestDispatcher dispatcher = request.getRequestDispatcher(destination); dispatcher.forward(request, response); }