List of usage examples for javax.servlet.http HttpServletRequest getRequestURI
public String getRequestURI();
From source file:cn.loveapple.service.interceptor.front.core.ResponseInterceptor.java
/** * // www. j av a 2 s . c o m * {@inheritDoc} */ @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { if (log.isDebugEnabled()) { log.debug("Request URI:" + request.getRequestURI()); StringBuilder paramStr = new StringBuilder(1024); for (@SuppressWarnings("unchecked") Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String name = (String) e.nextElement(); paramStr.append("["); paramStr.append(name); paramStr.append("="); paramStr.append(request.getParameter(name)); paramStr.append("]"); } log.debug("Form Parameters:" + paramStr); } return true; }
From source file:foam.nanos.blob.FileService.java
@Override protected void download(X x) { OutputStream os = null;//from w ww. j av a2 s. c o m HttpServletRequest req = x.get(HttpServletRequest.class); HttpServletResponse resp = x.get(HttpServletResponse.class); try { String path = req.getRequestURI(); String id = path.replaceFirst("/service/" + nspec_.getName() + "/", ""); // find file from file dao File file = (File) fileDAO_.find_(x, id); if (file == null || file.getData() == null) { resp.setStatus(HttpServletResponse.SC_NOT_FOUND); return; } // check to see if current user has access to file owner if (userDAO_.find_(x, file.getOwner()) == null) { resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return; } // get blob and blob size // TODO: figure out why delegate is not being set for IdentifiedBlob String blobId = ((IdentifiedBlob) file.getData()).getId(); Blob blob = getDelegate().find_(x, blobId); long size = blob.getSize(); // set response status, content type, content length resp.setStatus(HttpServletResponse.SC_OK); resp.setContentType(file.getMimeType()); resp.setHeader("Content-Length", Long.toString(size, 10)); resp.setHeader("Cache-Control", "public"); // output data to response os = resp.getOutputStream(); blob.read(os, 0, size); os.close(); } catch (Throwable t) { t.printStackTrace(); throw new RuntimeException(t); } finally { IOUtils.closeQuietly(os); } }
From source file:com.alibaba.dragoon.patrol.webx3.DragoonStatValve.java
public String getRequestURI(HttpServletRequest request) { String uri = (String) request.getAttribute("web-rpc.url-pattern"); if (uri == null || uri.length() == 0) { uri = request.getRequestURI(); }//from ww w.j a v a 2 s . c o m if (uri == null) { uri = "/"; } return uri; }
From source file:com.chessoft.filter.AuthenticationFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; HttpSession session = httpRequest.getSession(false); String uri = httpRequest.getRequestURI(); if (StringUtils.contains(uri, "/login.xhtml") || (session != null && session.getAttribute("login") != null) || StringUtils.contains(uri, "javax.faces.resource") || StringUtils.contains(uri, "org/apache/myfaces/tobago/renderkit")) { chain.doFilter(request, response); } else {/*from w w w .j a va 2 s .c o m*/ httpResponse.sendRedirect(httpRequest.getContextPath() + "/login.xhtml"); } }
From source file:io.druid.server.AsyncManagementForwardingServletTest.java
private static Server makeTestServer(int port, ExpectedRequest expectedRequest) { Server server = new Server(port); ServletHandler handler = new ServletHandler(); handler.addServletWithMapping(new ServletHolder(new HttpServlet() { @Override/*from www.j av a 2 s .co m*/ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { handle(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { handle(req, resp); } @Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws IOException { handle(req, resp); } @Override protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException { handle(req, resp); } private void handle(HttpServletRequest req, HttpServletResponse resp) throws IOException { boolean passed = expectedRequest.path.equals(req.getRequestURI()); passed &= expectedRequest.query == null || expectedRequest.query.equals(req.getQueryString()); passed &= expectedRequest.method.equals(req.getMethod()); if (expectedRequest.headers != null) { for (Map.Entry<String, String> header : expectedRequest.headers.entrySet()) { passed &= header.getValue().equals(req.getHeader(header.getKey())); } } passed &= expectedRequest.body == null || expectedRequest.body.equals(IOUtils.toString(req.getReader())); expectedRequest.called = true; resp.setStatus(passed ? 200 : 400); } }), "/*"); server.setHandler(handler); return server; }
From source file:net.sourceforge.ajaxtags.servlets.SourceLoader.java
/** * Write the content from the jarfile to the client stream. Use bufferedwriter to handle * newline. The filename is found in the requestURI, the contextpath is excluded and replaced * with the base package name./*from w ww . j a va 2s .com*/ * * @param req * the request * @param resp * the response * @throws ServletException * any errors * @throws IOException * any io errors */ public void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { final String res = req.getRequestURI(); final OutputStream stream = resp.getOutputStream(); final byte[] buffer = new byte[BUFFER]; String loadPath = res.substring(req.getContextPath().length()); if (prefix != null && loadPath.startsWith(prefix)) { loadPath = loadPath.substring(prefix.length()); } InputStream in = null; try { in = getClass().getResourceAsStream(SourceLoader.BASE + loadPath); if (in == null) { throw new IOException("resource not found"); } int read = -1; while ((read = in.read(buffer)) != -1) { stream.write(buffer, 0, read); } } finally { if (in != null) { in.close(); } stream.flush(); stream.close(); } }
From source file:org.mzd.shap.spring.web.filter.AjaxAwareAuthenticationEntryPoint.java
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException { Matcher matcher = this.ajaxRequestPattern.matcher(request.getRequestURI()); if (matcher.find()) { logger.debug("Identified unauthenticated AJAX request [" + request.getRequestURI() + "] which will be handled as an error with status " + getStatusCode()); response.sendError(getStatusCode(), "Unauthenticated AJAX request"); } else {/* www. j a v a 2 s. c o m*/ super.commence(request, response, authException); } }
From source file:com.leixl.easyframework.web.filter.VcaptchaFilter.java
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; String requestURI = request.getRequestURI(); if (ArrayUtils.contains(includeURIs, requestURI)) { if (!doValidate(request, response)) { ResponseUtils.renderJson(response, resultJson); return; }//w ww .j a va 2 s. c o m } chain.doFilter(req, resp); }
From source file:com.surevine.alfresco.audit.listeners.PostAuditEventListener.java
/** * Default implementation. Can be used by some listeners. * * @param request//from ww w . j a va 2 s .c om * the servlet request * @param postContent * post data if present * @return boolean whether an audit event is fired. */ public boolean isEventFired(final HttpServletRequest request) { return request.getRequestURI().contains(getURIDesignator()); }
From source file:your.microservice.core.util.YourServletUriComponentsBuilder.java
private void pathFromRequest(HttpServletRequest request) { this.servletRequestURI = request.getRequestURI(); replacePath(request.getRequestURI()); }