List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:de.innovationgate.wgpublisher.WGPRequestPath.java
public static URL buildCompleteURL(HttpServletRequest request) throws MalformedURLException, URIException { StringBuffer url = new StringBuffer(); url.append((String) request.getAttribute(WGAFilter.REQATTRIB_ORIGINAL_URL)); String qs = request.getQueryString(); if (qs != null) { url.append("?").append(qs); }// w ww . j a va2 s .co m return new URL(url.toString()); }
From source file:eu.simpaticoproject.ife.controller.ProxyController.java
@RequestMapping(value = "/api/proxy/textenrich", method = RequestMethod.GET) public @ResponseBody HttpEntity<String> textEnrichment(@RequestParam String text, @RequestParam String lex, HttpServletRequest request) throws Exception { String urlToCall = textEnrichUrl; if (Utils.isNotEmpty(request.getQueryString())) { urlToCall = urlToCall + "?lang=it&lex=" + URLEncoder.encode(lex, "UTF-8") + "&text=" + URLEncoder.encode(text, "UTF-8"); }//from w w w .j av a 2s.c om if (logger.isInfoEnabled()) { logger.info("textenrich:" + urlToCall); } GetMethod responseConnection = HTTPUtils.getConnection(urlToCall, null, null, null, null, request); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json; charset=UTF-8"); InputStream is = responseConnection.getResponseBodyAsStream(); byte[] byteStream = IOUtils.toByteArray(is); String body = new String(byteStream, "UTF-8"); return new HttpEntity<String>(body, headers); }
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 ww w .ja va 2s . c o 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:be.fedict.eid.idp.sp.protocol.openid.AuthenticationResponseServlet.java
/** * {@inheritDoc}//from w ww. j ava 2 s . co m */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { LOG.debug("doGet: size=" + request.getQueryString().length()); String openIdMode = request.getParameter("openid.mode"); if ("id_res".equals(openIdMode)) { try { doIdRes(request, response); } catch (Exception e) { showErrorPage(e.getMessage(), e, request, response); } } }
From source file:com.github.reverseproxy.ReverseProxyJettyHandler.java
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String requestPath = request.getRequestURI(); String queryString = request.getQueryString(); String method = request.getMethod(); String requestBody = IOUtils.toString(request.getReader()); requestBody = URLDecoder.decode(requestBody, "UTF-8"); //TODO String urlWithFullPath = StringUtils.isEmpty(queryString) ? requestPath : requestPath + "?" + queryString; String forwardUrl = getForwardUrl(urlWithFullPath); if (forwardUrl == null) { throw new IOException("Invalid forwardurl for : " + requestPath); }//from www . j a va 2 s .c om URLConnection urlConnection = getUrlConnection(request, method, requestBody, forwardUrl); writeResponse(urlConnection, response); }
From source file:io.kamax.mxisd.controller.identity.v1.SessionRestController.java
@RequestMapping(value = "/validate/{medium}/requestToken") String init(HttpServletRequest request, HttpServletResponse response, @PathVariable String medium) throws IOException { log.info("Request {}: {}", request.getMethod(), request.getRequestURL(), request.getQueryString()); if (ThreePidMedium.Email.is(medium)) { SessionEmailTokenRequestJson req = parser.parse(request, SessionEmailTokenRequestJson.class); return gson.toJson( new Sid(mgr.create(request.getRemoteHost(), new ThreePid(req.getMedium(), req.getValue()), req.getSecret(), req.getAttempt(), req.getNextLink()))); }/*from w ww . j a v a 2 s. co m*/ if (ThreePidMedium.PhoneNumber.is(medium)) { SessionPhoneTokenRequestJson req = parser.parse(request, SessionPhoneTokenRequestJson.class); ThreePid threepid = new ThreePid(req.getMedium(), req.getValue()); String sessionId = mgr.create(request.getRemoteHost(), threepid, req.getSecret(), req.getAttempt(), req.getNextLink()); JsonObject res = new JsonObject(); res.addProperty("sid", sessionId); res.addProperty(threepid.getMedium(), threepid.getAddress()); return gson.toJson(res); } JsonObject obj = new JsonObject(); obj.addProperty("errcode", "M_INVALID_3PID_TYPE"); obj.addProperty("error", medium + " is not supported as a 3PID type"); response.setStatus(HttpStatus.SC_BAD_REQUEST); return gson.toJson(obj); }
From source file:csiro.pidsvc.servlet.info.java
/** * Echoes HTTP headers.// w ww . j a v a 2s. co m * * @param request * @param response * @throws IOException * @throws URISyntaxException */ protected void echo(HttpServletRequest request, HttpServletResponse response) throws IOException, URISyntaxException { String ret = "HTTP " + request.getMethod() + " " + request.getRequestURL() + "?" + request.getQueryString() + "\n\n"; // Retrieve HTTP headers. for (@SuppressWarnings("unchecked") Enumeration<String> header = request.getHeaderNames(); header.hasMoreElements();) { String headerName = (String) header.nextElement(); ret += headerName + ": " + request.getHeader(headerName) + "\n"; } response.setContentType("text/plain"); response.getWriter().write(ret); }
From source file:com.yahoo.dba.perf.myperf.springmvc.SigninController.java
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse resp) throws Exception { logger.info("receive url path: " + request.getContextPath() + "," + request.getRequestURI() + ", " + request.getServletPath() + ", parameters: " + request.getQueryString()); boolean failed = false; String username = request.getParameter("name"); if (username != null) { username = username.trim().toLowerCase(); //find the user from the system cache AppUser appUser = this.frameworkContext.getAuth().findUserByName(username); //sign in process boolean authed = this.frameworkContext.getAuth().login(appUser, request); if (authed)//display {/*from w ww.j a v a2 s.c o m*/ String view = getLoginSuccessView(); //if admin user, and setup not done yet, send to setup. if (appUser.isAdminUser() && !frameworkContext.getMyperfConfig().isConfigured()) view = this.getSetupView(); logger.info(appUser.getName() + " login, redirect to " + view); return new ModelAndView(new RedirectView(view)); } //if(appUser!=null && appUser.match(request.getParameter("pd")) else { failed = true; } } //if(username!=null) //not authenticated? Try again //TODO add retry count long server_ts = System.currentTimeMillis(); int seed = (int) (Math.random() * Integer.MAX_VALUE); ModelAndView mv = new ModelAndView(getLoginFormView()); mv.addObject("name", username); if (failed) mv.addObject("message", DEFAULT_ERROR); mv.addObject("help_key", "start"); mv.addObject("server_ts", server_ts); mv.addObject("ars", seed);//ars: authentication random seed //add store them in session request.getSession(true).setAttribute(AppUser.SERVER_TS, new Long(server_ts)); request.getSession().setAttribute(AppUser.RANDOM_SEED, new Integer(seed)); return mv; }
From source file:cec.easyshop.storefront.filters.StorefrontFilter.java
@Override public void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws IOException, ServletException { final HttpSession session = request.getSession(); final String queryString = request.getQueryString(); if (isSessionNotInitialized(session, queryString)) { initDefaults(request);//from w ww. java2s . co m markSessionInitialized(session); } // For secure requests ensure that the JSESSIONID cookie is visible to insecure requests if (isRequestSecure(request)) { fixSecureHttpJSessionIdCookie(request, response); } if (isGetMethod(request)) { if (StringUtils.isBlank(request.getHeader(AJAX_REQUEST_HEADER_NAME))) { String requestURL = request.getRequestURL().toString(); session.setAttribute(ORIGINAL_REFERER, StringUtils.isNotBlank(queryString) ? requestURL + "?" + queryString : requestURL); } getBrowseHistory().addBrowseHistoryEntry(new BrowseHistoryEntry(request.getRequestURI(), null)); } filterChain.doFilter(request, response); }