当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletRequest.getPathInfo方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletRequest.getPathInfo方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletRequest.getPathInfo方法的具体用法?Java HttpServletRequest.getPathInfo怎么用?Java HttpServletRequest.getPathInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getPathInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleRequest

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
protected void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException
{
	String pathInfo = request.getPathInfo();
	Extension extension = endpointTracker.getExtension(pathInfo);
	if( extension != null )
	{
		synchronized( extension )
		{
			if( !registeredServices.contains(pathInfo) )
			{
				createService(extension, pathInfo);
				registeredServices.add(pathInfo);
			}
		}
	}
	super.handleRequest(request, response);
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:CXFHandler.java

示例2: dispatch

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
public void dispatch() {
	check();
	String path;
	String pathInfo;
	ServletRequest servletRequest = getRequest();
	if (servletRequest instanceof HttpServletRequest) {
		HttpServletRequest sr = (HttpServletRequest) servletRequest;
		path = sr.getServletPath();
		pathInfo = sr.getPathInfo();
	} else {
		path = request.getServletPath();
		pathInfo = request.getPathInfo();
	}
	if (pathInfo != null) {
		path += pathInfo;
	}
	if (this.context.getDispatchersUseEncodedPaths()) {
		path = URLEncoder.DEFAULT.encode(path, "UTF-8");
	}
	dispatch(path);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:AsyncContextImpl.java

示例3: setForwardUrl

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
private void setForwardUrl(HttpServletRequest httpRequest) {
    String relativePath = "";
    if (httpRequest.getServletPath() != null) {
        relativePath += httpRequest.getServletPath();
    }
    if (httpRequest.getPathInfo() != null) {
        relativePath += httpRequest.getPathInfo();
    }
    String queryPart = getServiceDetailsQueryPart(httpRequest,
            ui.findSessionBean());
    if (queryPart != null) {
        relativePath += queryPart;
    }
    httpRequest.getSession().setAttribute(Constants.SESS_ATTR_FORWARD_URL,
            relativePath);
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:17,代码来源:ManageReviewCtrl.java

示例4: doGet

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    Principal user = req.getUserPrincipal();
    String pathInfo = req.getPathInfo();
    System.out.printf("pathInfo=%s\n", pathInfo);

    String result = "";
    if(pathInfo.endsWith("/getSubject")) {
        System.out.printf("Calling getSubject\n");
        result = getSubject(resp);
    }
    else {
        System.out.printf("Calling getPrincipalClass\n");
        result = getPrincipalClass(user);
    }
    resp.getWriter().write(result);
}
 
开发者ID:eclipse,项目名称:microprofile-jwt-auth,代码行数:18,代码来源:ServiceServlet.java

示例5: service

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
protected final void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
	IOException
{
	String path = request.getPathInfo();
	int i = path.indexOf('/', 1);
	if( i < 0 )
	{
		throw new NotFoundException(path, true);
	}

	if( path.startsWith("/") )
	{
		path = path.substring(1);
	}

	int firstPart = path.indexOf('/');
	if( firstPart < 0 )
	{
		throw new NotFoundException(path, true);
	}

	service(request, response, path.substring(0, firstPart), path.substring(firstPart + 1));
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:AbstractIdPathServlet.java

示例6: process

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
public boolean process(HttpServletRequest req, HttpServletResponse resp, FilterChain chain)
        throws IOException, ServletException {
    String pathInfo = req.getPathInfo();
    if (pathInfo != null && pathInfo.startsWith("/webhook-step/")) {
        chain.doFilter(req, resp);
        return true;
    }

    return false;
}
 
开发者ID:cpitman,项目名称:webhook-step,代码行数:12,代码来源:WebhookRootAction.java

示例7: doFilter

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
public void doFilter(final ServletRequest req, final ServletResponse resp, final FilterChain chain)
        throws ServletException, IOException {

    final HttpServletRequest request = (HttpServletRequest) req;
    final HttpServletResponse response = (HttpServletResponse) resp;

    if (request.isSecure()) {
        if (includeSubdomains) {
            response.setHeader("Strict-Transport-Security", "max-age=" + maxAge + "; includeSubDomains");
        } else {
            response.setHeader("Strict-Transport-Security", "max-age=" + maxAge + ";");
        }
    } else {
        response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
        final StringBuilder sb = new StringBuilder();
        sb.append("https://").append(request.getServerName());

        if (httpsPort != DEFAULT_HTTPS_PORT) {
            sb.append(":").append(httpsPort);
        }
        if (request.getContextPath() != null) {
            sb.append(request.getContextPath());
        }
        if (request.getServletPath() != null) {
            sb.append(request.getServletPath());
        }
        if (request.getPathInfo() != null) {
            sb.append(request.getPathInfo());
        }
        if (request.getQueryString() != null && request.getQueryString().length() > 0) {
            sb.append("?").append(request.getQueryString());
        }
        response.setHeader("Location", sb.toString());
        return;
    }
    chain.doFilter(request, response);
}
 
开发者ID:stevespringett,项目名称:Alpine,代码行数:39,代码来源:HstsFilter.java

示例8: getRequestedPath

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
private String getRequestedPath(HttpServletRequest request) {
    String path = request.getServletPath();
    if (request.getPathInfo() != null) {
        path = path + request.getPathInfo();
    }
    return path;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:8,代码来源:TestRestCsrfPreventionFilter2.java

示例9: BoxResource

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * Constructor.
 * @param cell CELL Object
 * @param boxName Box Name
 * @param cellRsCmp cellRsCmp
 * @param accessContext AccessContextオブジェクト
 * @param request HTTPリクエスト
 * @param jaxRsRequest JAX-RS用HTTPリクエスト
 */
public BoxResource(final Cell cell, final String boxName, final AccessContext accessContext,
        final CellRsCmp cellRsCmp, final HttpServletRequest request, Request jaxRsRequest) {
    // 親はなし。パス名としてとりあえずboxNameをいれておく。
    this.cell = cell;
    this.boxName = boxName;
    // this.path= path;
    this.accessContext = accessContext;

    // Boxの存在確認
    // 本クラスではBoxが存在していることを前提としているため、Boxがない場合はエラーとする。
    // ただし、boxインストールではBoxがないことを前提としているため、以下の条件に合致する場合は処理を継続する。
    // -HTTPメソッドが MKCOL である。かつ、
    // -PathInfoが インストール先Box名 で終了している。
    // (CollectionへのMKCOLの場合があるため、boxインストールであることを確認する)
    this.box = this.cell.getBoxForName(boxName);
    // boxインストールではCellレベルで動作させる必要がある。
    this.cellRsCmp = cellRsCmp;
    if (this.box != null) {
        //BoxCmp is necessary only if this Box exists
        BoxCmp davCmp = ModelFactory.boxCmp(this.box);
        this.boxRsCmp = new BoxRsCmp(cellRsCmp, davCmp, this.accessContext, this.box);
    } else {
        //This box does not exist.
        String reqPathInfo = request.getPathInfo();
        if (!reqPathInfo.endsWith("/")) {
            reqPathInfo += "/";
        }
        String pathForBox = boxName;
        if (!pathForBox.endsWith("/")) {
            pathForBox += "/";
        }
        // Unless the HTTP method is MKCOL, respond with 404.
        if (!("MKCOL".equals(jaxRsRequest.getMethod()) && reqPathInfo.endsWith(pathForBox))) {
            throw PersoniumCoreException.Dav.BOX_NOT_FOUND.params(this.cell.getUrl() + boxName);
        }
    }

}
 
开发者ID:personium,项目名称:personium-core,代码行数:48,代码来源:BoxResource.java

示例10: getRequestPath

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public static String getRequestPath(HttpServletRequest request) {
    String path = getServletPath(request);
    if (path == null || path.isEmpty()) {
        path = request.getPathInfo();
    }
    return path;
}
 
开发者ID:febit,项目名称:febit,代码行数:8,代码来源:ServletUtil.java

示例11: getPathWithinServletMapping

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * Return the path within the servlet mapping for the given request,
 * i.e. the part of the request's URL beyond the part that called the servlet,
 * or "" if the whole URL has been used to identify the servlet.
 * <p>Detects include request URL if called within a RequestDispatcher include.
 * <p>E.g.: servlet mapping = "/test/*"; request URI = "/test/a" -> "/a".
 * <p>E.g.: servlet mapping = "/test"; request URI = "/test" -> "".
 * <p>E.g.: servlet mapping = "/*.test"; request URI = "/a.test" -> "".
 * @param request current HTTP request
 * @return the path within the servlet mapping, or ""
 */
public String getPathWithinServletMapping(HttpServletRequest request) {
	String pathWithinApp = getPathWithinApplication(request);
	String servletPath = getServletPath(request);
	String path = getRemainingPath(pathWithinApp, servletPath, false);
	if (path != null) {
		// Normal case: URI contains servlet path.
		return path;
	}
	else {
		// Special case: URI is different from servlet path.
		String pathInfo = request.getPathInfo();
		if (pathInfo != null) {
			// Use path info if available. Indicates index page within a servlet mapping?
			// e.g. with index page: URI="/", servletPath="/index.html"
			return pathInfo;
		}
		if (!this.urlDecode) {
			// No path info... (not mapped by prefix, nor by extension, nor "/*")
			// For the default servlet mapping (i.e. "/"), urlDecode=false can
			// cause issues since getServletPath() returns a decoded path.
			// If decoding pathWithinApp yields a match just use pathWithinApp.
			path = getRemainingPath(decodeInternal(request, pathWithinApp), servletPath, false);
			if (path != null) {
				return pathWithinApp;
			}
		}
		// Otherwise, use the full servlet path.
		return servletPath;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:42,代码来源:UrlPathHelper.java

示例12: handle

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
    try {
        String pathInfo = request.getPathInfo();
        if (pathInfo == null || pathInfo.length() == 0 || "/".equals(pathInfo)) {
            notFoundHandler.handle(request, response);
        } else {
            // Loop through all the known URLs
            for (Map.Entry<String, Handler> entry : urlMapping.entrySet()) {
                String url = entry.getKey();
                // If this URL matches, call the handler
                if (pathInfo.startsWith(url)) {
                    Handler handler = entry.getValue();
                    handler.handle(request, response);
                    return;
                }
            }
            notFoundHandler.handle(request, response);
        }
    } catch (SecurityException se) {
        // We don't want to give the client any information about the security error, handle it with a 404.
        log.error("Security Exception: ", se);
        notFoundHandler.handle(request, response);
    } catch (Exception e) {
        exceptionHandler.setException(e);
        exceptionHandler.handle(request, response);
    }
}
 
开发者ID:devefx,项目名称:validator-web,代码行数:28,代码来源:UrlProcessor.java

示例13: doGet

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * Process a GET request for the specified resource.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    StringManager smClient = StringManager.getManager(
            Constants.Package, request.getLocales());

    // Identify the request parameters that we need
    String command = request.getPathInfo();

    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);

    String message = "";
    // Process the requested command
    if (command == null) {
        // No command == list
    } else if (command.equals("/list")) {
        // Nothing to do - always generate list
    } else if (command.equals("/add") || command.equals("/remove") ||
            command.equals("/start") || command.equals("/stop")) {
        message = smClient.getString(
                "hostManagerServlet.postCommand", command);
    } else {
        message = smClient.getString(
                "hostManagerServlet.unknownCommand", command);
    }

    list(request, response, message, smClient);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:41,代码来源:HTMLHostManagerServlet.java

示例14: doPost

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * Process a POST request for the specified resource.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    StringManager smClient = StringManager.getManager(
            Constants.Package, request.getLocales());

    // Identify the request parameters that we need
    String command = request.getPathInfo();

    String name = request.getParameter("name");
 
    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);

    String message = "";
    
    // Process the requested command
    if (command == null) {
        // No command == list
    } else if (command.equals("/add")) {
        message = add(request, name, smClient);
    } else if (command.equals("/remove")) {
        message = remove(name, smClient);
    } else if (command.equals("/start")) {
        message = start(name, smClient);
    } else if (command.equals("/stop")) {
        message = stop(name, smClient);
    } else {
        //Try GET
        doGet(request, response);
    }

    list(request, response, message, smClient);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:45,代码来源:HTMLHostManagerServlet.java

示例15: doFilter

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
		throws IOException, ServletException {

	// This filter only needs to handle WebSocket upgrade requests
	if (!sc.areEndpointsRegistered() || !UpgradeUtil.isWebSocketUpgradeRequest(request, response)) {
		chain.doFilter(request, response);
		return;
	}

	// HTTP request with an upgrade header for WebSocket present
	HttpServletRequest req = (HttpServletRequest) request;
	HttpServletResponse resp = (HttpServletResponse) response;

	// Check to see if this WebSocket implementation has a matching mapping
	String path;
	String pathInfo = req.getPathInfo();
	if (pathInfo == null) {
		path = req.getServletPath();
	} else {
		path = req.getServletPath() + pathInfo;
	}
	WsMappingResult mappingResult = sc.findMapping(path);

	if (mappingResult == null) {
		// No endpoint registered for the requested path. Let the
		// application handle it (it might redirect or forward for example)
		chain.doFilter(request, response);
		return;
	}

	UpgradeUtil.doUpgrade(sc, req, resp, mappingResult.getConfig(), mappingResult.getPathParams());
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:WsFilter.java


注:本文中的javax.servlet.http.HttpServletRequest.getPathInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。