List of usage examples for javax.servlet.http HttpServletRequest getRequestURL
public StringBuffer getRequestURL();
From source file:com.aimluck.eip.services.social.gadgets.ALGadgetContext.java
/** * *//*from ww w .j a v a2s.c om*/ public ALGadgetContext(RunData runData, String viewer, String appId, String appUrl, long moduleId) { this.runData = runData; this.viewer = viewer; this.appId = appId; this.appUrl = appUrl; this.moduleId = moduleId; HttpServletRequest request = ((JetspeedRunData) runData).getRequest(); this.activeUrl = request.getRequestURL().toString(); }
From source file:com.ari.controller.catalog.CategoryController.java
private String addSortLink(SortOption sortOption) { Map<String, String> attrs = new HashMap<String, String>(); BroadleafRequestContext blcContext = BroadleafRequestContext.getBroadleafRequestContext(); HttpServletRequest request = blcContext.getRequest(); String baseUrl = request.getRequestURL().toString(); Map<String, String[]> params = new HashMap<String, String[]>(request.getParameterMap()); String key = ProductSearchCriteria.SORT_STRING; String sortField = sortOption.getSortCondition(); List<String[]> sortedFields = new ArrayList<String[]>(); String[] paramValues = params.get(key); if (paramValues != null && paramValues.length > 0) { String sortQueries = paramValues[0]; for (String sortQuery : sortQueries.split(",")) { String[] sort = sortQuery.split(" "); if (sort.length == 2) { sortedFields.add(new String[] { sort[0], sort[1] }); }//from w w w .j a v a 2 s .c om } } boolean currentlySortingOnThisField = false; boolean currentlyAscendingOnThisField = false; for (String[] sortedField : sortedFields) { if (sortField.equals(sortedField[0])) { currentlySortingOnThisField = true; currentlyAscendingOnThisField = sortedField[1].equals("asc"); sortedField[1] = currentlyAscendingOnThisField ? "desc" : "asc"; } } String sortString = sortField; String classString = ""; if (currentlySortingOnThisField) { classString += "active "; if (currentlyAscendingOnThisField) { sortString += " desc"; classString += "asc "; } else { sortString += " asc"; classString += "desc "; } } else { sortString += " asc"; classString += "asc "; params.remove(ProductSearchCriteria.PAGE_NUMBER); } boolean allowMultipleSorts = false; if (allowMultipleSorts) { StringBuilder sortSb = new StringBuilder(); for (String[] sortedField : sortedFields) { sortSb.append(sortedField[0]).append(" ").append(sortedField[1]).append(","); } sortString = sortSb.toString(); if (sortString.charAt(sortString.length() - 1) == ',') { sortString = sortString.substring(0, sortString.length() - 1); } } params.put(key, new String[] { sortString }); String url = ProcessorUtils.getUrl(baseUrl, params); //TODO attrs.put("class", classString); attrs.put("href", url); return url; }
From source file:fr.mby.saml2.sp.impl.web.Saml20ProcessingFilter.java
protected IIncomingSaml processSaml2Request(final HttpServletRequest samlRequest) throws SamlProcessingException, UnsupportedSamlOperation { IIncomingSaml incomingSaml = null;//from w ww . ja va2 s.c o m final String endpointUrl = samlRequest.getRequestURL().toString(); final ISaml20SpProcessor spProcessor = SamlHelper.findSpProcessorToUse(endpointUrl); incomingSaml = spProcessor.processSaml20IncomingRequest(samlRequest); if (incomingSaml == null) { String incomingRequest = null; if (SamlHelper.isSamlRequest(samlRequest)) { incomingRequest = SamlHelper.getSamlRequest(samlRequest); } else if (SamlHelper.isSamlResponse(samlRequest)) { incomingRequest = SamlHelper.getSamlResponse(samlRequest); } Saml20ProcessingFilter.LOGGER .error(String.format("Unable to process SAML incoming request: [%s] !", incomingRequest)); } return incomingSaml; }
From source file:br.com.munif.personalsecurity.aplicacao.autorizacao.Autorizador.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String[] urlParameters = getUrlParameters(request); System.out.println("---->" + request.getRequestURL()); System.out.println("---->" + Arrays.toString(urlParameters)); response.setContentType("application/json;charset=UTF-8"); Usuario usuario = service.view(urlParameters[1]); mapper.writeValue(response.getOutputStream(), TokenAdapter.getAutorizationData(usuario, urlParameters[3])); }
From source file:com.fdu.jira.plugin.servlet.LicenseServlet.java
private void redirectToLogin(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.sendRedirect(loginUriProvider.getLoginUri(URI.create(req.getRequestURL().toString())).toASCIIString()); }
From source file:io.onedecision.engine.decisions.impl.LocationHeaderInterceptor.java
@Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { System.out.println("---Request Completed---"); if (response.getStatus() == HttpStatus.CREATED.value()) { response.setHeader("Location", String.format("%1$s", request.getRequestURL())); }//from w ww . j a va 2 s. c om }
From source file:com.doculibre.constellio.filters.LocalRequestFilter.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Set<String> acceptedAndDynamicHosts = new HashSet<String>(); acceptedAndDynamicHosts.addAll(Arrays.asList(ACCEPTED_HOSTS)); // Solution adapted from http://www.exampledepot.com/egs/java.net/Local.html String hostName = InetAddress.getLocalHost().getHostName(); InetAddress addrs[] = InetAddress.getAllByName(hostName); for (InetAddress addr : addrs) { String hostAddress = addr.getHostAddress(); acceptedAndDynamicHosts.add(hostAddress); }//from w ww . ja va 2 s . c om boolean valid; if (isIgnoredRequest(request) || isFileRequest(request)) { valid = true; } else { valid = false; String remoteHost = request.getRemoteHost(); for (String acceptedHost : acceptedAndDynamicHosts) { if (remoteHost.equals(acceptedHost)) { valid = true; } } } if (valid) { // Pass control on to the next filter chain.doFilter(request, response); } else { HttpServletRequest httpRequest = (HttpServletRequest) request; throw new ServletException("Cannot send request to a servlet from outside the Web application : " + httpRequest.getRequestURL()); } }
From source file:ua.aits.sdolyna.controller.MainController.java
@RequestMapping(value = { "/500", "/Sdolyna/500" }) public ModelAndView error500(HttpServletRequest request, HttpServletResponse response) { Throwable exception = (Throwable) request.getAttribute("javax.servlet.error.exception"); String url = request.getRequestURL().toString() + "?" + request.getQueryString(); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw);//from w w w . ja v a 2 s .co m helpers.sendMail(url, sw.toString()); ModelAndView model = new ModelAndView("/error/500"); model.addObject("lan", "en"); TranslateElements translate = new TranslateElements("en"); model.addObject("lan", "en"); model.addObject("translate", translate); return model; }
From source file:fr.mby.saml2.sp.impl.BasicSaml20SpFacade.java
protected IIncomingSaml processSaml20IncomingRequestInternal(final HttpServletRequest request) throws SamlProcessingException, UnsupportedSamlOperation { IIncomingSaml incomingSaml = null;//from ww w.ja v a2s.c o m final String endpointUrl = request.getRequestURL().toString(); final ISaml20SpProcessor spProcessor = SamlHelper.findSpProcessorToUse(endpointUrl); incomingSaml = spProcessor.processSaml20IncomingRequest(request); if (incomingSaml == null) { String incomingRequest = null; if (SamlHelper.isSamlRequest(request)) { incomingRequest = SamlHelper.getSamlRequest(request); } else if (SamlHelper.isSamlResponse(request)) { incomingRequest = SamlHelper.getSamlResponse(request); } BasicSaml20SpFacade.LOGGER .error(String.format("Unable to process SAML incoming request: [%s] !", incomingRequest)); } return incomingSaml; }
From source file:com.bluexml.side.Framework.alfresco.languagepicker.MyWebScriptServlet.java
protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { if (logger.isDebugEnabled()) logger.debug("Processing request (" + req.getMethod() + ") " + req.getRequestURL() + (req.getQueryString() != null ? "?" + req.getQueryString() : "")); if (req.getCharacterEncoding() == null) { req.setCharacterEncoding("UTF-8"); }// w w w. ja va2 s . c o m setUserLanguage(req); try { WebScriptServletRuntime runtime = new WebScriptServletRuntime(container, authenticatorFactory, req, res, serverProperties); runtime.executeScript(); } finally { // clear threadlocal I18NUtil.setLocale(null); } }