List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:de.hybris.platform.addonsupport.controllers.page.AbstractAddOnPageController.java
protected void storeContinueUrl(final HttpServletRequest request) { final StringBuilder url = new StringBuilder(); url.append(request.getServletPath()); final String queryString = request.getQueryString(); if (queryString != null && !queryString.isEmpty()) { url.append('?').append(queryString); }// w ww .j a v a2s . c o m getSessionService().setAttribute("session_continue_url", url.toString()); }
From source file:org.deegree.securityproxy.authentication.wass.AddParameterAnonymousAuthenticationFilter.java
private HttpServletRequest wrapRequest(HttpServletRequest request) throws ServletException { String method = request.getMethod(); LOG.debug("Retrieved " + method + " request"); if (isGetRequestedAndSupported(method)) { LOG.debug("Handle GET request with query string " + request.getQueryString()); return new KvpRequestWrapper(request); } else if (isPostRequestedAndSupported(method)) { LOG.debug("Handle POST request"); try {//from ww w .ja va 2 s . c om return new HttpServletRequestBodyWrapper(request); } catch (IOException e) { throw new ServletException(e); } } return request; }
From source file:org.stockwatcher.web.UserController.java
@RequestMapping(value = "/select/{userId}", method = RequestMethod.GET) public String selectUser(@PathVariable String userId, Model model, HttpServletRequest request, HttpServletResponse response) {//w w w . ja v a 2 s . c om String view = "redirect:/main/users"; // first we need to validate the user User user = getUser(userId); if (user != null) { LOGGER.info("User selected with id = {}", userId); request.getSession().setAttribute("user", user); } else { String path = request.getQueryString(); view = path.substring(0, path.indexOf("/select/")); } return view; }
From source file:net.eusashead.hateoas.conditional.interceptor.ConditionalResponseInterceptor.java
/** * Get the full URI *including*/*from w w w. j a v a 2 s . c o m*/ * the query string. That's because * the content of a resource might * be different depending on the query * string, although the actual server side * resource would be the same. * @param request * @return * @throws URISyntaxException */ private URI getUri(HttpServletRequest request) { StringBuilder requestUri = new StringBuilder(); requestUri.append(request.getRequestURI()); String queryString = request.getQueryString(); if (queryString != null) { requestUri.append('?').append(queryString); } try { return new URI(requestUri.toString()); } catch (URISyntaxException e) { throw new IllegalArgumentException("The request could nt be parsed as a URI."); } }
From source file:com.alfaariss.oa.profile.aselect.binding.protocol.cgi.CGIRequest.java
/** * Creates the CGI request object.// w w w . j av a 2s. co m * * Reads the request parameters and puts them in a <code>Hashtable</code> * @param oRequest the servlet request * @throws BindingException if the request object can't be created */ public CGIRequest(HttpServletRequest oRequest) throws BindingException { try { _logger = LogFactory.getLog(CGIRequest.class); _htRequest = new Hashtable<String, Object>(); _sRequestedURL = oRequest.getRequestURL().toString(); if (_logger.isDebugEnabled()) { String sQueryString = oRequest.getQueryString(); if (sQueryString == null) sQueryString = ""; _logger.debug("QueryString: " + sQueryString); } Hashtable<String, Vector<String>> htVectorItems = new Hashtable<String, Vector<String>>(); Enumeration enumNames = oRequest.getParameterNames(); while (enumNames.hasMoreElements()) { String sName = (String) enumNames.nextElement(); String sValue = oRequest.getParameter(sName); if (sName.endsWith(CGIBinding.ENCODED_BRACES) || sName.endsWith(CGIBinding.ENCODED_BRACES.toLowerCase()) || sName.endsWith("[]")) { Vector<String> vValues = htVectorItems.get(sName); if (vValues == null) vValues = new Vector<String>(); vValues.add(sValue); htVectorItems.put(sName, vValues); } else _htRequest.put(sName, sValue); } _htRequest.putAll(htVectorItems); } catch (Exception e) { _logger.fatal("Internal error during CGI Request creation", e); throw new BindingException(SystemErrors.ERROR_INTERNAL); } }
From source file:com.cyclopsgroup.waterview.servlet.ServletRuntimeData.java
/** * Default constructor of default web runtime * * @param request Http request object//from w w w . ja va 2 s . c o m * @param response Http response object * @param context Http servlet context * @param fileUpload File upload component * @param services ServiceManager object * @param applicationBase application base url * @throws Exception Throw it out */ ServletRuntimeData(HttpServletRequest request, HttpServletResponse response, ServletContext context, FileUpload fileUpload, ServiceManager services, String applicationBase) throws Exception { this.response = response; this.context = context; setQueryString(request.getQueryString()); setRefererUrl(request.getHeader("referer")); //Session Context setSessionContext(new HttpSessionContext(request.getSession())); setSessionId(request.getSession().getId()); setRequestContext(new ServletRequestContext(request)); //Request path String requestPath = request.getPathInfo(); setRequestPath(requestPath == null ? StringUtils.EMPTY : requestPath); //Output OutputStream outputStream = response.getOutputStream(); setOutputStream(outputStream); InterpolationFilterWriter filterWriter = new InterpolationFilterWriter(new OutputStreamWriter(outputStream), '%') { /** * Overwrite or implement method interpolate() * * @see com.cyclopsgroup.waterview.utils.InterpolationFilterWriter#interpolate(java.lang.String) */ protected String interpolate(String name) throws Exception { I18NService i18n = (I18NService) getServiceManager().lookup(I18NService.ROLE); return i18n.translate(name, getLocale()); } }; setOutput(new PrintWriter(filterWriter)); //Request value parser if (FileUpload.isMultipartContent(request)) { setParams(new MultipartServletRequestParameters(request, fileUpload)); } else { setParams(new ServletRequestParameters(request)); } //Service manager setServiceManager(services); //Application base url if (StringUtils.isEmpty(applicationBase)) { StringBuffer sb = new StringBuffer(request.getScheme()); sb.append("://").append(request.getServerName()); if (request.getServerPort() != 80) { sb.append(':').append(request.getServerPort()); } sb.append(request.getContextPath()); applicationBase = sb.toString(); } setApplicationBaseUrl(applicationBase); //Page base url setPageBaseUrl(applicationBase + request.getServletPath()); }
From source file:com.github.restdriver.clientdriver.unit.ClientDriverHandlerTest.java
/** * with no expectations set, and a request made, the handler throws an error upon verification *//*from w w w . j av a 2 s . c o m*/ @Test public void testUnexpectedRequest() throws IOException, ServletException { Request mockRequest = mock(Request.class); HttpServletRequest mockHttpRequest = mock(HttpServletRequest.class); HttpServletResponse mockHttpResponse = mock(HttpServletResponse.class); when(mockHttpRequest.getMethod()).thenReturn("POST"); when(mockHttpRequest.getPathInfo()).thenReturn("yarr"); when(mockHttpRequest.getQueryString()).thenReturn("gooo=gredge"); when(mockHttpRequest.getInputStream()).thenReturn(new DummyServletInputStream(IOUtils.toInputStream(""))); try { sut.handle("", mockRequest, mockHttpRequest, mockHttpResponse); Assert.fail(); } catch (ClientDriverFailedExpectationException e) { assertThat(e.getMessage(), containsString("1 unexpected request(s):")); assertThat(e.getMessage(), containsString("POST yarr; PARAMS: [gooo=[gredge]];")); } }
From source file:edu.usc.lunchnlearn.elasticsearch.interceptor.BreadCrumbInterceptor.java
private Crumb getCurrentCrumb(HttpServletRequest request, Map<String, Long> breadcrumbUrls, Map<Long, Crumb> breadcrumbs, ModelAndView modelAndView) { Crumb crumb = new Crumb(); StringBuffer stringBuffer = request.getRequestURL(); if (request.getQueryString() != null) { stringBuffer.append("?").append(request.getQueryString()); }//from w w w .j a v a2 s. co m crumb.setUrl(stringBuffer.toString()); //if the exact URL has already been requested, use that crumb instead of creating a new one. if (breadcrumbUrls.containsKey(crumb.getUrl())) { return breadcrumbs.get(breadcrumbUrls.get(crumb.getUrl())); } //set the display text of the breadcrumb crumb.setDisplayText(""); if (modelAndView.getModelMap().containsAttribute("title")) { crumb.setDisplayText((String) modelAndView.getModelMap().get("title")); } else { for (String uri : uriDisplayTextMapping.keySet()) { if (crumb.getUrl().contains(uri)) { crumb.setDisplayText(uriDisplayTextMapping.get(uri)); break; } } } //set the parent value if (request.getParameterMap().containsKey("x")) { if (StringUtils.isNumeric(request.getParameter("x"))) { crumb.setParentX(Long.parseLong(request.getParameter("x"))); } } //set the time in millis for X crumb.setX(System.currentTimeMillis()); return crumb; }
From source file:per.mnn.controller.CategoryController.java
@RequestMapping(value = "/category", method = RequestMethod.GET) public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse respond) { ModelAndView retval = new ModelAndView(); HttpSession httpSess = request.getSession(); Session sess = HibernateUtil.getSessionFactory().openSession(); try {/* w ww . jav a 2s.c om*/ Query query = sess.createQuery("FROM Category"); retval.addObject("categories", query.list()); String name = request.getQueryString(); if (name != null && !name.isEmpty()) { for (Category item : (List<Category>) query.list()) { if (item.getName().equals(name.replace("%20", " "))) { httpSess.setAttribute("selectedCategory", item); query = sess.createQuery("FROM Product as p WHERE p.category.id = :id"); query.setInteger("id", item.getId()); httpSess.setAttribute("categoryProducts", query.list()); break; } } } } finally { sess.close(); } retval.setViewName("category"); return retval; }
From source file:com.googlesource.gerrit.plugins.github.oauth.OAuthGitFilter.java
private String getRequestPathWithQueryString(HttpServletRequest httpRequest) { String requestPathWithQueryString = httpRequest.getContextPath() + httpRequest.getServletPath() + Strings.nullToEmpty(httpRequest.getPathInfo()) + "?" + httpRequest.getQueryString(); return requestPathWithQueryString; }