Example usage for javax.servlet.http HttpServletRequest getRequestURL

List of usage examples for javax.servlet.http HttpServletRequest getRequestURL

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getRequestURL.

Prototype

public StringBuffer getRequestURL();

Source Link

Document

Reconstructs the URL the client used to make the request.

Usage

From source file:br.com.munif.personalsecurity.aplicacao.autorizacao.GenericTokenApi.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    String[] urlParameters = getUrlParameters(request);
    System.out.println("---->" + request.getRequestURL());
    System.out.println("---->" + Arrays.toString(urlParameters));
    Usuario usuario = service.view(urlParameters[1]);
    response.setContentType("application/json;charset=UTF-8");
    //[{"id":1,"oi":null,"name":"GUMGA","subOrganizations":null,"mainOrganization":{"value":true},"hierarchyCode":"1.","internalCode":null,"isSoftwareHouse":false,"securityManager":false,"mainUser":null,"logo":null,"maxShortTokens":0}]
    Map resposta = new HashMap();
    resposta.put("id", usuario.getId());
    resposta.put("name", usuario.getNome());
    resposta.put("hierarchyCode", usuario.getPid());
    mapper.writeValue(response.getOutputStream(), new Object[] { resposta });

}

From source file:de.drv.dsrv.utility.spring.web.LoggingHandlerInterceptor.java

@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response,
        final Object handler) {
    // Prfe, ob Log-Level aktiviert ist
    if (LOG.isDebugEnabled()) {
        // Schreibe Log-Meldung
        LOG.debug("URL " + request.getRequestURL() + " aufgerufen");

        // Schreibe Parameter
        for (final Object key : request.getParameterMap().keySet()) {
            // Prfe, ob Parameter gltig (ungleich null) ist
            if (key != null) {
                // Prfe, ob sich um ein Passwort handelt
                if (key.toString().matches(PASSWORT_REGEX)) {
                    LOG.debug("+ Parameter: " + key.toString() + "=********");
                } else {
                    LOG.debug("+ Parameter: " + key.toString() + "=" + request.getParameter(key.toString()));
                }/*ww w  .j  a  v a  2 s  .  c  om*/
            }
        }
    }

    // Fhre weitere Verarbeitung durch
    return true;
}

From source file:io.kamax.mxisd.controller.identity.v1.SessionController.java

@RequestMapping(value = "/validate/{medium}/submitToken", method = GET)
public String validate(HttpServletRequest request, HttpServletResponse response, @RequestParam String sid,
        @RequestParam("client_secret") String secret, @RequestParam String token, Model model) {
    log.info("Requested: {}?{}", request.getRequestURL(), request.getQueryString());

    ValidationResult r = mgr.validate(sid, secret, token);
    log.info("Session {} was validated", sid);
    if (r.getNextUrl().isPresent()) {
        String url = r.getNextUrl().get();
        try {//from www. jav  a  2s .  c  o  m
            url = new URL(url).toString();
        } catch (MalformedURLException e) {
            log.info("Session next URL {} is not a valid one, will prepend public URL {}", url,
                    srvCfg.getPublicUrl());
            url = srvCfg.getPublicUrl() + r.getNextUrl().get();
        }
        log.info("Session {} validation: next URL is present, redirecting to {}", sid, url);
        return "redirect:" + url;
    } else {
        if (r.isCanRemote()) {
            String url = srvCfg.getPublicUrl()
                    + RemoteIdentityAPIv1.getRequestToken(r.getSession().getId(), r.getSession().getSecret());
            model.addAttribute("remoteSessionLink", url);
            return viewCfg.getSession().getLocalRemote().getOnTokenSubmit().getSuccess();
        } else {
            return viewCfg.getSession().getLocal().getOnTokenSubmit().getSuccess();
        }
    }
}

From source file:org.apache.cxf.fediz.service.idp.FederationEntryPoint.java

protected String extractFullContextPath(HttpServletRequest request) throws MalformedURLException {
    String result = null;//from w  w w . j  a v a 2  s  .  c o  m
    String contextPath = request.getContextPath();
    String requestUrl = request.getRequestURL().toString();

    String requestPath = new URL(requestUrl).getPath();
    // Cut request path of request url and add context path if not ROOT
    if (requestPath != null && requestPath.length() > 0) {
        int lastIndex = requestUrl.lastIndexOf(requestPath);
        result = requestUrl.substring(0, lastIndex);
    } else {
        result = requestUrl;
    }
    if (contextPath != null && contextPath.length() > 0) {
        // contextPath contains starting slash
        result = result + contextPath;
    }
    if (result.charAt(result.length() - 1) != '/') {
        result = result + "/";
    }
    return result;
}

From source file:eu.trentorise.smartcampus.permissionprovider.controller.GlobalDefaultExceptionHandler.java

public ModelAndView resolveException(HttpServletRequest aReq, HttpServletResponse aRes, Object aHandler,
        Exception anExc) {/*from   w w  w  .j  a va 2  s  .co m*/
    // Otherwise setup and send the user to a default error-view.
    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", anExc);
    mav.addObject("url", aReq.getRequestURL());
    mav.setViewName(DEFAULT_ERROR_VIEW);
    return mav;
}

From source file:io.hedwig.petclinic.ui.web.GeneralController.java

@ExceptionHandler(Exception.class)
public ModelAndView handleException(HttpServletRequest req, Exception e) {
    logger.debug("In handleException");

    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", e);
    mav.addObject("timestamp", new Date());
    mav.addObject("url", req.getRequestURL());
    mav.setViewName("exception");
    return mav;//from  ww w.  j  a va 2 s. c  om
}

From source file:info.magnolia.cms.util.ServletUtil.java

/**
 * Returns the original request url. If the request has been forwarded it reconstructs the url from  request
 * attributes. The returned url is not decoded.
 *///from  w ww.  jav a 2s  .  c o m
public static String getOriginalRequestURLIncludingQueryString(HttpServletRequest request) {
    if (request.getAttribute(FORWARD_REQUEST_URI_ATTRIBUTE) != null) {
        StringBuilder builder = new StringBuilder();

        String scheme = request.getScheme();
        builder.append(scheme).append("://").append(request.getServerName());

        int port = request.getServerPort();
        if ((scheme.equalsIgnoreCase("http") && port == 80)
                || (scheme.equalsIgnoreCase("https") && port == 443)) {
            // adding port is not necessary
        } else {
            builder.append(":").append(port);
        }

        String requestUri = (String) request.getAttribute(FORWARD_REQUEST_URI_ATTRIBUTE);
        builder.append(requestUri);

        String queryString = (String) request.getAttribute(FORWARD_QUERY_STRING_ATTRIBUTE);
        if (StringUtils.isNotEmpty(queryString)) {
            builder.append("?").append(queryString);
        }

        return builder.toString();
    }
    StringBuilder builder = new StringBuilder();
    builder.append(request.getRequestURL());
    String queryString = request.getQueryString();
    if (StringUtils.isNotEmpty(queryString)) {
        builder.append("?").append(queryString);
    }
    return builder.toString();
}

From source file:com.sun.identity.provider.springsecurity.OpenSSOAuthenticationEntryPoint.java

private String buildGotoUrl(HttpServletRequest request) {
    StringBuffer result;/*from ww  w .ja v  a2 s  .c  o  m*/
    if (getGotoUrl() != null && getGotoUrl().length() > 0) {
        result = new StringBuffer(getGotoUrl());
    } else {
        result = request.getRequestURL();
    }
    return result.toString();
}

From source file:edu.du.penrose.systems.fedoraApp.web.FedoraAppController.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    logger.info("FedoraAppController searching for view:" + request.getRequestURL());
    ////  w ww  .ja  v  a2 s.  c  o m
    //           if ( request.getRequestURL().toString().endsWith( "/batchIngest.htm" )){
    //              return new ModelAndView( FedoraAppConstants.JSP_URI_PATH+"batchIngest.jsp" );         
    //           }

    if (request.getRequestURL().toString().toLowerCase().endsWith("/error.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "error.jsp");
    }

    if (request.getRequestURL().toString().toLowerCase().endsWith("/hello.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "hello.jsp");
    }

    if (request.getRequestURL().toString().toLowerCase().endsWith("/index.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "hello.jsp");
    }

    if (request.getRequestURL().toString().toLowerCase().endsWith("/viewrunningingests.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "viewRunningIngests.jsp");
    }

    if (request.getRequestURL().toString().endsWith("/getFedoraObj")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "getFedoraObj.jsp");
    }

    if (request.getRequestURL().toString().endsWith("/searchFedora")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "searchFedora.jsp");
    }

    if (request.getRequestURL().toString().endsWith("/loginFedora")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "loginFedora.jsp");
    }

    if (request.getRequestURL().toString().endsWith("/viewFO.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "viewFO.jsp");
    }

    if (request.getRequestURL().toString().endsWith("/batchIngestReport.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "batchIngestReport.jsp");
    }

    if (request.getRequestURL().toString().endsWith("/batchIngestPidReport.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "batchIngestPidReport.jsp");
    }

    //            if ( request.getRequestURL().toString().endsWith( "/batchIngestStatus.htm" )){
    //                return new ModelAndView( MyServletContextListener.JSP_URI_PATH+"batchIngestStatus.jsp" );   
    //            }

    if (request.getRequestURL().toString().endsWith("/versions.htm")) {
        return new ModelAndView(MyServletContextListener.JSP_URI_PATH + "versions.jsp");
    }

    throw new PageNotFoundNonCheckedException("Page not found");

}

From source file:de.mare.mobile.ui.security.AuthFilter.java

/**
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse,
 *      javax.servlet.FilterChain)//from   ww w. j  av  a  2 s. c  o m
 */
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    final HttpServletRequest request = (HttpServletRequest) servletRequest;
    final String requestURI = request.getRequestURL().toString();
    LOG.debug("Current request url for filtering is " + requestURI);
    this.doFilterInternal(servletRequest, response, chain);
}