List of usage examples for javax.servlet.http HttpServletRequest getQueryString
public String getQueryString();
From source file:net.lightbody.bmp.proxy.jetty.servlet.AdminServlet.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getQueryString() != null && request.getQueryString().length() > 0) { String target = doAction(request); response.sendRedirect(request.getContextPath() + request.getServletPath() + (request.getPathInfo() != null ? request.getPathInfo() : "") + (target != null ? ("#" + target) : "")); return;//from www . j a v a2s. c om } Page page = new Page(); page.title(getServletInfo()); page.addHeader(""); page.attribute("text", "#000000"); page.attribute(Page.BGCOLOR, "#FFFFFF"); page.attribute("link", "#606CC0"); page.attribute("vlink", "#606CC0"); page.attribute("alink", "#606CC0"); page.add(new Block(Block.Bold).add(new Font(3, true).add(getServletInfo()))); page.add(Break.rule); Form form = new Form(request.getContextPath() + request.getServletPath() + "?A=exit"); form.method("GET"); form.add(new Input(Input.Submit, "A", "Exit All Servers")); page.add(form); page.add(Break.rule); page.add(new Heading(3, "Components:")); List sList = new List(List.Ordered); page.add(sList); String id1; int i1 = 0; Iterator s = _servers.iterator(); while (s.hasNext()) { id1 = "" + i1++; HttpServer server = (HttpServer) s.next(); Composite sItem = sList.newItem(); sItem.add("<B>HttpServer "); sItem.add(lifeCycle(request, id1, server)); sItem.add("</B>"); sItem.add(Break.line); sItem.add("<B>Listeners:</B>"); List lList = new List(List.Unordered); sItem.add(lList); HttpListener[] listeners = server.getListeners(); for (int i2 = 0; i2 < listeners.length; i2++) { HttpListener listener = listeners[i2]; String id2 = id1 + ":" + listener; lList.add(lifeCycle(request, id2, listener)); } Map hostMap = server.getHostMap(); sItem.add("<B>Contexts:</B>"); List hcList = new List(List.Unordered); sItem.add(hcList); Iterator i2 = hostMap.entrySet().iterator(); while (i2.hasNext()) { Map.Entry hEntry = (Map.Entry) (i2.next()); String host = (String) hEntry.getKey(); PathMap contexts = (PathMap) hEntry.getValue(); Iterator i3 = contexts.entrySet().iterator(); while (i3.hasNext()) { Map.Entry cEntry = (Map.Entry) (i3.next()); String contextPath = (String) cEntry.getKey(); java.util.List contextList = (java.util.List) cEntry.getValue(); Composite hcItem = hcList.newItem(); if (host != null) hcItem.add("Host=" + host + ":"); hcItem.add("ContextPath=" + contextPath); String id3 = id1 + ":" + host + ":" + (contextPath.length() > 2 ? contextPath.substring(0, contextPath.length() - 2) : contextPath); List cList = new List(List.Ordered); hcItem.add(cList); for (int i4 = 0; i4 < contextList.size(); i4++) { String id4 = id3 + ":" + i4; Composite cItem = cList.newItem(); HttpContext hc = (HttpContext) contextList.get(i4); cItem.add(lifeCycle(request, id4, hc)); cItem.add("<BR>ResourceBase=" + hc.getResourceBase()); cItem.add("<BR>ClassPath=" + hc.getClassPath()); List hList = new List(List.Ordered); cItem.add(hList); int handlers = hc.getHandlers().length; for (int i5 = 0; i5 < handlers; i5++) { String id5 = id4 + ":" + i5; HttpHandler handler = hc.getHandlers()[i5]; Composite hItem = hList.newItem(); hItem.add(lifeCycle(request, id5, handler, handler.getName())); if (handler instanceof ServletHandler) { hItem.add("<BR>" + ((ServletHandler) handler).getServletMap()); } } } } } sItem.add("<P>"); } response.setContentType("text/html"); response.setHeader("Pragma", "no-cache"); response.setHeader("Cache-Control", "no-cache,no-store"); Writer writer = response.getWriter(); page.write(writer); writer.flush(); }
From source file:com.eharmony.services.swagger.SwaggerResourceServer.java
/** * Provides initial entry point by redirecting Swagger js with desired target url as parameter. *///from w w w.ja v a 2 s . c o m @GET public Response getBase(@Context HttpServletRequest request) throws IOException, URISyntaxException { String cp = contextPath; if (StringUtils.isBlank(contextPath)) { cp = request.getContextPath(); } if (!cp.endsWith("/")) { cp += "/"; } String loc = "swagger-ui/index.html?url=" + cp + "swagger.json"; String queryString = request.getQueryString(); if (StringUtils.isNotBlank(queryString)) { loc += "&" + queryString; } return Response.seeOther(new URI(loc)).build(); }
From source file:com.pedra.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>//from w ww. j a va 2s.c o m * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); //set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel())) // Restrict to B2C channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (isNotActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); //set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:com.sixt.service.framework.jetty.RpcReadException.java
public String toJson(HttpServletRequest req) { JsonObject obj = new JsonObject(); Enumeration<String> h = req.getHeaderNames(); while (h.hasMoreElements()) { String hKey = h.nextElement(); String hValue = req.getHeader(hKey); obj.addProperty("request_header_" + hKey, hValue); }/*from w ww. j a v a2 s . co m*/ obj.addProperty("exception_message", this.getMessage()); obj.addProperty("request_query_string", req.getQueryString()); obj.addProperty("request_url", req.getRequestURL().toString()); obj.addProperty("request_remote_addr", req.getRemoteAddr()); obj.addProperty("request_remote_port", req.getRemotePort()); obj.addProperty("request_remote_host", req.getRemoteHost()); obj.addProperty("request_remote_user", req.getRemoteUser()); String readBody = "success"; // read the whole remaining body and put the joined base64 encoded message into the json object try { byte[] ba = IOUtils.toByteArray(this.in); byte[] combined; if ((ba != null) && (this.incomplete != null)) { combined = new byte[ba.length + this.incomplete.length]; System.arraycopy(incomplete, 0, combined, 0, this.incomplete.length); System.arraycopy(ba, 0, combined, this.incomplete.length, ba.length); obj.addProperty("request_body", Base64.getEncoder().encodeToString(combined)); } else if (ba != null) { combined = ba; } else if (this.incomplete != null) { combined = this.incomplete; } else { readBody = "body is empty"; } } catch (Exception ex) { readBody = String.format("failed because: %s", ex.getCause()); } obj.addProperty("read_body", readBody); return obj.toString(); }
From source file:de.highbyte_le.weberknecht.security.filters.AuthenticationFilter.java
/** * do authentication, if parameters are present and check session for valid login * @return true, if the user is authenticated *//*from w ww . j a v a 2s . com*/ protected boolean handleAuthentication(HttpServletRequest request) { HttpSession session = request.getSession(); String reqUser = null; String reqPwd = null; String reqDoParam = null; //Erst prfen, ob Authentifizierungsversuch vorliegt, da es nach getParameter() nicht mehr mglich ist auf gepostete formulare zuzugreifen. String queryString = request.getQueryString(); if (queryString != null && (queryString.contains(doParameter + "=auth") || queryString.contains(doParameter + "=signout"))) { // Get user id and password from request parameters reqUser = request.getParameter("user"); reqPwd = request.getParameter("pwd"); reqDoParam = request.getParameter(doParameter); } boolean success = false; // If user id and password are present, authenticate if (reqUser != null && reqPwd != null && reqDoParam != null && reqDoParam.equalsIgnoreCase("auth")) { session.removeAttribute("user_auth"); //first remove the previous login from session if (authentication != null) { Integer userId = authentication.authenticate(reqUser, reqPwd); if (userId != null) { //successful login session.setAttribute("user_auth", new UserAuthentication(userId, true)); success = true; } } else { logger.fatal("handleAuthentication() - no Authenticator object set!"); } } else if (reqDoParam != null && reqDoParam.equalsIgnoreCase("signout")) { session.removeAttribute("user_auth"); //remove the previous login from session } else { //use login information from session UserAuthentication userAuth = (UserAuthentication) session.getAttribute("user_auth"); if (userAuth != null) { success = userAuth.isAuthenticated(); } } return success; }
From source file:com.acc.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>/*from w w w . j a v a 2 s . co m*/ * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); //set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel())) // Restrict to B2C channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); //set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:com.exxonmobile.ace.hybris.storefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>// w w w . j av a 2 s . c o m * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); // set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2B.equals(cmsSiteModel.getChannel())) // Restrict to B2B channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); // set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:io.druid.server.AsyncQueryForwardingServlet.java
protected URI rewriteURI(HttpServletRequest request, String scheme, String host) { return makeURI(scheme, host, request.getRequestURI(), request.getQueryString()); }
From source file:de.hybris.platform.ytelcoacceleratorstorefront.filters.cms.CMSSiteFilter.java
/** * Processing normal request (i.e. when user goes directly to that application - not from cmscockpit) * <p/>//from w ww . j av a2 s. c o m * <b>Note:</b> <br/> * We preparing application by setting correct: * <ul> * <li>Current Site</li> * <li>Current Catalog Versions</li> * <li>Enabled language fallback</li> * </ul> * * @see ContextInformationLoader#initializeSiteFromRequest(String) * @see ContextInformationLoader#setCatalogVersions() * @param httpRequest * current request * @param httpResponse * the http response * @throws java.io.IOException */ protected boolean processNormalRequest(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws IOException { final String queryString = httpRequest.getQueryString(); final String currentRequestURL = httpRequest.getRequestURL().toString(); //set current site CMSSiteModel cmsSiteModel = getCurrentCmsSite(); if (cmsSiteModel == null || StringUtils.contains(queryString, CLEAR_CMSSITE_PARAM)) { final String absoluteURL = StringUtils.removeEnd(currentRequestURL, "/") + (StringUtils.isBlank(queryString) ? "" : "?" + queryString); cmsSiteModel = getContextInformationLoader().initializeSiteFromRequest(absoluteURL); } if (cmsSiteModel == null) { // Failed to lookup CMS site httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, MISSING_CMS_SITE_ERROR_MESSAGE); return false; } else if (!SiteChannel.B2C.equals(cmsSiteModel.getChannel()) && !SiteChannel.TELCO.equals(cmsSiteModel.getChannel())) // Restrict to B2C and Telco channel { // CMS site that we looked up was for an unsupported channel httpResponse.sendError(MISSING_CMS_SITE_ERROR_STATUS, INCORRECT_CMS_SITE_CHANNEL_ERROR_MESSAGE); return false; } if (!isActiveSite(cmsSiteModel)) { throw new IllegalStateException( "Site is not active. Active flag behaviour must be implement for this project."); } getContextInformationLoader().setCatalogVersions(); //set fall back language enabled setFallbackLanguage(httpRequest, Boolean.TRUE); return true; }
From source file:org.wso2.carbon.core.transports.CarbonServlet.java
/** * WSAS specific GET implementation/*from w w w. ja v a 2 s .c om*/ */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { initContextRoot(request); boolean isRequestHandled = false; try { String queryString = request.getQueryString(); if (queryString != null) { for (String item : getRequestProcessors.keySet()) { if (queryString.indexOf(item) == 0 && (queryString.equals(item) || queryString.indexOf('&') == item.length() || queryString.indexOf('=') == item.length())) { processWithGetProcessor(request, response, item); isRequestHandled = true; break; } } } if (!isRequestHandled) { handleRestRequest(request, response); // Assume that this is a REST request } } catch (Exception e) { throw AxisFault.makeFault(e); } }