List of usage examples for javax.servlet.http HttpServletRequest getContextPath
public String getContextPath();
From source file:pivotal.au.se.gemfirexdweb.controller.ReportsController.java
@RequestMapping(value = "/displayqueryreports", method = RequestMethod.GET) public String showQueryReports(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from ww w.j a v a 2s. co m Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to show all query reports"); QueryBeanReader reader = QueryBeanReader.getInstance(); List<String> qlBeanNames = Arrays.asList(reader.getQueryListBeans()); List queries = new ArrayList(); List headerNames = new ArrayList(); int i = 0; for (String beanName : qlBeanNames) { i++; QueryList ql = reader.getQueryListBean(beanName); headerNames.add(ql.getDescription()); queries.add(ql.getQueryList()); } model.addAttribute("queries", queries); model.addAttribute("headerNames", headerNames); // This will resolve to /WEB-INF/jsp/reports.jsp return "reports"; }
From source file:com.glaf.jbpm.tag.JbpmProcessImageTag.java
public int doEndTag() throws JspException { JbpmContext jbpmContext = null;//w w w. j a v a 2 s.com HttpServletRequest request = null; try { request = (HttpServletRequest) pageContext.getRequest(); contextPath = request.getContextPath(); jbpmContext = ProcessContainer.getContainer().createJbpmContext(); initialize(jbpmContext); if (processInstance != null && processDefinition != null) { retrieveByteArrays(); if (gpdBytes != null && imageBytes != null) { writeTable(); } } } catch (IOException e) { throw new JspException("table couldn't be displayed", e); } catch (DocumentException e) { throw new JspException("table couldn't be displayed", e); } catch (Throwable ex) { } finally { release(); try { Context.close(jbpmContext); } catch (java.lang.Throwable ex) { } } return EVAL_PAGE; }
From source file:module.workflow.presentationTier.taglib.ActivitivyLinkTag.java
protected String getContextPath() { final HttpServletRequest httpServletRequest = (HttpServletRequest) pageContext.getRequest(); return httpServletRequest.getContextPath(); }
From source file:com.sinosoft.one.mvc.web.RequestPath.java
public RequestPath(HttpServletRequest request) { // method// ww w .j a v a 2 s . c o m setMethod(parseMethod(request)); // ctxpath setCtxpath(request.getContextPath()); String invocationCtxpath = null; // includeinvocationCtxPathincludectxpath // dispather, uri, ctxpath String uri; if (WebUtils.isIncludeRequest(request)) { setDispatcher(Dispatcher.INCLUDE); uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE); invocationCtxpath = ((String) request.getAttribute(WebUtils.INCLUDE_CONTEXT_PATH_ATTRIBUTE)); setMvcPath((String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE)); } else { if (request.getAttribute(MvcConstants.WINDOW_REQUEST_URI) != null) { uri = (String) request.getAttribute(MvcConstants.WINDOW_REQUEST_URI); request.removeAttribute(MvcConstants.WINDOW_REQUEST_URI); request.setAttribute(MvcConstants.IS_WINDOW_REQUEST, "1"); } else { uri = request.getRequestURI(); request.removeAttribute(MvcConstants.IS_WINDOW_REQUEST); } this.setMvcPath(request.getServletPath()); if (request.getAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE) == null) { this.setDispatcher(Dispatcher.REQUEST); } else { this.setDispatcher(Dispatcher.FORWARD); } } if (uri.startsWith("http://") || uri.startsWith("https://")) { int start = uri.indexOf('/', 9); if (start == -1) { uri = ""; } else { uri = uri.substring(start); } } if (uri.indexOf('%') != -1) { try { String encoding = request.getCharacterEncoding(); if (encoding == null || encoding.length() == 0) { encoding = "UTF-8"; } uri = URLDecoder.decode(uri, encoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } this.setUri(uri); // requestPathctxpathincludeinvocationCtxpath if (getCtxpath().length() <= 1) { setMvcPath(getUri()); } else { setMvcPath(getUri().substring((invocationCtxpath == null ? getCtxpath() : invocationCtxpath).length())); } }
From source file:cn.vlabs.duckling.vwb.CPSFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { int advSiteId = Integer.parseInt(StringUtils.defaultIfEmpty(request.getParameter("as"), "-1")); if (advSiteId <= 0) { chain.doFilter(request, response); return;/*from www .j a v a 2s .c o m*/ } HttpServletResponse rep = (HttpServletResponse) response; HttpServletRequest req = (HttpServletRequest) request; request.setAttribute("cps", advSiteId); Cookie[] cookies = req.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (StringUtils.equals(CPS_ADV, cookie.getName())) { cookie.setPath(req.getContextPath()); cookie.setMaxAge(0); } } } Cookie myCookie = new Cookie(CPS_ADV, advSiteId + ""); myCookie.setMaxAge(60 * 60 * 24);// myCookie.setPath(req.getContextPath()); rep.addCookie(myCookie); chain.doFilter(request, response); }
From source file:fr.univlille2.ecm.drive.BasicDriveAuthenticator.java
public Boolean needLoginPrompt(HttpServletRequest httpRequest) { logger.debug(BasicDriveAuthenticator.class.getSimpleName() + " : needLoginPrompt"); if (autoPrompt) { return true; } else {//from w ww .j a va 2 s . c om String requestedURI = httpRequest.getRequestURI(); String context = httpRequest.getContextPath() + '/'; requestedURI = requestedURI.substring(context.length()); for (String prefixURL : forcePromptURLs) { if (requestedURI.startsWith(prefixURL)) { return true; } } return false; } }
From source file:pivotal.au.se.gemfirexdweb.controller.AddWriterController.java
@RequestMapping(value = "/addwriter", method = RequestMethod.GET) public String createWriter(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {/*from www . j av a 2s. co m*/ Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to add new Table Writer"); AddWriter writerAttribute = new AddWriter(); if (request.getParameter("tableName") != null) { writerAttribute.setTableName(request.getParameter("tableName")); } if (request.getParameter("schemaName") != null) { writerAttribute.setSchemaName(request.getParameter("schemaName")); } model.addAttribute("writerAttribute", writerAttribute); // This will resolve to /WEB-INF/jsp/addwriter.jsp return "addwriter"; }
From source file:com.panet.imeta.www.GetJobStatusServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (!request.getContextPath().equals(CONTEXT_PATH)) return;/*ww w .j a v a 2s. c o m*/ if (log.isDebug()) log.logDebug(toString(), Messages.getString("GetJobStatusServlet.Log.JobStatusRequested")); String jobName = request.getParameter("name"); boolean useXML = "Y".equalsIgnoreCase(request.getParameter("xml")); response.setStatus(HttpServletResponse.SC_OK); if (useXML) { response.setContentType("text/xml"); response.setCharacterEncoding(Const.XML_ENCODING); } else { response.setContentType("text/html"); } PrintWriter out = response.getWriter(); Job job = jobMap.getJob(jobName); if (job != null) { String status = job.getStatus(); if (useXML) { response.setContentType("text/xml"); response.setCharacterEncoding(Const.XML_ENCODING); out.print(XMLHandler.getXMLHeader(Const.XML_ENCODING)); SlaveServerJobStatus jobStatus = new SlaveServerJobStatus(jobName, status); Log4jStringAppender appender = (Log4jStringAppender) jobMap.getAppender(jobName); if (appender != null) { // The log can be quite large at times, we are going to put a base64 encoding around a compressed stream // of bytes to handle this one. ByteArrayOutputStream baos = new ByteArrayOutputStream(); GZIPOutputStream gzos = new GZIPOutputStream(baos); gzos.write(appender.getBuffer().toString().getBytes()); gzos.close(); String loggingString = new String(Base64.encodeBase64(baos.toByteArray())); jobStatus.setLoggingString(loggingString); } // Also set the result object... // jobStatus.setResult(job.getResult()); // might be null out.println(jobStatus.getXML()); } else { response.setContentType("text/html"); out.println("<HTML>"); out.println("<HEAD>"); out.println("<TITLE>" + Messages.getString("GetJobStatusServlet.KettleJobStatus") + "</TITLE>"); out.println("<META http-equiv=\"Refresh\" content=\"10;url=/kettle/jobStatus?name=" + URLEncoder.encode(jobName, "UTF-8") + "\">"); out.println("</HEAD>"); out.println("<BODY>"); out.println("<H1>" + Messages.getString("GetJobStatusServlet.JobStatus") + "</H1>"); try { out.println("<table border=\"1\">"); out.print("<tr> <th>" + Messages.getString("GetJobStatusServlet.Jobname") + "</th> <th>" + Messages.getString("TransStatusServlet.TransStatus") + "</th> </tr>"); out.print("<tr>"); out.print("<td>" + jobName + "</td>"); out.print("<td>" + status + "</td>"); out.print("</tr>"); out.print("</table>"); out.print("<p>"); if (job.isFinished()) { out.print("<a href=\"/kettle/startJob?name=" + URLEncoder.encode(jobName, "UTF-8") + "\">" + Messages.getString("GetJobStatusServlet.StartJob") + "</a>"); out.print("<p>"); } else { out.print("<a href=\"/kettle/stopJob?name=" + URLEncoder.encode(jobName, "UTF-8") + "\">" + Messages.getString("GetJobStatusServlet.StopJob") + "</a>"); out.print("<p>"); } out.println("<p>"); out.print("<a href=\"/kettle/jobStatus/?name=" + URLEncoder.encode(jobName, "UTF-8") + "&xml=y\">" + Messages.getString("TransStatusServlet.ShowAsXml") + "</a><br>"); out.print("<a href=\"/kettle/status\">" + Messages.getString("TransStatusServlet.BackToStatusPage") + "</a><br>"); out.print("<p><a href=\"/kettle/jobStatus?name=" + URLEncoder.encode(jobName, "UTF-8") + "\">" + Messages.getString("TransStatusServlet.Refresh") + "</a>"); // Put the logging below that. Log4jStringAppender appender = (Log4jStringAppender) jobMap.getAppender(jobName); if (appender != null) { out.println("<p>"); /* out.println("<pre>"); out.println(appender.getBuffer().toString()); out.println("</pre>"); */ out.println( "<textarea id=\"joblog\" cols=\"120\" rows=\"20\" wrap=\"off\" name=\"Job log\" readonly=\"readonly\">" + appender.getBuffer().toString() + "</textarea>"); out.println("<script type=\"text/javascript\"> "); out.println(" joblog.scrollTop=joblog.scrollHeight; "); out.println("</script> "); out.println("<p>"); } } catch (Exception ex) { out.println("<p>"); out.println("<pre>"); ex.printStackTrace(out); out.println("</pre>"); } out.println("<p>"); out.println("</BODY>"); out.println("</HTML>"); } } else { if (useXML) { out.println(new WebResult(WebResult.STRING_ERROR, Messages.getString("StartJobServlet.Log.SpecifiedJobNotFound", jobName))); } else { out.println("<H1>Job '" + jobName + "' could not be found.</H1>"); out.println("<a href=\"/kettle/status\">" + Messages.getString("TransStatusServlet.BackToStatusPage") + "</a><p>"); } } }
From source file:pivotal.au.se.gemfirexdweb.controller.CreateDiskStoreController.java
@RequestMapping(value = "/creatediskstore", method = RequestMethod.GET) public String createDiskStore(Model model, HttpServletResponse response, HttpServletRequest request, HttpSession session) throws Exception { if (session.getAttribute("user_key") == null) { logger.debug("user_key is null new Login required"); response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else {//from w w w . ja v a 2 s.c om Connection conn = AdminUtil.getConnection((String) session.getAttribute("user_key")); if (conn == null) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } else { if (conn.isClosed()) { response.sendRedirect(request.getContextPath() + "/GemFireXD-Web/login"); return null; } } } logger.debug("Received request to create a new Disk Store"); model.addAttribute("diskStoreAttribute", new NewDiskStore()); // This will resolve to /WEB-INF/jsp/create-hdfsstore.jsp return "create-diskstore"; }
From source file:controller.OrderManagerController.java
@RequestMapping(value = "/process", method = RequestMethod.POST) public String processOrder(HttpServletRequest req, ModelMap mm, @RequestParam int oderId, @RequestParam byte status) { try {/*from w w w .ja va2s .c o m*/ Order order = orderModel.getByID(oderId); order.setStatus(status); mm.put("check", orderModel.addOrUpdate(order)); mm.put("alert", "Updated"); mm.put("link", req.getContextPath() + "/admin/orderManager.html"); } catch (Exception ex) { ex.printStackTrace(); mm.put("alert", ex.getMessage()); } return "processOrder"; }