Package org.zeroturnaround.javarebel
Interface RebelServletContext
public interface RebelServletContext
Servlet context interface visible to JavaRebel agent.
RebelServletContext consists of the resource providing methods
defined in javax.servlet.ServletContext/jakarta.servlet.ServletContext.
Separate interface is required as the javax.servlet.ServletContext/jakarta.servlet.ServletContext
interface is not loaded by the boot class loader.
All Servlet context instances must implement this interface in order to be integrated with JavaRebel.
In practice a bytecode processor makes javax.servlet.ServletContext/jakarta.servlet.ServletContext
to extend the given interface. So no particular Servlet context implementation
has to implement it explicitly.
- Author:
- Rein Raudjärv'
-
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String paramString) A access mirror for ServletContext's methodA access mirror for ServletContext's methodgetInitParameter(String name) A access mirror for ServletContext's methodgetRealPath(String path) Returns a String containing the real path for a given virtual path.getResource(String path) Returns a URL to the resource that is mapped to a specified path.getResourceAsStream(String name) Returns the resource located at the named path as an InputStream object.getResourcePaths(String path) Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.voidremoveAttribute(String name) A access mirror for ServletContext's methodvoidsetAttribute(String paramString, Object paramObject) A access mirror for ServletContext's method
-
Method Details
-
getResourcePaths
Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. Paths indicating subdirectory paths end with a '/'. The returned paths are all relative to the root of the web application and have a leading '/'. For example, for a web application containing /welcome.html /catalog/index.html /catalog/products.html /catalog/offers/books.html /catalog/offers/music.html /customer/login.jsp /WEB-INF/web.xml /WEB-INF/classes/com.acme.OrderServlet.class, getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"} getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}.- Parameters:
path- partial path used to match the resources, which must start with a /- Returns:
- a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path.
-
getResource
Returns a URL to the resource that is mapped to a specified path. The path must begin with a "/" and is interpreted as relative to the current context root. This method allows the servlet container to make a resource available to servlets from any source. Resources can be located on a local or remote file system, in a database, or in a .war file. The servlet container must implement the URL handlers and URLConnection objects that are necessary to access the resource. This method returns null if no resource is mapped to the pathname. Some containers may allow writing to the URL returned by this method using the methods of the URL class. The resource content is returned directly, so be aware that requesting a .jsp page returns the JSP source code. Use a RequestDispatcher instead to include results of an execution. This method has a different purpose than java.lang.Class.getResource, which looks up resources based on a class loader. This method does not use class loaders.- Parameters:
path- a String specifying the path to the resource- Returns:
- the resource located at the named path, or null if there is no resource at that path
- Throws:
MalformedURLException- if the pathname is not given in the correct form
-
getResourceAsStream
Returns the resource located at the named path as an InputStream object. The data in the InputStream can be of any type or length. The path must be specified according to the rules given in getResource. This method returns null if no resource exists at the specified path. Meta-information such as content length and content type that is available via getResource method is lost when using this method. The servlet container must implement the URL handlers and URLConnection objects necessary to access the resource. This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader.- Parameters:
name- a String specifying the path to the resource- Returns:
- the InputStream returned to the servlet, or null if no resource exists at the specified path
-
getRealPath
Returns a String containing the real path for a given virtual path. For example, the path "/index.html" returns the absolute file path on the server's filesystem would be served by a request for "http://host/contextPath/index.html", where contextPath is the context path of this ServletContext.. The real path returned will be in a form appropriate to the computer and operating system on which the servlet container is running, including the proper path separators. This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).- Parameters:
path- a String specifying a virtual path- Returns:
- a String specifying the real path, or null if the translation cannot be performed
-
getInitParameter
A access mirror for ServletContext's method -
getContextPath
String getContextPath()A access mirror for ServletContext's method -
getAttribute
A access mirror for ServletContext's method -
setAttribute
A access mirror for ServletContext's method -
removeAttribute
A access mirror for ServletContext's method
-