List of usage examples for javax.servlet RequestDispatcher forward
public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException;
From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.RefactorRetryController.java
public void doGet(HttpServletRequest request, HttpServletResponse response) { if (!isAuthorizedToDisplayPage(request, response, SimplePermission.EDIT_ONTOLOGY.ACTION)) { return;/*from ww w . jav a 2s . com*/ } //create an EditProcessObject for this and put it in the session EditProcessObject epo = super.createEpo(request); VitroRequest vreq = new VitroRequest(request); String modeStr = request.getParameter("mode"); if (modeStr != null) { if (modeStr.equals("renameResource")) { doRenameResource(vreq, response, epo); } else if (modeStr.equals("movePropertyStatements")) { doMovePropertyStatements(vreq, response, epo); } else if (modeStr.equals("moveInstances")) { doMoveInstances(vreq, response, epo); } } RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP); setRequestAttributes(request, epo); try { rd.forward(request, response); } catch (Exception e) { log.error(this.getClass().getName() + " could not forward to view."); log.error(e.getMessage()); log.error(e.getStackTrace()); } }
From source file:edu.lternet.pasta.portal.MetadataPreviewerServlet.java
/** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * /*from w ww . j a va 2 s . co m*/ * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession httpSession = request.getSession(); String uid = (String) httpSession.getAttribute("uid"); String forward = "./metadataViewer.jsp"; if (uid == null || uid.isEmpty()) uid = "public"; String html = null; boolean isMultipart = ServletFileUpload.isMultipartContent(request); 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 try { List /* FileItem */ items = upload.parseRequest(request); // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (!(item.isFormField())) { String eml = processUploadedFile(item); EmlUtility emlUtility = new EmlUtility(eml); html = emlUtility.xmlToHtmlSaxon(cwd + xslpath, null); } } } catch (Exception e) { handleDataPortalError(logger, e); } } request.setAttribute("metadataHtml", html); RequestDispatcher requestDispatcher = request.getRequestDispatcher(forward); requestDispatcher.forward(request, response); }
From source file:controller.controller.java
public void dispatcher(HttpServletRequest request, HttpServletResponse response, String page) throws ServletException, IOException { RequestDispatcher rd = request.getRequestDispatcher(page); rd.forward(request, response); }
From source file:edu.lternet.pasta.portal.HarvestReportServlet.java
/** * The doPost method of the servlet. <br> * /* w w w. j av a 2 s. c om*/ * This method is called when a form has its tag value method equals to post. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { HttpSession httpSession = request.getSession(); String uid = (String) httpSession.getAttribute("uid"); String warningMessage = null; if (uid == null) { warningMessage = "<p class=\"warning\">" + LOGIN_WARNING + "</p>"; request.setAttribute("message", warningMessage); } else { String reportId = request.getParameter("reportId"); if (reportId != null && reportId.length() > 0) { httpSession.setAttribute("harvestReportID", reportId); } } if (warningMessage == null || warningMessage.length() == 0) { response.sendRedirect("./harvestReport.jsp"); } else { RequestDispatcher requestDispatcher = request.getRequestDispatcher("./harvestReport.jsp"); requestDispatcher.forward(request, response); } } catch (Exception e) { handleDataPortalError(logger, e); } }
From source file:org.apache.struts.chain.commands.servlet.PerformForward.java
private void handleAsForward(String uri, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher rd = servletContext.getRequestDispatcher(uri); if (LOG.isDebugEnabled()) { LOG.debug("Forwarding to " + uri); }//from w w w . jav a 2 s. c o m rd.forward(request, response); }
From source file:com.camel.action.base.LoginAction.java
public String doLogin() { try {/*from w ww. j ava 2 s .c om*/ /***** login iin spring security alternatif picketlink*/ ExternalContext context = FacesContext.getCurrentInstance().getExternalContext(); RequestDispatcher dispatcher = ((ServletRequest) context.getRequest()) .getRequestDispatcher("/j_spring_security_check"); dispatcher.forward((ServletRequest) context.getRequest(), (ServletResponse) context.getResponse()); FacesContext.getCurrentInstance().responseComplete(); } catch (ServletException ex) { Logger.getLogger(LoginAction.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(LoginAction.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:controller.ControlPembayaran.java
public void returnError(HttpServletRequest request, HttpServletResponse response, Exception e) throws ServletException, IOException { RequestDispatcher dispatcher; request.setAttribute("error", e.getMessage()); dispatcher = request.getRequestDispatcher("error.jsp"); dispatcher.forward(request, response); }
From source file:edu.lternet.pasta.portal.JournalCitationAddServlet.java
/** * The doPost method of the servlet. <br> * /*from ww w .j a va 2 s. c o m*/ * This method is called when a form has its tag value method equals to post. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession httpSession = request.getSession(); String uid = (String) httpSession.getAttribute("uid"); if (uid == null || uid.isEmpty()) uid = "public"; String message = null; String messageType = "info"; String createMessage = ""; String packageId = request.getParameter("packageid"); String articleDoi = request.getParameter("articledoi"); String articleUrl = request.getParameter("articleurl"); String articleTitle = request.getParameter("articletitle"); String journalTitle = request.getParameter("journaltitle"); /* * Check for valid input */ String inputMessage = validateInput(packageId, articleDoi, articleUrl, articleTitle, journalTitle); JournalCitation journalCitation = new JournalCitation(); journalCitation.setPackageId(packageId); journalCitation.setArticleDoi(articleDoi); journalCitation.setArticleUrl(articleUrl); journalCitation.setArticleTitle(articleTitle); journalCitation.setJournalTitle(journalTitle); boolean includeDeclaration = true; String journalCitationXML = journalCitation.toXML(includeDeclaration); if (uid.equals("public")) { message = LOGIN_WARNING; messageType = "warning"; request.setAttribute("message", message); } else if (inputMessage != null && !inputMessage.isEmpty()) { createMessage = inputMessage; messageType = "input-error"; } else { try { JournalCitationsClient journalCitationsClient = new JournalCitationsClient(uid); Integer journalCitationId = journalCitationsClient.create(journalCitationXML); String mapbrowseUrl = MapBrowseServlet.getRelativeURL(packageId); String mapbrowseHTML = String.format("<a class='searchsubcat' href='%s'>%s</a>", mapbrowseUrl, packageId); createMessage = String.format( "A journal citation entry with identifier '<strong>%d</strong>' was created for data package %s", journalCitationId, mapbrowseHTML); } catch (Exception e) { handleDataPortalError(logger, e); } } request.setAttribute("createMessage", createMessage); request.setAttribute("messageType", messageType); RequestDispatcher requestDispatcher = request.getRequestDispatcher(forward); requestDispatcher.forward(request, response); }
From source file:com.mkmeier.quickerbooks.ProcessUwcu.java
private void showForm(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { Map<String, List<QbAccount>> accountLists = getAccountLists(); HttpSession session = request.getSession(true); session.setAttribute("lists", accountLists); RequestDispatcher rd = request.getRequestDispatcher("UwcuProcessor.jsp"); rd.forward(request, response); }
From source file:com.sun.socialsite.web.rest.servlets.ImageServlet.java
/** * Handles the HTTP <code>GET</code> method. * @param req servlet request// w ww .ja v a 2 s. c o m * @param resp servlet response */ @Override protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String itemName = ((req.getPathInfo() != null) ? req.getPathInfo().substring(1) : null); if (itemName != null) itemName = URLDecoder.decode(itemName, "UTF-8"); Result result = getResult(itemName); if ((result == null) || (result.imageType == null) || (result.imageType.equals(""))) { RequestDispatcher rd = req.getRequestDispatcher(defaultImage); rd.forward(req, resp); return; } long ifModifiedTime = 0L; if (req.getHeader("If-Modified-Since") != null) { try { ifModifiedTime = getDateFormat().parse(req.getHeader("If-Modified-Since")).getTime(); } catch (Throwable intentionallyIgnored) { } } // We've got an EHCache GenericResponseWrapper, it ignores date headers //resp.setDateHeader("Last-Modified", lastModifiedString); resp.setHeader("Last-Modified", getDateFormat().format(result.lastUpdate)); resp.setHeader("ETag", result.eTag); // Force clients to revalidate each time // See RFC 2616 (HTTP 1.1 spec) secs 14.21, 13.2.1 // We've got an EHCache GenericResponseWrapper, it ignores date headers //resp.setDateHeader("Expires", 0); resp.setHeader("Expires", epoch); // We may also want this (See 13.2.1 and 14.9.4) // response.setHeader("Cache-Control","must-revalidate"); if (result.lastUpdate.getTime() > ifModifiedTime || !handleConditionalGets) { resp.setContentType(result.imageType); resp.setContentLength(result.imageBytes.length); OutputStream out = resp.getOutputStream(); out.write(result.imageBytes, 0, result.imageBytes.length); out.close(); } else { resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED); } return; }