<li><a href="<%=
UTIL.getServletPath("/SetupPage?PG=setupusersettings") %>">
<span>Settings</span></a>
public String getServletPath(String fileName)
{
if(!fileName.startsWith("/"))
fileName = "/" + fileName;
return getContextPath() + fileName;
}
public String getContextPath()
{
try
{
return request != null ? request.getContextPath() : "";
}
catch(Exception ex)
{
DBGlobals.Error(ex);
return "";
}
}
public i开发者_如何学JAVAnterface HttpServletRequest extends javax.servlet.ServletRequest {
java.lang.String getContextPath();
I have a few questions..
- What does getServletPath do?
- What does getContextPath do?
- Canyone explain me the flow?
original derived from Oracle's specs:
http://download.oracle.com/javaee/1.2.1/api/javax/servlet/http/HttpServletRequest.html
getServletPath
public java.lang.String getServletPath() Returns the part of this request's URL that calls the servlet. This includes either the servlet name or a path to the servlet, but does not include any extra path information or a query string. Same as the value of the CGI variable SCRIPT_NAME.
getContextPath
public java.lang.String getContextPath() Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI. The path starts with a "/" character but does not end with a "/" character. For servlets in the default (root) context, this method returns "". Returns: a String specifying the portion of the request URI that indicates the context of the request
I think that the spec is descriptive enough.
Regards.
精彩评论