List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:org.apache.hadoop.gateway.dispatch.DefaultDispatchTest.java
@Test public void testCallToSecureClusterWithoutDelegationToken() throws URISyntaxException, IOException { DefaultDispatch defaultDispatch = new DefaultDispatch(); defaultDispatch.setReplayBufferSize(10); ServletContext servletContext = EasyMock.createNiceMock(ServletContext.class); GatewayConfig gatewayConfig = EasyMock.createNiceMock(GatewayConfig.class); EasyMock.expect(gatewayConfig.isHadoopKerberosSecured()).andReturn(Boolean.TRUE).anyTimes(); EasyMock.expect(servletContext.getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE)) .andReturn(gatewayConfig).anyTimes(); ServletInputStream inputStream = EasyMock.createNiceMock(ServletInputStream.class); HttpServletRequest inboundRequest = EasyMock.createNiceMock(HttpServletRequest.class); EasyMock.expect(inboundRequest.getQueryString()).andReturn("a=123").anyTimes(); EasyMock.expect(inboundRequest.getInputStream()).andReturn(inputStream).anyTimes(); EasyMock.expect(inboundRequest.getServletContext()).andReturn(servletContext).anyTimes(); EasyMock.replay(gatewayConfig, servletContext, inboundRequest); HttpEntity httpEntity = defaultDispatch.createRequestEntity(inboundRequest); assertTrue("not buffering in the absence of delegation token", (httpEntity instanceof PartiallyRepeatableHttpEntity)); }
From source file:com.lyh.licenseworkflow.web.filter.LoginFilter.java
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; StringBuffer buffer = httpRequest.getRequestURL();// url String queryString = httpRequest.getQueryString();// ? HttpSession session = httpRequest.getSession(); //?//from ww w . ja va 2 s.c o m String wonderUrl = URLEncoder.encode(httpRequest.getRequestURI() + "?" + httpRequest.getQueryString(), "UTF-8"); String fullUrl = buffer.toString();// url???web?? boolean checkPermission = true;// ?????CSSJSJVM??? for (String ingoreUrl : ingoreUrls) { if (fullUrl.indexOf(ingoreUrl) != -1) {// URL??????? checkPermission = false; break; } } if (!checkPermission) {// ??? filterChain.doFilter(httpRequest, httpResponse); } else {// ????? User loginUser = (User) httpRequest.getSession().getAttribute(LicenseWorkFlowConstants.SESSION_USER); if (loginUser == null) { //?? //session // httpResponse.sendRedirect(httpRequest.getContextPath() + "/index.action?wonderUrl=" + wonderUrl); httpResponse.sendRedirect(httpRequest.getContextPath() + "/index.action"); return; } else { filterChain.doFilter(httpRequest, httpResponse); } } }
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));//ww w . j a va 2 s. c o m } return null; }
From source file:nl.surfnet.coin.selfservice.filter.ApiOAuthFilter.java
private String getCurrentRequestUrl(HttpServletRequest request) { StringBuilder sb = new StringBuilder().append(request.getRequestURL()); if (!StringUtils.isBlank(request.getQueryString())) { sb.append("?").append(request.getQueryString()); }/*from ww w . j a v a 2 s . c o m*/ return sb.toString(); }
From source file:in.mycp.controller.LoginController.java
@RequestMapping(produces = "text/html") public String main(HttpServletRequest req, HttpServletResponse resp) { logger.info("login " + req.getQueryString() + " {}{}{} " + req.getRequestURL() + " {}{}{} " + req.getRemoteAddr());/*from w w w. ja v a 2 s .c o m*/ //HttpSession s = req.getSession(true); return "mycplogin"; }
From source file:org.tsm.concharto.web.eventsearch.EventSearchController.java
/** * Override the default setting. If there are query parameters in the URL, we assume * this is a form submission (e.g. when=, where=, what=) *//* w w w .j av a 2 s .c o m*/ @Override protected boolean isFormSubmission(HttpServletRequest request) { return !StringUtils.isEmpty(request.getQueryString()) || super.isFormSubmission(request); }
From source file:com.meltmedia.cadmium.servlets.RedirectFilter.java
@Override public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { Redirect redir = null;//from w w w . j av a2 s. c o m try { if (redirect != null && req instanceof HttpServletRequest && resp instanceof HttpServletResponse) { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) resp; String path = request.getRequestURI(); String queryString = request.getQueryString(); log.trace("Checking for existing redirect [{}?{}]", path, queryString); redir = redirect.requestMatches(path, queryString); if (redir != null) { String redirectTo = redir.getUrlSubstituted(); if (StringUtils.isNotBlank(queryString) && !redirectTo.contains("?")) { redirectTo += "?" + queryString; log.debug("adding query string to redirect path: {}", redirectTo); } response.setHeader("Location", redirectTo); response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY); log.debug("Location response header: {}", redirectTo); return; } } else { log.trace("Redirect and/or req and resp are not http"); } try { chain.doFilter(req, resp); } catch (IOException ioe) { log.trace("Failed down stream from redirect filter.", ioe); throw ioe; } catch (ServletException se) { log.trace("Failed down stream from redirect filter.", se); throw se; } catch (Throwable t) { StringWriter str = new StringWriter(); t.printStackTrace(new PrintWriter(str)); log.trace("Failed down stream from redirect filter: " + str.toString(), t); ServletException se = new ServletException(t); throw se; } } catch (Throwable t) { StringWriter str = new StringWriter(); t.printStackTrace(new PrintWriter(str)); log.debug("Failed in redirect filter: " + str.toString(), t); ServletException se = new ServletException(t); throw se; } }
From source file:org.apache.hadoop.gateway.dispatch.DefaultDispatchTest.java
@Test public void testUsingDefaultBufferSize() throws URISyntaxException, IOException { DefaultDispatch defaultDispatch = new DefaultDispatch(); ServletContext servletContext = EasyMock.createNiceMock(ServletContext.class); GatewayConfig gatewayConfig = EasyMock.createNiceMock(GatewayConfig.class); EasyMock.expect(gatewayConfig.isHadoopKerberosSecured()).andReturn(Boolean.TRUE).anyTimes(); EasyMock.expect(gatewayConfig.getHttpServerRequestBuffer()).andReturn(16384).anyTimes(); EasyMock.expect(servletContext.getAttribute(GatewayConfig.GATEWAY_CONFIG_ATTRIBUTE)) .andReturn(gatewayConfig).anyTimes(); ServletInputStream inputStream = EasyMock.createNiceMock(ServletInputStream.class); HttpServletRequest inboundRequest = EasyMock.createNiceMock(HttpServletRequest.class); EasyMock.expect(inboundRequest.getQueryString()).andReturn("a=123").anyTimes(); EasyMock.expect(inboundRequest.getInputStream()).andReturn(inputStream).anyTimes(); EasyMock.expect(inboundRequest.getServletContext()).andReturn(servletContext).anyTimes(); EasyMock.replay(gatewayConfig, servletContext, inboundRequest); HttpEntity httpEntity = defaultDispatch.createRequestEntity(inboundRequest); assertTrue("not buffering in the absence of delegation token", (httpEntity instanceof PartiallyRepeatableHttpEntity)); assertEquals(defaultDispatch.getReplayBufferSize(), 16); assertEquals(defaultDispatch.getReplayBufferSizeInBytes(), 16384); //also test normal setter and getters defaultDispatch.setReplayBufferSize(-1); assertEquals(defaultDispatch.getReplayBufferSizeInBytes(), -1); assertEquals(defaultDispatch.getReplayBufferSize(), -1); defaultDispatch.setReplayBufferSize(16); assertEquals(defaultDispatch.getReplayBufferSizeInBytes(), 16384); assertEquals(defaultDispatch.getReplayBufferSize(), 16); }
From source file:io.apicurio.studio.fe.servlet.servlets.DownloadServlet.java
/** * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) *//* ww w. j a v a2 s .c o m*/ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { Map<String, String> params = parseQueryString(req.getQueryString()); String type = params.get("type"); if ("api".equals(type)) { String format = params.get("format"); String designId = params.get("id"); String url = generateHubApiUrl(req); if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } url += "/designs/{designId}/content?format={format}".replace("{designId}", designId).replace("{format}", format); disableHttpCaching(resp); proxyUrlTo(url, req, resp); } else if ("codegen".equals(type)) { String designId = params.get("designId"); String projectId = params.get("projectId"); String url = generateHubApiUrl(req); if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); } url += "/designs/{designId}/codegen/projects/{projectId}/zip".replace("{designId}", designId) .replace("{projectId}", projectId); disableHttpCaching(resp); proxyUrlTo(url, req, resp); } else { resp.sendError(404); } }
From source file:org.iwethey.forums.web.user.LoginInterceptor.java
/** * Check the session for an authenticated user name. If none, redirect to * the login page.//from w ww . j a va 2 s .c o m * <p> * @param request The servlet request object. * @param response The servlet response object. * @param handler The request handler processing this request. */ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Integer id = (Integer) WebUtils.getSessionAttribute(request, USER_ID_ATTRIBUTE); if (id == null) { String uri = request.getServletPath(); String query = request.getQueryString(); ModelAndView mv = new ModelAndView(new RedirectView("../user/login.iwt")); throw new ModelAndViewDefiningException(mv); } else { return true; } }