List of usage examples for javax.servlet.http HttpServletRequest getPathInfo
public String getPathInfo();
From source file:com.github.restdriver.clientdriver.HttpRealRequest.java
public HttpRealRequest(HttpServletRequest request) { this.path = request.getPathInfo(); this.method = Method.custom(request.getMethod().toUpperCase()); this.params = HashMultimap.create(); if (request.getQueryString() != null) { MultiMap<String> parameterMap = new MultiMap<String>(); UrlEncoded.decodeTo(request.getQueryString(), parameterMap, "UTF-8", 0); for (Entry<String, String[]> paramEntry : parameterMap.toStringArrayMap().entrySet()) { String[] values = paramEntry.getValue(); for (String value : values) { this.params.put(paramEntry.getKey(), value); }// www.j a v a2 s .c o m } } headers = new HashMap<String, Object>(); Enumeration<String> headerNames = request.getHeaderNames(); if (headerNames != null) { while (headerNames.hasMoreElements()) { String headerName = headerNames.nextElement(); headers.put(headerName.toLowerCase(), request.getHeader(headerName)); } } try { this.bodyContent = IOUtils.toByteArray(request.getInputStream()); } catch (IOException e) { throw new RuntimeException("Failed to read body of request", e); } this.bodyContentType = request.getContentType(); }
From source file:GoTo.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { // Determine the site where they want to go String site = req.getPathInfo(); String query = req.getQueryString(); // Handle a bad request if (site == null) { res.sendError(res.SC_BAD_REQUEST, "Extra path info required"); }/*from www . ja va 2s . c o m*/ // Cut off the leading "/" and append the query string // We're assuming the path info URL is always absolute String url = site.substring(1) + (query == null ? "" : "?" + query); // Log the requested URL and redirect log(url); // or write to a special file res.sendRedirect(url); }
From source file:info.magnolia.imaging.ImagingServlet.java
/** * Determines the ImageGenerator to use, using the first path element of the * pathInfo.//from w w w . jav a 2 s. c o m */ protected String getImageGeneratorName(HttpServletRequest request) { final String pathInfo = request.getPathInfo(); return new PathSplitter(pathInfo).skipTo(0); }
From source file:eu.delving.services.controller.ServiceController.java
@RequestMapping("/resolve") public void resolve(HttpServletRequest request, HttpServletResponse response) throws IOException { String pathInfo = request.getPathInfo(); if (pathInfo == null) { report(response, "Nothing to resolve"); } else {/* ww w . ja va 2s . c om*/ String[] parts = pathInfo.split("/"); if (parts.length != 4 || !"record".equals(parts[1])) { report(response, "Expected path like /resolve/object/*/*"); } else { String uri = resolverUrlPrefix + request.getRequestURI(); String encodedUri = URLEncoder.encode(uri, "UTF-8"); String redirect = displayPageUrl + "?uri=" + encodedUri; // report(response, redirect); response.sendRedirect(redirect); } } }
From source file:com.thinkberg.webdav.GetHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { FileObject object = VFSBackend.resolveFile(request.getPathInfo()); if (object.exists()) { if (FileType.FOLDER.equals(object.getType())) { response.sendError(HttpServletResponse.SC_FORBIDDEN); return; }/*from www .j a v a 2 s . c o m*/ setHeader(response, object.getContent()); InputStream is = object.getContent().getInputStream(); OutputStream os = response.getOutputStream(); Util.copyStream(is, os); is.close(); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); } }
From source file:com.apress.progwt.server.web.controllers.MyListController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse arg1) throws Exception { log.debug("SERVLET PATH: " + req.getServletPath() + " " + req.getPathInfo() + " " + req.getQueryString()); Map<String, Object> model = getDefaultModel(req); ModelAndView mav = getMav();//from www.ja va2s .c o m mav.addAllObjects(model); return mav; }
From source file:com.carolinarollergirls.scoreboard.jetty.LoadXmlScoreBoard.java
protected void handleDocument(HttpServletRequest request, HttpServletResponse response, Document doc) throws IOException { if (request.getPathInfo().equalsIgnoreCase("/load")) getXmlScoreBoard().loadDocument(doc); else if (request.getPathInfo().equalsIgnoreCase("/merge")) getXmlScoreBoard().mergeDocument(doc); else//from w ww . j a va2 s. com response.sendError(HttpServletResponse.SC_NOT_FOUND, "Must specify to load or merge document"); response.setContentType("text/plain"); response.setStatus(HttpServletResponse.SC_OK); }
From source file:com.thinkberg.moxo.dav.OptionsHandler.java
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setHeader("DAV", "1, 2"); String path = request.getPathInfo(); StringBuffer options = new StringBuffer(); FileObject object = getResourceManager().getFileObject(path); if (object.exists()) { options.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE, COPY, MOVE, LOCK, UNLOCK, PROPFIND"); if (FileType.FOLDER.equals(object.getType())) { options.append(", PUT"); }//from w w w.j av a 2 s . c om } else { options.append("OPTIONS, MKCOL, PUT, LOCK"); } response.setHeader("Allow", options.toString()); // see: http://www-128.ibm.com/developerworks/rational/library/2089.html response.setHeader("MS-Author-Via", "DAV"); }
From source file:MyServlet.java
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/plain"); PrintWriter out = res.getWriter(); if (req.getPathInfo() != null) { out.println("The file \"" + req.getPathInfo() + "\""); out.println("Is stored at \"" + req.getPathTranslated() + "\""); } else {//from ww w . j a v a 2s. c o m out.println("Path info is null, no file to lookup"); } }
From source file:com.github.jryans.websockettap.WebSocketTap.java
public void startServer() throws Exception { Server server = new Server(_serverPort); server.setHandler(new WebSocketHandler() { @Override/*from w ww . j a va 2 s. c o m*/ public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) { return new LoggingWebSocket(request.getPathInfo()); } }); server.start(); _webSocketClientFactory.start(); System.out.println("Ready for connections on port " + _serverPort); server.join(); }