本文整理匯總了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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());
}