List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:net.community.chest.gitcloud.facade.backend.git.GitBackendServlet.java
private void logHeaders(HttpServletRequest req, Map<String, String> hdrsMap, String hdrsType) { for (Map.Entry<String, String> hdrEntry : hdrsMap.entrySet()) { String hdrName = hdrEntry.getKey(), hdrValue = hdrEntry.getValue(); logger.trace("service(" + req.getMethod() + ")[" + req.getRequestURI() + "][" + req.getQueryString() + "]" + " " + hdrsType + " " + hdrName + ": " + hdrValue); }// w w w.ja v a 2s.c o m }
From source file:EditForm.java
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // change the following parameters to connect to the oracle database String photo_id = request.getQueryString(); PrintWriter out = response.getWriter(); // Check to makes sure the user is logged in String userid = ""; Cookie login_cookie = null;// ww w. j a v a 2 s .c o m Cookie cookie = null; Cookie[] cookies = null; // Get an array of cookies associated with this domain cookies = request.getCookies(); // If any cookies were found, see if any of them contain a valid login. if (cookies != null) { for (int i = 0; i < cookies.length; i++) { cookie = cookies[i]; // out.println(cookie.getName()+"<br>"); // However, we only want one cookie, the one whose name matches // the // userid that has logged in on this browser. if (i != 0 && userid == "") { userid = cookie.getName(); } } } // If no login was detected, redirect the user to the login page. if (userid == "") { out.println("<a href=login.jsp>Please login to access this site.</a>"); } // Else, we have a valid session. else { out.println("<html><body><head><title>Edit Image</title></head><body ><P>"); out.println("<form name=\"EditForm\" method=\"POST\" action=\"EditImage?" + photo_id + "\"><table>"); out.println("<tr><td> Subject: <td> <input type=text size=20 name=subject>"); out.println( "<tr><td alian = right> Location: </td><td alian = left> <input type=text size=20 name=place></td></tr>"); out.println("<tr><td alian = right> Date: </td><td alian = left> <script type=\"text/javascript\"" + " src=\"http://www.snaphost.com/jquery/Calendar.aspx?dateFormat=yy-mm-dd\"></script></script> </td></tr>"); out.println( "<tr><td alian = right> Description: </td><td alian = left> <textarea name=description rows=10 cols=30></textarea></td></tr>"); out.println("<tr><td alain = right> Who Can See This Photo:"); out.println( "<td>Everyone <input class=\"everyone\" name = \"permission\" type=\"radio\" id=\"everyone\" value=\"everyone\">"); out.println( "Only Me <input class=\"useronly\" name = \"permission\" type=\"radio\" id=\"useronly\" value=\"useronly\">"); out.println( "Specific Group <input class=\"conditional_form_part_activator\" name = \"permission\" type=\"radio\" id=\"group\" value=\"group\">"); out.println( "<div class=\"conditional_form_part\">Group Name: <input class=\"groupname\" type=text size=20 name=\"groupName\"></td></select> </div></tr></td>"); out.println( "<tr><td alian = center colspan=\"2\"><input type = submit value = \"Update Image\"></td></tr></form></table></body></html>"); } }
From source file:io.apiman.gateway.platforms.servlet.GatewayServlet.java
/** * Gets the API key from the request's query string. * @param request the inbound request//from w ww . ja v a 2 s.c o m * @return the api key or null if not found */ protected String getApiKeyFromQuery(HttpServletRequest request) { String queryString = request.getQueryString(); if (queryString == null) { return null; } int idx = queryString.indexOf("apikey="); //$NON-NLS-1$ if (idx >= 0) { int endIdx = queryString.indexOf('&', idx); if (endIdx == -1) { endIdx = queryString.length(); } return queryString.substring(idx + 7, endIdx); } else { return null; } }
From source file:at.plechinger.spring.security.scribe.ScribeAuthenticationFilter.java
@Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { String callbackUrl = request.getRequestURL().append("?").append(request.getQueryString()).toString(); LOG.log(Level.DEBUG, "callbackUrl " + callbackUrl); String configMatch = request.getParameter(configMatchParameter); LOG.log(Level.DEBUG, "configMatch: " + configMatch); ProviderConfiguration providerConfiguration = getMatchedProviderConfiguration(configMatch); HttpSession session = request.getSession(true); ServiceBuilder serviceBuilder = new ServiceBuilder().provider(providerConfiguration.getApiClass()) .apiKey(providerConfiguration.getApiKey()).apiSecret(providerConfiguration.getApiSecret()) .callback(callbackUrl);//from ww w . j a v a 2 s . c om //enable debug logging if enabled if (LOG.getLevel() == Level.DEBUG) { LOG.log(Level.DEBUG, "enable scribe debug mode"); serviceBuilder.debug(); } OAuthService oAuthService = serviceBuilder.build(); if (!providerConfiguration.isAuthCodeProvided(request)) { Token requestToken = null; try { requestToken = oAuthService.getRequestToken(); } catch (UnsupportedOperationException e) { //some networks dont support request tokens (eg. Facebook) } String authUrl = oAuthService.getAuthorizationUrl(requestToken); session.setAttribute(SESSION_TOKEN, requestToken); response.sendRedirect(authUrl); return null; } else { ScribeAuthentication scribeAuthentication = new ScribeAuthentication(); String authCode = providerConfiguration.getAuthCode(request); Verifier verifier = new Verifier(authCode); Token requestToken = (Token) session.getAttribute(SESSION_TOKEN); Token accessToken = oAuthService.getAccessToken(requestToken, verifier); scribeAuthentication.setScribeToken(accessToken); scribeAuthentication.setRedirectUrl(callbackUrl); scribeAuthentication.setDetails(this.authenticationDetailsSource.buildDetails(request)); scribeAuthentication.setProviderConfiguration(providerConfiguration); AuthenticationManager authenticationManager = this.getAuthenticationManager(); Authentication success = authenticationManager.authenticate(scribeAuthentication); return success; } }
From source file:org.meruvian.yama.webapp.interceptor.OAuth2ClientContextInterceptor.java
/** * Calculate the current URI given the request. * /*from w w w . ja va 2s . co m*/ * @param request The request. * @return The current uri. */ protected String calculateCurrentUri(HttpServletRequest request) throws UnsupportedEncodingException { ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequest(request); // Now work around SPR-10172... String queryString = request.getQueryString(); boolean legalSpaces = queryString != null && queryString.contains("+"); if (legalSpaces) { builder.replaceQuery(queryString.replace("+", "%20")); } UriComponents uri = null; try { uri = builder.replaceQueryParam("code").build(true); } catch (IllegalArgumentException ex) { // ignore failures to parse the url (including query string). does't make sense // for redirection purposes anyway. return null; } String query = uri.getQuery(); if (legalSpaces) { query = query.replace("%20", "+"); } return ServletUriComponentsBuilder.fromUri(uri.toUri()).replaceQuery(query).build().toString(); }
From source file:net.shopxx.plugin.yeepayPayment.YeepayPaymentPlugin.java
@Override public boolean verifyNotify(PaymentPlugin.NotifyMethod notifyMethod, HttpServletRequest request) { PluginConfig pluginConfig = getPluginConfig(); PaymentLog paymentLog = getPaymentLog(request.getParameter("r6_Order")); Map<String, String> parameterValuesMap = WebUtils.parse(request.getQueryString(), "GBK"); Map<String, Object> parameterMap = new LinkedHashMap<String, Object>(); parameterMap.put("p1_MerId", parameterValuesMap.get("p1_MerId")); parameterMap.put("r0_Cmd", parameterValuesMap.get("r0_Cmd")); parameterMap.put("r1_Code", parameterValuesMap.get("r1_Code")); parameterMap.put("r2_TrxId", parameterValuesMap.get("r2_TrxId")); parameterMap.put("r3_Amt", parameterValuesMap.get("r3_Amt")); parameterMap.put("r4_Cur", parameterValuesMap.get("r4_Cur")); parameterMap.put("r5_Pid", parameterValuesMap.get("r5_Pid")); parameterMap.put("r6_Order", parameterValuesMap.get("r6_Order")); parameterMap.put("r7_Uid", parameterValuesMap.get("r7_Uid")); parameterMap.put("r8_MP", parameterValuesMap.get("r8_MP")); parameterMap.put("r9_BType", parameterValuesMap.get("r9_BType")); if (paymentLog != null && generateSign(parameterMap).equals(parameterValuesMap.get("hmac")) && pluginConfig.getAttribute("partner").equals(parameterValuesMap.get("p1_MerId")) && "1".equals(parameterValuesMap.get("r1_Code")) && paymentLog.getAmount().compareTo(new BigDecimal(parameterValuesMap.get("r3_Amt"))) == 0) { return true; }//from w w w. j ava 2 s . co m return false; }
From source file:io.kamax.mxisd.controller.identity.v1.SessionRestController.java
@RequestMapping(value = "/3pid/bind") String bind(HttpServletRequest request, HttpServletResponse response, @RequestParam String sid, @RequestParam("client_secret") String secret, @RequestParam String mxid) { log.info("Requested: {}", request.getRequestURL(), request.getQueryString()); try {/* ww w .j a v a 2 s. c om*/ mgr.bind(sid, secret, mxid); return "{}"; } catch (BadRequestException e) { log.info("requested session was not validated"); JsonObject obj = new JsonObject(); obj.addProperty("errcode", "M_SESSION_NOT_VALIDATED"); obj.addProperty("error", e.getMessage()); response.setStatus(HttpStatus.SC_BAD_REQUEST); return gson.toJson(obj); } finally { // If a user registers, there is no standard login event. Instead, this is the only way to trigger // resolution at an appropriate time. Meh at synapse/Riot! invMgr.lookupMappingsForInvites(); } }
From source file:com.esri.gpt.control.rest.search.DistributedSearchServlet.java
/** * Processes the HTTP request./*www . ja v a 2 s . c o m*/ * * @param request * the HTTP request. * @param response * HTTP response. * @param context * request context * @throws Exception * if an exception occurs */ @Override public void execute(HttpServletRequest request, HttpServletResponse response, RequestContext context) throws Exception { LOG.finer("Handling rest query string=" + request.getQueryString()); MessageBroker msgBroker = new FacesContextBroker(request, response).extractMessageBroker(); // parse the query RestQuery query = null; PrintWriter printWriter = null; try { query = parseRequest(request, context); if (query == null) query = new RestQuery(); this.executeQuery(request, response, context, msgBroker, query); } catch (Exception e) { LOG.log(Level.SEVERE, "Error executing query.", e); String msg = Val.chkStr(e.getMessage()); if (msg.length() == 0) msg = e.toString(); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg); } finally { printWriter = response.getWriter(); if (printWriter != null) { try { try { printWriter.flush(); } catch (Throwable e) { LOG.log(Level.FINE, "Error while flushing printwriter", e); } } catch (Throwable t) { LOG.log(Level.FINE, "Error while closing printwriter", t); } } } }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractController.java
/** * Gets the parameter string.//from w ww. ja v a 2 s .co m * * @param request the request * @return the parameter string */ private String getParameterString(HttpServletRequest request) { return request.getQueryString(); }
From source file:com.graphhopper.http.InfoServlet.java
@Override public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try {/*from www . j a v a 2s . c o m*/ writeInfos(req, res); } catch (IllegalArgumentException ex) { writeError(res, SC_BAD_REQUEST, ex.getMessage()); } catch (Exception ex) { logger.error("Error while executing request: " + req.getQueryString(), ex); writeError(res, SC_INTERNAL_SERVER_ERROR, "Problem occured:" + ex.getMessage()); } }