Example usage for javax.servlet.http HttpServletRequest getRequestURI

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

Introduction

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

Prototype

public String getRequestURI();

Source Link

Document

Returns the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.

Usage

From source file:com.digitalmisfits.support.compat.jasig.cas.web.flow.CasDefaultFlowUrlHandler.java

@Override
public String createFlowExecutionUrl(final String flowId, final String flowExecutionKey,
        final HttpServletRequest request) {
    final StringBuilder builder = new StringBuilder();
    builder.append(request.getRequestURI());
    builder.append("?");
    @SuppressWarnings("unchecked")
    final Map<String, Object> flowParams = new LinkedHashMap<String, Object>(request.getParameterMap());
    flowParams.put(this.flowExecutionKeyParameter, flowExecutionKey);
    appendQueryParameters(builder, flowParams, getEncodingScheme(request));
    return builder.toString();
}

From source file:io.github.microcks.web.ResourceController.java

@RequestMapping(value = "/resources/{name}", method = RequestMethod.GET)
public ResponseEntity<?> execute(@PathVariable("name") String name, HttpServletRequest request) {
    String extension = request.getRequestURI().substring(request.getRequestURI().lastIndexOf('.'));
    name = name + extension;/* w ww  .j a  va  2s .  c  om*/

    log.info("Requesting resource named " + name);

    Resource resource = resourceRepository.findByName(name);
    if (resource != null) {
        return new ResponseEntity<Object>(resource.getContent(), HttpStatus.OK);
    }
    return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
}

From source file:org.keycloak.testsuite.ApplicationServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String title = "";
    if (req.getRequestURI().endsWith("auth")) {
        title = "AUTH_RESPONSE";
    } else if (req.getRequestURI().endsWith("logout")) {
        title = "LOGOUT_REQUEST";
    } else {/*from  w  w  w  . j  a  v a 2 s.c o  m*/
        title = "APP_REQUEST";
    }

    PrintWriter pw = resp.getWriter();
    pw.printf("<html><head><title>%s</title></head><body>", title);

    pw.printf(LINK, "http://localhost:8081/auth/rest/realms/test/account", "account", "account");

    pw.print("</body></html>");
    pw.flush();
}

From source file:org.guanxi.idp.service.UrlRewriter.java

/**
 * Rewrites an incoming URL based on the rules defined in services/url-rewriter.xml
 * If you want to map /SSO to /shibb/sso, do this:
 * -- in web.xml, add a servlet-mapping for /SSO to the Guanxi Identity Provider servlet
 * -- in services/url-rewriter.xml, add <entry key="SSO" value="/shibb/sso" />, omit the leading /
 *
 * @param request Standard HttpServletRequest
 * @param response Standard HttpServletResponse
 * @param object handler// w w  w . j a  v  a2 s.com
 * @return true
 * @throws Exception if an error occurs
 */
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object object)
        throws Exception {
    String[] parts = request.getRequestURI().split("/");
    if (urlMaps.containsKey(parts[parts.length - 1])) {
        request.getRequestDispatcher((String) urlMaps.get(parts[parts.length - 1])).forward(request, response);
        return false;
    }
    return true;
}

From source file:org.uaa.security.core.LogoutHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
    String uri = request.getRequestURI();

    // clear Cookies
    Cookie[] cookies = request.getCookies();
    for (Cookie cookie : cookies) {
        log.debug(cookie.getName());//  ww  w . j  av  a  2 s.com

        cookie.setMaxAge(0);
        response.addCookie(cookie);
    }

    // set response message
    ResponseWithStatus res = new ResponseWithStatus(uri, "0", ConfigUtil.getValue("00000"));
    response.setContentType("application/json;charset=UTF-8");
    response.getOutputStream().write(res.toJson().getBytes());
    return;
}

From source file:org.brutusin.rpc.websocket.WebsocketFilter.java

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    if (isDisabled || httpRequest.getRequestURI() == null
            || !(httpRequest.getRequestURI().substring(httpRequest.getContextPath().length())
                    .startsWith(RpcConfig.getInstance().getPath() + "/wskt"))) {
        chain.doFilter(request, response);
        return;//from  w  ww . jav a 2  s.  c o  m
    }
    final Map<String, String[]> fakedParams = Collections.singletonMap("requestId",
            new String[] { String.valueOf(counter.getAndIncrement()) });
    HttpServletRequestWrapper wrappedRequest = new HttpServletRequestWrapper(httpRequest) {
        @Override
        public Map<String, String[]> getParameterMap() {
            return fakedParams;
        }
    };
    /*
     * current request is needed for getEndpointInstance(). In glassfish getEndpointInstance() is executed out this filter chain, 
     * but inside whole request-response cycle (controlled by the overall listener that sets and removes GlobalThreadLocal)
     */
    if (GlobalThreadLocal.get() == null) {
        throw new AssertionError();
    }
    Object securityContext;
    if (ClassUtils.isPresent("org.springframework.security.core.context.SecurityContextHolder",
            RpcWebInitializer.class.getClassLoader())) {
        securityContext = SecurityContextHolder.getContext();
    } else {
        securityContext = null;
    }
    GlobalThreadLocal.set(new GlobalThreadLocal(wrappedRequest, securityContext)); // override current request with the one with faked params and security context
    chain.doFilter(wrappedRequest, response);
}

From source file:com.cognifide.aet.rest.LockServlet.java

private String getKey(HttpServletRequest req) {
    return StringUtils.substringAfter(req.getRequestURI(), Helper.getLocksPath()).replace(Helper.PATH_SEPARATOR,
            "");/*from  w  ww. j ava 2 s . c  o m*/
}

From source file:com.dcs.controller.filter.SecurityServlet.java

public String getRequestURI(HttpServletRequest request) {
    return request.getRequestURI();
}

From source file:eu.openanalytics.shinyproxy.controllers.BaseController.java

protected String getAppName(HttpServletRequest request) {
    return getAppName(request.getRequestURI());
}

From source file:de.appsolve.padelcampus.admin.controller.general.AdminGeneralModulesBlogController.java

private Module getModule(HttpServletRequest request) {
    String requestURI = request.getRequestURI();
    int index = requestURI.indexOf(getModuleName()) + getModuleName().length() + 1;
    int toIndex = requestURI.indexOf('/', index);
    toIndex = (toIndex == -1) ? requestURI.length() : toIndex;
    String moduleIdentifier = requestURI.substring(index, toIndex);
    return moduleDAO.findById(Long.parseLong(moduleIdentifier));
}