List of usage examples for javax.servlet.http HttpServletRequest getPathInfo
public String getPathInfo();
From source file:edu.mayo.cts2.framework.plugin.namespace.ui.osgi.StaticHttpService.java
/** * Service the request. The only path recognized by this servlet is * \/editor/console - all others will be delegated to OSGi resource handling. * * @param request the request/*from www. jav a 2 s . c o m*/ * @param response the response * @throws ServletException the servlet exception * @throws IOException Signals that an I/O exception has occurred. */ private void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // check whether we are not at .../{webManagerRoot} final String pathInfo = request.getPathInfo(); if (pathInfo.equals("/console")) { InputStream in = this.getClass().getResourceAsStream("/web/index.html"); response.setContentType("text/html"); IOUtils.copy(in, response.getWriter()); } }
From source file:com.boundlessgeo.geoserver.api.controllers.ConfigurationLockInterceptor.java
@Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (THREAD_LOCK.get() != null) { throw new RuntimeException("existing lock found on " + request.getPathInfo()); }/*from ww w.ja v a 2 s. c om*/ String method = request.getMethod().toLowerCase(); GeoServerConfigurationLock.LockType lockType; switch (method) { case "get": case "head": case "options": lockType = GeoServerConfigurationLock.LockType.READ; break; default: // defaulting to a write lock is probably the safest bet here // unless a new, popular read method is invented sometime... lockType = GeoServerConfigurationLock.LockType.WRITE; } if (logger.isLoggable(Level.FINE)) { logger.fine("DEBUG LOCK: " + lockType); } THREAD_LOCK.set(lockType); lock().lock(lockType); return true; }
From source file:com.adito.core.MessageResourceLoaderServlet.java
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name = request.getPathInfo().substring(1); if (name.equals("")) { log.error("No name supplied to the class loader servlet."); response.sendError(500);// w w w .j a va 2s.co m return; } int idx = name.lastIndexOf('/'); String basename = name; if (idx != -1) { basename = name.substring(idx + 1); } if (!basename.startsWith("ApplicationResources") || (!basename.endsWith(".properties") && !basename.endsWith(".class"))) { log.debug("Attempt to load something other that a resource bundle via the class loader servlet."); response.sendError(500); return; } /* This is a hack to get around the problem where we never get * get a request for the default language resources when they are * in a properties file. This is because we use a class loader on * the client end to retrieve the resources. */ if (basename.endsWith(".class")) { basename = basename.substring(0, basename.length() - 6) + ".properties"; name = name.substring(0, name.length() - 6) + ".properties"; } /* * Load into byte array so we get the content length before sending on * to the client */ ByteArrayOutputStream bout = new ByteArrayOutputStream(); InputStream in = ContextHolder.getContext().getContextLoader().getResourceAsStream(name); if (in == null) { response.setContentType("text/plain"); response.sendError(404, "Class not found"); } else { try { Util.copy(in, bout); } finally { bout.close(); in.close(); } response.setContentType("text/plain"); response.setContentLength(bout.size()); response.setStatus(200); ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); sendFile(bin, bout.size(), response); } }
From source file:org.fcrepo.http.commons.session.SessionFactory.java
/** * Extract the id embedded at the beginning of a request path * * @param servletRequest the servlet request * @param prefix the prefix for the id//from w w w. ja v a 2 s. com * @return the found id or null */ protected String getEmbeddedId(final HttpServletRequest servletRequest, final Prefix prefix) { String requestPath = servletRequest.getPathInfo(); // http://stackoverflow.com/questions/18963562/grizzlys-request-getpathinfo-returns-always-null if (requestPath == null && servletRequest.getContextPath().isEmpty()) { requestPath = servletRequest.getRequestURI(); } String id = null; if (requestPath != null) { final String pathPrefix = prefix.getPrefix(); final String[] part = requestPath.split("/"); if (part.length > 1 && part[1].startsWith(pathPrefix)) { id = part[1].substring(pathPrefix.length()); } } return id; }
From source file:org.sakaiproject.imagegallery.web.MultiFileUploaderController.java
public ModelAndView singleFileUpload(HttpServletRequest request, HttpServletResponse response) throws Exception { if (log.isInfoEnabled()) log.info("req contextPath=" + request.getContextPath() + ", pathInfo=" + request.getPathInfo() + ", query=" + request.getQueryString() + ", URI=" + request.getRequestURI() + ", URL=" + request.getRequestURL() + ", servlet=" + request.getServletPath()); if (request instanceof MultipartHttpServletRequest) { return new ModelAndView(new RedirectView( "/site/AddInformationToImages?imageIds=" + storeNewImage((MultipartHttpServletRequest) request), true));/* w w w. j a v a 2 s . co m*/ } return null; }
From source file:org.apache.lucene.replicator.http.ReplicationService.java
/** * Returns the path elements that were given in the servlet request, excluding * the servlet's action context./*from w w w . j a va 2 s.c o m*/ */ private String[] getPathElements(HttpServletRequest req) { String path = req.getServletPath(); String pathInfo = req.getPathInfo(); if (pathInfo != null) { path += pathInfo; } int actionLen = REPLICATION_CONTEXT.length(); int startIdx = actionLen; if (path.length() > actionLen && path.charAt(actionLen) == '/') { ++startIdx; } // split the string on '/' and remove any empty elements. This is better // than using String.split() since the latter may return empty elements in // the array StringTokenizer stok = new StringTokenizer(path.substring(startIdx), "/"); ArrayList<String> elements = new ArrayList<>(); while (stok.hasMoreTokens()) { elements.add(stok.nextToken()); } return elements.toArray(new String[0]); }
From source file:com.ecyrd.jspwiki.url.DefaultURLConstructor.java
/** * This method is not needed for the DefaultURLConstructor. * /*w ww. j av a 2 s . c om*/ * @param request The HTTP Request that was used to end up in this page. * @return "Wiki.jsp", "PageInfo.jsp", etc. Just return the name, * JSPWiki will figure out the page. */ public String getForwardPage(HttpServletRequest request) { return request.getPathInfo(); }
From source file:com.jaspersoft.jasperserver.rest.services.RESTJobSummary.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { // Get the uri of the resource String url = restUtils.extractRepositoryUri(req.getPathInfo()); if (log.isDebugEnabled()) { log.debug("getting job summary for " + url); }/*from w w w . j av a 2s . c om*/ if (url == null) { throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, "malformed url: " + url); } if (isValidUri(url)) { JobSummary[] summaries = new JobSummary[0]; try { summaries = reportSchedulerService.getReportJobs(url); } catch (AxisFault axisFault) { throw new ServiceException(HttpServletResponse.SC_NOT_FOUND, "could not locate jobs for report in uri: " + url + axisFault.getLocalizedMessage()); } if (summaries == null) { restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, ""); } else { if (log.isDebugEnabled()) { log.debug("found " + summaries.length + "job summaries for report: " + req.getPathInfo()); } restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, generateSummeryReport(summaries)); } } else throw new ServiceException(HttpServletResponse.SC_BAD_REQUEST, "bad report uri"); }
From source file:com.jaspersoft.jasperserver.rest.RESTAbstractService.java
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { log.error("Method GET is not supported for this object type - request params: Path: " + req.getPathInfo()); restUtils.setStatusAndBody(HttpServletResponse.SC_METHOD_NOT_ALLOWED, resp, "Method not supported for this object type"); }
From source file:com.jaspersoft.jasperserver.rest.RESTAbstractService.java
protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { log.error("Method PUT is not supported for this object type - request params: Path: " + req.getPathInfo()); restUtils.setStatusAndBody(HttpServletResponse.SC_METHOD_NOT_ALLOWED, resp, "Method not supported for this object type"); }