org.zkoss.web.util.resource
Interface ExtendletContext


public interface ExtendletContext

This interface defines an extended context that Servlets.getRequestDispatcher(javax.servlet.ServletContext, javax.servlet.ServletRequest, java.lang.String, java.util.Map, int) will try to resolve. When Servlets.getRequestDispatcher(javax.servlet.ServletContext, javax.servlet.ServletRequest, java.lang.String, java.util.Map, int) is called, it detects whether ~xxx/ is specified. If specified, it looks up any extended context is registered as xxx. If found, the extend context is used. If not found, it looks up any servlet context called xxx.

To registers an extended context, use Servlets.addExtendletContext(javax.servlet.ServletContext, java.lang.String, org.zkoss.web.util.resource.ExtendletContext).

Author:
tomyeh

Method Summary
 java.lang.String encodeRedirectURL(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri, java.util.Map params, int mode)
          Returns the encoded URL for send redirect.
 java.lang.String encodeURL(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.String uri)
          Returns the encoded URL.
 Locator getLocator()
          Returns the locator of this context used to locate resorces.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String uri)
           
 java.net.URL getResource(java.lang.String uri)
          Returns the URL of the specified URI, or null if not found.
 java.io.InputStream getResourceAsStream(java.lang.String uri)
          Returns the resource of the specified URI as input stream, or null if not found.
 javax.servlet.ServletContext getServletContext()
          Returns the servlet context.
 void include(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String uri, java.util.Map params)
          Includes the specified page.
 boolean shallCompress(javax.servlet.ServletRequest request, java.lang.String ext)
          Tests whether to compress the specified extension, e.g, "js" and "css".
 

Method Detail

encodeURL

java.lang.String encodeURL(javax.servlet.ServletRequest request,
                           javax.servlet.ServletResponse response,
                           java.lang.String uri)
                           throws javax.servlet.ServletException,
                                  java.io.IOException
Returns the encoded URL. The returned URL is also encoded with HttpServletResponse.encodeURL.

It resolves "*" contained in URI, if any, to the proper Locale, and the browser code. Refer to Servlets.locate(javax.servlet.ServletContext, ServletRequest, String, org.zkoss.util.resource.Locator) for details.

Parameters:
uri - it must be empty or starts with "/". It might contain "*" for current browser code and Locale.
Returns:
the complete URL (excluding the machine name). It includes the context path and the servelt to interpret this extended resource.
Throws:
javax.servlet.ServletException
java.io.IOException

encodeRedirectURL

java.lang.String encodeRedirectURL(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response,
                                   java.lang.String uri,
                                   java.util.Map params,
                                   int mode)
Returns the encoded URL for send redirect. The URL is also encoded with HttpServletResposne.encodeRedirectURL.


getRequestDispatcher

javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String uri)

include

void include(javax.servlet.http.HttpServletRequest request,
             javax.servlet.http.HttpServletResponse response,
             java.lang.String uri,
             java.util.Map params)
             throws javax.servlet.ServletException,
                    java.io.IOException
Includes the specified page.

Note: if you want to include the content into a different writer, you have to use BufferedResponse to 'wrap' the writer in the response.

Throws:
javax.servlet.ServletException
java.io.IOException
Since:
3.5.2

getResource

java.net.URL getResource(java.lang.String uri)
Returns the URL of the specified URI, or null if not found.

Unlike getLocator(), getResourceAsStream(java.lang.String) handles the JavaScript debugging. In other words, if the JavaScript debugging is turned on, it will try to load the non-compressed version.


getResourceAsStream

java.io.InputStream getResourceAsStream(java.lang.String uri)
Returns the resource of the specified URI as input stream, or null if not found.

Unlike getLocator(), getResourceAsStream(java.lang.String) handles the JavaScript debugging. In other words, if the JavaScript debugging is turned on, it will try to load the non-compressed version.


getServletContext

javax.servlet.ServletContext getServletContext()
Returns the servlet context.


getLocator

Locator getLocator()
Returns the locator of this context used to locate resorces.

Unlike getResource(java.lang.String) and getResourceAsStream(java.lang.String), getLocator() doesn't handle the JavaScript debugging.


shallCompress

boolean shallCompress(javax.servlet.ServletRequest request,
                      java.lang.String ext)
Tests whether to compress the specified extension, e.g, "js" and "css".

It returns false if the request is included by other Serlets.



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo