List of usage examples for javax.servlet.http HttpServletRequest getServletPath
public String getServletPath();
From source file:com.myjeeva.spring.security.securechannel.AbstractCrossDomainRetryEntryPoint.java
/** * {@inheritDoc}//w w w.jav a2s . c o m */ public void commence(ServletRequest req, ServletResponse res) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; String pathInfo = request.getPathInfo(); String queryString = request.getQueryString(); String contextPath = request.getContextPath(); String destination = request.getServletPath() + ((pathInfo == null) ? "" : pathInfo) + ((queryString == null) ? "" : ("?" + queryString)); String redirectUrl = contextPath; Integer currentPort = new Integer(portResolver.getServerPort(request)); Integer redirectPort = getMappedPort(currentPort); if (redirectPort != null) { boolean includePort = redirectPort.intValue() != standardPort; redirectUrl = scheme + getMappedDomain(request.getServerName()) + ((includePort) ? (":" + redirectPort) : "") + contextPath + destination; } LOG.debug(" Cross Domain EntryPoint Redirecting to: " + redirectUrl); ((HttpServletResponse) res).sendRedirect(((HttpServletResponse) res).encodeRedirectURL(redirectUrl)); }
From source file:com.fota.firmMgt.controller.FirmUpdateCTR.java
/** * ? ? view //from w w w .j a v a 2 s .c o m * @param vo * @param model * @return * @throws Exception */ @RequestMapping(value = "/updateView") @ResponseBody public ModelAndView firmUpdateView(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("firmUpdateVO") FirmUpdateVO vo, Model model) throws Exception { if (!request.getServletPath().equals("/commonDevice/firmUpdateMgt/updateView")) { response.setStatus(403); return new ModelAndView("redirect:/lresources/errorPage.jsp"); // return null; } model.addAttribute("data", vo); return new ModelAndView("firmMgt/firmUpdateView"); }
From source file:de.mpg.mpdl.inge.syndication.presentation.RestServlet.java
/** * {@inheritDoc}//w w w . j a va2 s. c o m */ @Override protected final void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String url = null; try { url = PropertyReader.getProperty("escidoc.syndication.service.url") + req.getServletPath() + req.getPathInfo(); } catch (Exception e) { handleException(e, resp); } String q = req.getQueryString(); if (Utils.checkVal(q)) { url += "?" + q; } Feed feed = synd.getFeeds().matchFeedByUri(url); // set correct mime-type resp.setContentType("application/" + (url.contains("rss_") ? "rss" : "atom") + "+xml; charset=utf-8"); // cache handling String ttl = feed.getCachingTtl(); if (Utils.checkVal(ttl)) { long ttlLong = Long.parseLong(ttl) * 1000L; resp.setHeader("control-cache", "max-age=" + ttl + ", must-revalidate"); DateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z"); df.setTimeZone(TimeZone.getTimeZone("GMT")); resp.setHeader("Expires", df.format(new Date(System.currentTimeMillis() + ttlLong))); } try { synd.getFeed(url, resp.getWriter()); } catch (SyndicationException e) { handleException(e, resp); } catch (URISyntaxException e) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Wrong URI syntax: " + url); return; } catch (FeedException e) { handleException(e, resp); } }
From source file:org.openmrs.module.uiframework.PageController.java
/** * Since the 1.x web application only lets spring handle certain file extensions (not including .page) we * need to let people access pages like: ".../openmrs/pages/home.form" *//*ww w . j a v a2 s . c o m*/ @RequestMapping("/pages/**") public String handleUrlStartingWithPage(HttpServletRequest request, HttpServletResponse response, Model model, HttpSession httpSession) { // everything after the contextPath, e.g. "/pages/uilibrary/examples.form", "/pages/emr/registration/checkin.form" String path = request.getServletPath(); path = path.substring("/pages/".length(), path.lastIndexOf(".")); return handlePath(path, request, response, model, httpSession); }
From source file:fr.paris.lutece.portal.web.user.AuthenticationFilter.java
/** * Return the absolute representation of the requested url * /*from w w w . j a v a 2s . c om*/ * @param request * the http request (provides the base path if needed) * @return the requested url has a string * * */ private String getResquestedUrl(HttpServletRequest request) { return AppPathService.getBaseUrl(request) + request.getServletPath().substring(1); }
From source file:io.neba.core.logviewer.LogfileViewerConsolePlugin.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String suffix = substringAfter(req.getRequestURI(), req.getServletPath() + "/" + getLabel()); if (!isBlank(suffix) && suffix.startsWith("/tail")) { this.tailServlet.service(req, res); return;/*from w ww. j a v a 2 s . c om*/ } if ("/download".equals(suffix)) { download(res, req); return; } if ("/serverTime".equals(suffix)) { serverTime(res); return; } super.doGet(req, res); }
From source file:de.mpg.escidoc.services.syndication.presentation.RestServlet.java
/** * {@inheritDoc}//from w ww. j av a2s . c om */ @Override protected final void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { String url = null; try { url = PropertyReader.getProperty("escidoc.syndication.service.url") + req.getServletPath() + req.getPathInfo(); } catch (Exception e) { handleException(e, resp); } String q = req.getQueryString(); if (Utils.checkVal(q)) { url += "?" + q; } Feed feed = synd.getFeeds().matchFeedByUri(url); //set correct mime-type resp.setContentType("application/" + (url.contains("rss_") ? "rss" : "atom") + "+xml; charset=utf-8"); //cache handling String ttl = feed.getCachingTtl(); if (Utils.checkVal(ttl)) { long ttlLong = Long.parseLong(ttl) * 1000L; resp.setHeader("control-cache", "max-age=" + ttl + ", must-revalidate"); DateFormat df = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss z"); df.setTimeZone(TimeZone.getTimeZone("GMT")); resp.setHeader("Expires", df.format(new Date(System.currentTimeMillis() + ttlLong))); } try { synd.getFeed(url, resp.getWriter()); } catch (SyndicationException e) { handleException(e, resp); } catch (URISyntaxException e) { resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Wrong URI syntax: " + url); return; } catch (FeedException e) { handleException(e, resp); } }
From source file:org.semispace.semimeter.controller.CounterController.java
@RequestMapping("/**/monitor.html") public String monitorPage(Model model, HttpServletRequest request, @RequestParam(required = false) String graphresolution, @RequestParam(required = false) String counterresolution) { if (!isSane(request.getServletPath())) { throw new RuntimeException("Disallowed character found in query."); }/*from w ww . ja v a 2 s .c om*/ if (graphresolution == null) { graphresolution = "month"; } if (counterresolution == null) { counterresolution = "total"; } semimeterService.calculateNumberOfSamples(counterresolution); // Just in order to get an exception if value is wrong model.addAttribute("graphresolution", graphresolution); model.addAttribute("counterresolution", counterresolution); model.addAttribute("path", trimPath("/monitor.html", request.getServletPath())); model.addAttribute("graphsamples", semimeterService.calculateNumberOfSamples(graphresolution)); return "monitor"; }
From source file:jp.co.opentone.bsol.linkbinder.view.filter.LoginFilter.java
private void setDirectLogin(HttpServletRequest request, boolean timeout) { // ?ID?//from www . j ava 2 s .com RedirectScreenId screenId = RedirectScreenId.getPairedIdOf(request.getServletPath()); switch (screenId) { case CORRESPON: String id = request.getParameter(RedirectProcessParameterKey.ID); String projectId = request.getParameter(RedirectProcessParameterKey.PROJECT_ID); // ??????????????? // ??????????? if (timeout && (StringUtils.isEmpty(id) || StringUtils.isEmpty(projectId))) { return; } ArgumentValidator.validateNotNull(id, RedirectProcessParameterKey.ID); ArgumentValidator.validateNotNull(projectId, RedirectProcessParameterKey.PROJECT_ID); // ??????????????true? HttpSession session = request.getSession(true); session.setAttribute(Constants.KEY_REDIRECT_SCREEN_ID, screenId); session.setAttribute(RedirectProcessParameterKey.ID, id); session.setAttribute(RedirectProcessParameterKey.PROJECT_ID, projectId); break; default: throw new ApplicationFatalRuntimeException("invalid screen id"); } }