What is the role of ServletContext. getContect (java. lang. String uripath?
Returns the ServletContext object corresponding to the path specified in the same Server. This object can be used to deal with other contexts in the Server.
Uripath must start with "/" and indicate the root path relative to the entire Servlet document, rather than the root path of the current ServletContext ).
What is the difference between ServletContext. getRequestDispatcher (String url) and ServletRequest. getRequestDispatcher (String url? Why?
The URLs in ServletContext. getRequestDispatcher (String url) can only use absolute paths, while those in ServletRequest. getRequestDispatcher (String url) can use relative paths.
Because ServletRequest has the concept of relative paths, while ServletContext does not.
How do I transfer requests to an address in another Web App?
ServletContext. getRequestDispatcher (String url) and ServletRequest. getRequestDispatcher (String url) can only transfer requests to addresses in the same Web App.
To transfer requests to an address in another Web App, follow these steps:
1. Obtain the ServletConext object (currentServletContext. getContext (uripath) of another Web App )).
2. Call the ServletContext. getRequestDispatcher (String url) method.
- How to install Apache Servlet
- Optimize Servlet configuration for web. xml slimming
- How to configure Servlet in XML
- Solve the Problem of Servlet JSP page garbled
- Servlet and JSP security issues