List of usage examples for javax.servlet.http HttpServletResponse addDateHeader
public void addDateHeader(String name, long date);
From source file:org.localmatters.lesscss4j.servlet.LessCssServlet.java
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String clearCache = request.getParameter(CLEAR_CACHE); if (clearCache != null && clearCache.equals("true")) { clearCache();/*from w w w. j a v a 2 s. c o m*/ } final String resource = getRequestedResource(request); if (resource == null || resource.trim().length() == 0) { response.sendError(HttpServletResponse.SC_NOT_FOUND); return; } final long now = getTime(); CacheEntry cacheEntry = getCacheEntry(resource, now); if (cacheEntry.getValue() != null) { boolean isHeadRequest = METHOD_HEAD.equalsIgnoreCase(request.getMethod()); if (isHeadRequest || isModified(request, cacheEntry)) { response.addDateHeader(LAST_MODIFIED, cacheEntry.getLastUpdate()); response.addDateHeader(EXPIRES, now + getHttpCacheMillis()); response.addHeader(CACHE_CONTROL, String.format("%s=%s", MAX_AGE, getHttpCacheMillis() / 1000)); response.setContentType("text/css; charset=UTF-8"); response.setContentLength(cacheEntry.getValue().length); if (!isHeadRequest) { IOUtils.write(cacheEntry.getValue(), response.getOutputStream()); } } else { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); } } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:org.owasp.dependencytrack.controller.DownloadController.java
/** * Service to download NIST CPE/CVE XML data files. * * @param response an HttpServletResponse object * @param filename the xml file to download * @throws java.io.IOException bad robot *///from ww w. j a va 2 s . co m @RequestMapping(value = "/nist/{filename:.+}", method = { RequestMethod.GET, RequestMethod.HEAD }) public void getNistFile(HttpServletResponse response, @PathVariable("filename") String filename) throws IOException { final File canonicalizedFile = new File(filename).getCanonicalFile(); if (!NistDataMirrorUpdater.isValidNistFile(canonicalizedFile.getName())) { response.sendError(404); } InputStream fis = null; OutputStream out = null; try { File file = new File(nistDir + File.separator + filename); fis = new FileInputStream(file); if (filename.endsWith(".gz")) { response.setHeader("Content-Type", "application/x-gzip;"); } else if (filename.endsWith(".xml")) { response.setHeader("Content-Type", "application/xml;"); } response.addDateHeader("Last-Modified", file.lastModified()); out = response.getOutputStream(); IOUtils.copy(fis, out); out.flush(); } catch (IOException ex) { LOGGER.error("Error writing NIST datafile to output stream."); throw new RuntimeException("IOError writing file to output stream"); } finally { IOUtils.closeQuietly(out); IOUtils.closeQuietly(fis); } }
From source file:org.ramadda.repository.server.RepositoryServlet.java
/** * Overriding doGet method in HttpServlet. Called by the server via the service method. * * @param request - an HttpServletRequest object that contains the request the client has made of the servlet * @param response - an HttpServletResponse object that contains the response the servlet sends to the client * * @throws IOException - if an input or output error is detected when the servlet handles the GET request * @throws ServletException - if the request for the GET could not be handled *//*from w w w. ja va 2s .c om*/ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { // there can be only one if (repository == null) { try { createRepository(request); } catch (Exception e) { logException(e, request); response.sendError(response.SC_INTERNAL_SERVER_ERROR, "Error:" + e.getMessage()); return; } } request.setCharacterEncoding("UTF-8"); response.setCharacterEncoding("UTF-8"); RequestHandler handler = new RequestHandler(request); Result repositoryResult = null; boolean isHeadRequest = request.getMethod().equals("HEAD"); try { try { // create a org.ramadda.repository.Request object from the relevant info from the HttpServletRequest object Request repositoryRequest = new Request(repository, request.getRequestURI(), handler.formArgs, request, response, this); repositoryRequest.setIp(request.getRemoteAddr()); repositoryRequest.setOutputStream(response.getOutputStream()); repositoryRequest.setFileUploads(handler.fileUploads); repositoryRequest.setHttpHeaderArgs(handler.httpArgs); // create a org.ramadda.repository.Result object and transpose the relevant info into a HttpServletResponse object repositoryResult = repository.handleRequest(repositoryRequest); if (standAloneServer != null) { //We are running stand-alone so nothing is doing logging } } catch (Throwable e) { e = LogUtil.getInnerException(e); logException(e, request); response.sendError(response.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } if (repositoryResult == null) { response.sendError(response.SC_INTERNAL_SERVER_ERROR, "Unknown request:" + request.getRequestURI()); return; } if (repositoryResult.getNeedToWrite()) { List<String> args = repositoryResult.getHttpHeaderArgs(); if (args != null) { for (int i = 0; i < args.size(); i += 2) { String name = args.get(i); String value = args.get(i + 1); response.setHeader(name, value); } } Date lastModified = repositoryResult.getLastModified(); if (lastModified != null) { response.addDateHeader("Last-Modified", lastModified.getTime()); } if (repositoryResult.getCacheOk()) { // response.setHeader("Cache-Control", // "public,max-age=259200"); response.setHeader("Expires", "Tue, 08 Jan 2020 07:41:19 GMT"); if (lastModified == null) { // response.setHeader("Last-Modified", // "Tue, 20 Jan 2010 01:45:54 GMT"); } } else { response.setHeader("Cache-Control", "no-cache"); } if (isHeadRequest) { response.setStatus(repositoryResult.getResponseCode()); return; } if (repositoryResult.getRedirectUrl() != null) { try { response.sendRedirect(repositoryResult.getRedirectUrl()); } catch (Exception e) { logException(e, request); } } else if (repositoryResult.getInputStream() != null) { try { response.setStatus(repositoryResult.getResponseCode()); response.setContentType(repositoryResult.getMimeType()); OutputStream output = response.getOutputStream(); try { // System.err.println("SLEEP"); // Misc.sleepSeconds(30); IOUtils.copy(repositoryResult.getInputStream(), output); //IOUtil.writeTo(repositoryResult.getInputStream(), // output); } finally { IOUtil.close(output); } } catch (IOException e) { //We'll ignore any ioexception } catch (Exception e) { logException(e, request); } finally { IOUtil.close(repositoryResult.getInputStream()); } } else { try { response.setStatus(repositoryResult.getResponseCode()); response.setContentType(repositoryResult.getMimeType()); OutputStream output = response.getOutputStream(); try { output.write(repositoryResult.getContent()); } catch (java.net.SocketException se) { //ignore } catch (IOException se) { //ignore } finally { IOUtil.close(output); } } catch (Exception e) { logException(e, request); } } } } finally { if ((repositoryResult != null) && (repositoryResult.getInputStream() != null)) { IOUtil.close(repositoryResult.getInputStream()); } } }
From source file:org.sakaiproject.basiclti.impl.BasicLTISecurityServiceImpl.java
private void sendHTMLPage(HttpServletResponse res, String body) { try {/* w ww . ja v a 2 s. c om*/ res.setContentType("text/html; charset=UTF-8"); res.setCharacterEncoding("utf-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); java.io.PrintWriter out = res.getWriter(); out.println( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); out.println("<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">"); out.println("<html>\n<head>"); out.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"); out.println("</head>\n<body>\n"); out.println(body); out.println("\n</body>\n</html>"); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.sakaiproject.courier.tool.CourierTool.java
/** * Send any deliveries, or at least something javascrip eval()'able. * /* ww w.j a va 2s . co m*/ * @param res * @param deliveries * The list (possibly empty) of deliveries * @throws IOException */ protected void sendDeliveries(HttpServletResponse res, List deliveries) throws IOException { res.setContentType("text/plain; charset=UTF-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); // get the writer PrintWriter out = res.getWriter(); for (Iterator i = deliveries.iterator(); i.hasNext();) { Delivery d = (Delivery) i.next(); String s = d.compose(); if (M_log.isDebugEnabled()) M_log.debug("sending delivery: " + s); out.println(s); } // make sure we send something if (deliveries.isEmpty()) { String s = "//"; if (M_log.isDebugEnabled()) M_log.debug("sending delivery: " + s); out.println(s); } }
From source file:org.sakaiproject.courier.tool.CourierTool.java
/** * Send a redirect so our "top" ends up at the url, via javascript. * /*from w ww. j a v a2s . co m*/ * @param url * The redirect url */ protected void sendTopRedirect(HttpServletResponse res, String url) throws IOException { res.setContentType("text/plain; charset=UTF-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); // get the writer PrintWriter out = res.getWriter(); // we are on deep under the main portal window out.println("parent.location.replace('" + url + "');"); }
From source file:org.sakaiproject.jsf.util.HelperAwareJsfTool.java
protected void dispatch(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // NOTE: this is a simple path dispatching, taking the path as the view id = jsp file name for the view, // with default used if no path and a path prefix as configured. // TODO: need to allow other sorts of dispatching, such as pulling out drill-down ids and making them // available to the JSF // build up the target that will be dispatched to String target = req.getPathInfo(); // see if we have a helper request if (sendToHelper(req, res, target)) { return;//from w w w .j a v a2 s .c o m } // see if we have a resource request - i.e. a path with an extension, and one that is not the JSF_EXT if (isResourceRequest(target)) { // get a dispatcher to the path RequestDispatcher resourceDispatcher = getServletContext().getRequestDispatcher(target); if (resourceDispatcher != null) { resourceDispatcher.forward(req, res); return; } } if ("Title".equals(req.getParameter("panel"))) { // This allows only one Title JSF for each tool target = "/title.jsf"; } else { ToolSession session = SessionManager.getCurrentToolSession(); if (target == null || "/".equals(target) || target.length() == 0) { if (!m_defaultToLastView) { // make sure tool session is clean session.clearAttributes(); } target = computeDefaultTarget(); // make sure it's a valid path if (!target.startsWith("/")) { target = "/" + target; } // now that we've messed with the URL, send a redirect to make it official res.sendRedirect(Web.returnUrl(req, target)); return; } // see if we want to change the specifically requested view String newTarget = redirectRequestedTarget(target); // make sure it's a valid path if (!newTarget.startsWith("/")) { newTarget = "/" + newTarget; } if (!newTarget.equals(target)) { // now that we've messed with the URL, send a redirect to make it official res.sendRedirect(Web.returnUrl(req, newTarget)); return; } target = newTarget; // store this session.setAttribute(LAST_VIEW_VISITED, target); } // add the configured folder root and extension (if missing) target = m_path + target; // add the default JSF extension (if we have no extension) int lastSlash = target.lastIndexOf("/"); int lastDot = target.lastIndexOf("."); if (lastDot < 0 || lastDot < lastSlash) { target += JSF_EXT; } // set the information that can be removed from return URLs req.setAttribute(URL_PATH, m_path); req.setAttribute(URL_EXT, JSF_FACELETS_EXT); // set the sakai request object wrappers to provide the native, not Sakai set up, URL information // - this assures that the FacesServlet can dispatch to the proper view based on the path info req.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL); // TODO: Should setting the HTTP headers be moved up to the portal level as well? res.setContentType("text/html; charset=UTF-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); // dispatch to the target M_log.debug("dispatching path: " + req.getPathInfo() + " to: " + target + " context: " + getServletContext().getServletContextName()); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(target); dispatcher.forward(req, res); // restore the request object req.removeAttribute(Tool.NATIVE_URL); req.removeAttribute(URL_PATH); req.removeAttribute(URL_EXT); }
From source file:org.sakaiproject.jsf.util.JsfTool.java
/** * Respond to requests./* ww w . ja v a 2 s. c om*/ * * @param req * The servlet request. * @param res * The servlet response. * @throws ServletException. * @throws IOException. */ protected void dispatch(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // NOTE: this is a simple path dispatching, taking the path as the view id = jsp file name for the view, // with default used if no path and a path prefix as configured. // TODO: need to allow other sorts of dispatching, such as pulling out drill-down ids and making them // available to the JSF // build up the target that will be dispatched to String target = req.getPathInfo(); // see if we have a resource request - i.e. a path with an extension, and one that is not the JSF_EXT if (isResourceRequest(target)) { // get a dispatcher to the path RequestDispatcher resourceDispatcher = getServletContext().getRequestDispatcher(target); if (resourceDispatcher != null) { resourceDispatcher.forward(req, res); return; } } if ("Title".equals(req.getParameter("panel"))) { // This allows only one Title JSF for each tool target = "/title.jsf"; } else { ToolSession session = SessionManager.getCurrentToolSession(); if (target == null || "/".equals(target)) { target = computeDefaultTarget(); // make sure it's a valid path if (!target.startsWith("/")) { target = "/" + target; } // now that we've messed with the URL, send a redirect to make it official res.sendRedirect(Web.returnUrl(req, target)); return; } // see if we want to change the specifically requested view String newTarget = redirectRequestedTarget(target); // make sure it's a valid path if (!newTarget.startsWith("/")) { newTarget = "/" + newTarget; } if (!newTarget.equals(target)) { // now that we've messed with the URL, send a redirect to make it official res.sendRedirect(Web.returnUrl(req, newTarget)); return; } target = newTarget; // store this if (m_defaultToLastView) { session.setAttribute(LAST_VIEW_VISITED, target); } } // add the configured folder root and extension (if missing) target = m_path + target; // add the default JSF extension (if we have no extension) int lastSlash = target.lastIndexOf("/"); int lastDot = target.lastIndexOf("."); if (lastDot < 0 || lastDot < lastSlash) { target += JSF_EXT; } // set the information that can be removed from return URLs req.setAttribute(URL_PATH, m_path); req.setAttribute(URL_EXT, JSF_FACELETS_EXT); // set the sakai request object wrappers to provide the native, not Sakai set up, URL information // - this assures that the FacesServlet can dispatch to the proper view based on the path info req.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL); // TODO: Should setting the HTTP headers be moved up to the portal level as well? res.setContentType("text/html; charset=UTF-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); // dispatch to the target M_log.debug("dispatching path: " + req.getPathInfo() + " to: " + target + " context: " + getServletContext().getServletContextName()); RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(target); dispatcher.forward(req, res); // restore the request object req.removeAttribute(Tool.NATIVE_URL); req.removeAttribute(URL_PATH); req.removeAttribute(URL_EXT); }
From source file:org.sakaiproject.jsf.util.SamigoJsfTool.java
protected void dispatch(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // NOTE: this is a simple path dispatching, taking the path as the view id = jsp file name for the view, // with default used if no path and a path prefix as configured. // build up the target that will be dispatched to String target = req.getPathInfo(); log.debug("***0. dispatch, target =" + target); // see if we need to reset the assessmentBean, such as when returning // from a helper // TODO: there MUST be a cleaner way to do this!! These dependencies // shouldn't be here!! if (target != null && target.startsWith(RESET_ASSESSMENT_BEAN)) { AssessmentBean assessmentBean = (AssessmentBean) ContextUtil .lookupBeanFromExternalServlet("assessmentBean", req, res); if (assessmentBean != null && assessmentBean.getAssessmentId() != null) { AssessmentIfc assessment;/*from w w w . j av a 2 s.c om*/ AuthorBean author = (AuthorBean) ContextUtil.lookupBean("author"); AssessmentService assessmentService; if (author.getIsEditPendingAssessmentFlow()) { assessmentService = new AssessmentService(); } else { assessmentService = new PublishedAssessmentService(); } assessment = assessmentService.getAssessment(Long.valueOf(assessmentBean.getAssessmentId())); assessmentBean.setAssessment(assessment); } target = target.replaceFirst(RESET_ASSESSMENT_BEAN, ""); } // see if this is a helper trying to return to caller if (HELPER_RETURN_NOTIFICATION.equals(target)) { ToolSession session = SessionManager.getCurrentToolSession(); target = (String) session.getAttribute(ToolManager.getCurrentTool().getId() + Tool.HELPER_DONE_URL); if (target != null) { session.removeAttribute(ToolManager.getCurrentTool().getId() + Tool.HELPER_DONE_URL); res.sendRedirect(target); return; } } boolean sendToHelper = sendToHelper(req, res); boolean isResourceRequest = isResourceRequest(target); log.debug("***1. dispatch, send to helper =" + sendToHelper); log.debug("***2. dispatch, isResourceRequest =" + isResourceRequest); // see if we have a helper request if (sendToHelper) { return; } if (isResourceRequest) { // get a dispatcher to the path RequestDispatcher resourceDispatcher = getServletContext().getRequestDispatcher(target); if (resourceDispatcher != null) { resourceDispatcher.forward(req, res); return; } } if (target == null || "/".equals(target)) { target = computeDefaultTarget(); // make sure it's a valid path if (!target.startsWith("/")) { target = "/" + target; } // now that we've messed with the URL, send a redirect to make it official res.sendRedirect(Web.returnUrl(req, target)); return; } // see if we want to change the specifically requested view String newTarget = redirectRequestedTarget(target); // make sure it's a valid path if (!newTarget.startsWith("/")) { newTarget = "/" + newTarget; } if (!newTarget.equals(target)) { // now that we've messed with the URL, send a redirect to make it official res.sendRedirect(Web.returnUrl(req, newTarget)); return; } target = newTarget; // store this ToolSession toolSession = SessionManager.getCurrentToolSession(); if (toolSession != null) { toolSession.setAttribute(LAST_VIEW_VISITED, target); } log.debug("3a. dispatch: toolSession=" + toolSession); log.debug("3b. dispatch: target=" + target); log.debug("3c. dispatch: lastview?" + m_defaultToLastView); // add the configured folder root and extension (if missing) target = m_path + target; // add the default JSF extension (if we have no extension) int lastSlash = target.lastIndexOf("/"); int lastDot = target.lastIndexOf("."); if (lastDot < 0 || lastDot < lastSlash) { target += JSF_EXT; } // set the information that can be removed from return URLs req.setAttribute(URL_PATH, m_path); req.setAttribute(URL_EXT, ".jsp"); // set the sakai request object wrappers to provide the native, not Sakai set up, URL information // - this assures that the FacesServlet can dispatch to the proper view based on the path info req.setAttribute(Tool.NATIVE_URL, Tool.NATIVE_URL); // TODO: Should setting the HTTP headers be moved up to the portal level as well? res.setContentType("text/html; charset=UTF-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); // dispatch to the target log.debug("***4. dispatch, dispatching path: " + req.getPathInfo() + " to: " + target + " context: " + getServletContext().getServletContextName()); // if this is a return from the file picker and going back to // case 1: item mofification, then set // itemAuthorbean.attachmentlist = filepicker list if (target.indexOf("/jsf/author/item/") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { ItemAuthorBean bean = (ItemAuthorBean) ContextUtil.lookupBeanFromExternalServlet("itemauthor", req, res); // For EMI Item Attachments AnswerBean emiQAComboItem = bean.getCurrentAnswer(); if (emiQAComboItem == null) { bean.setItemAttachment(); } else { emiQAComboItem.setItemTextAttachment(); } toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } // case 2: part mofification, then set // sectionBean.attachmentList = filepicker list else if (target.indexOf("/jsf/author/editPart") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { SectionBean bean = (SectionBean) ContextUtil.lookupBeanFromExternalServlet("sectionBean", req, res); bean.setPartAttachment(); toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } // case 3.1: assessment settings mofification, then set assessmentSettingsBean.attachmentList = filepicker list else if (target.indexOf("/jsf/author/authorSettings") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { AssessmentSettingsBean bean = (AssessmentSettingsBean) ContextUtil .lookupBeanFromExternalServlet("assessmentSettings", req, res); bean.setAssessmentAttachment(); toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } // case 3.2: published assessment settings mofification, then set assessmentSettingsBean.attachmentList = filepicker list else if (target.indexOf("/jsf/author/publishedSettings") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { PublishedAssessmentSettingsBean bean = (PublishedAssessmentSettingsBean) ContextUtil .lookupBeanFromExternalServlet("publishedSettings", req, res); bean.setAssessmentAttachment(); toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } // case 4: create new mail, then set // emailBean.attachmentList = filepicker list else if (target.indexOf("/jsf/evaluation/createNewEmail") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { EmailBean bean = (EmailBean) ContextUtil.lookupBeanFromExternalServlet("email", req, res); bean.prepareAttachment(); toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } else if (target.indexOf("/jsf/evaluation/questionScore") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { QuestionScoresBean bean = (QuestionScoresBean) ContextUtil .lookupBeanFromExternalServlet("questionScores", req, res); bean.setAttachment((Long) toolSession.getAttribute("itemGradingId")); toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } else if (target.indexOf("/jsf/evaluation/gradeStudentResult") > -1 && ("true").equals(toolSession.getAttribute("SENT_TO_FILEPICKER_HELPER"))) { ItemContentsBean bean = (ItemContentsBean) ContextUtil.lookupBeanFromExternalServlet("itemContents", req, res); bean.setAttachment((Long) toolSession.getAttribute("itemGradingId")); toolSession.removeAttribute("SENT_TO_FILEPICKER_HELPER"); } RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(target); dispatcher.forward(req, res); // restore the request object req.removeAttribute(Tool.NATIVE_URL); req.removeAttribute(URL_PATH); req.removeAttribute(URL_EXT); }
From source file:org.sakaiproject.login.tool.AuthnPortal.java
protected PrintWriter startResponse(HttpServletResponse res, String title, String skin) throws IOException { // headers/* w w w. j a v a 2 s . co m*/ res.setContentType("text/html; charset=UTF-8"); res.addDateHeader("Expires", System.currentTimeMillis() - (1000L * 60L * 60L * 24L * 365L)); res.addDateHeader("Last-Modified", System.currentTimeMillis()); res.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0"); res.addHeader("Pragma", "no-cache"); // get the writer PrintWriter out = res.getWriter(); // form the head out.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" " + "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" + "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">" + " <head>" + " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"); // pick the one full portal skin if (skin == null) skin = ServerConfigurationService.getString("skin.default"); String skinRepo = ServerConfigurationService.getString("skin.repo"); out.println(" <link href=\"" + skinRepo + "/" + skin + "/portal.css\" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />"); out.println(" <meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />" + " <title>" + title + "</title>" + " <script type=\"text/javascript\" language=\"JavaScript\" src=\"" + getScriptPath() + "headscripts.js\"></script>" + " </head>"); // start the body out.println("<body marginwidth=\"0\" marginheight=\"0\" topmargin=\"0\" leftmargin=\"0\">"); return out; }