获取服务器文件路径(Gets the server file path)
获取服务器文件路径(Gets the server file path)
1. understanding of basic concepts
Absolute path: absolute path is the file or directory on your home page, the real path on the hard disk, (URL and physical path), for example:
C:\xyz\test.txt represents the absolute path of the test.txt file. Http:///index.htm also stands for one
URL absolute path.
Relative path: the path relative to a base directory. Contains the relative path of Web (relative directory in HTML), for example: in
In Servlet, "/" represents the directory of the Web application. The relative representation of the physical path. For example: "/" represents the current directory,
"/" represents the parent directory. Such a representation is also a relative path.
Also, for URI, URL, URN, and so on, see the RFC related documentation standards.
RFC, 2396:, Uniform, Resource, Identifiers (URI): Generic, Syntax,
(/rfc/rfc2396.txt)
2. relative paths and absolute paths in JSP/Servlet.
2.1 server-side address
The relative address of the server refers to the address relative to your web application, which is parsed at the server side
(unlike the relative addresses in HTML and JavaScript, they are parsed by the client browser), that is to say, this time
The relative address in JSP and servlet should be relative to your web application, that is, relative to /webapp/.
Where it is used:
Request.getRequestDispatcher (address) in forward:servlet; this address is
Parsed on the server side, so you should write it from forward to a.jsp:
Request.getRequestDispatcher ("/user/a.jsp") this / applies webapp relative to the current web,
Its absolute address is: /webapp/user/a.jsp.
SendRedirect:
2.22, client address
All the relative addresses in the HTML page are relative to the server root directory (/),
Instead of (with the directory of the Web application directory) /webapp/.
The action attribute of the form form in Html should be relative to the server root directory (/),
So, if sub