This servlet lets you dump responses from the provided URL's and serve the sub-sequential requests from your local host. Dump servlet transparently passes HTTP GET requests to the hosts, provided as a parameter. The response will be served to the user requested it and in the same time saved on your host. So for the next requests the content will be provided right from your host How to use this servlet: a) download dumpPackage.jar and save it in WEB-INF/lib b) describe this servlet in web.xml file. Servlet accepts the following initial parameters:
For example:
<servlet> <servlet-name>DumpServlet</servlet-name> <servlet-class>com.jsos.dump.DumpServlet</servlet-class> <init-param> <param-name>dir</param-name> <param-value>/my_cache</param-value> </init-param> </servlet> c) describe a mapping for this servlet in web.xml file. E.g.:
<servlet-mapping> <servlet-name>DumpServlet</servlet-name> <url-pattern>/servlet/dump</url-pattern> </servlet-mapping> and now in your applications you can use servlet in the following forms
/servlet/dump?http://some_remore_content requests content and saves it locally
/servlet/dump?url=http://some_remore_content&ttl=10 parameter ttl describes time to live for the saved content (in seconds). So in this example for the next 10 seconds the sub-sequent requests will be served locally. And parameter expires describes a client-side cache (in seconds). E.g. you can use it with Google Charts API:
<img src="/servlet/dump?url=http://chart.apis.google.com/chart?cht=p3& chd=s:hW&chs=250x100&chl=Hello|World&ttl=20"/> and the chart will be cached locally for 20 seconds. If ttl value is 0 than cached data will be ignored and servlet will request data from the external host. You can describe the proxy settings for the servlet itself.
Parameters are proxyHost and proxyPort. E.g.:
<servlet> <servlet-name>DumpServlet</servlet-name> <servlet-class>com.jsos.dump.DumpServlet</servlet-class> <init-param> <param-name>dir</param-name> <param-value>/my_cache</param-value> </init-param> <init-param> <param-name>proxyHost</param-name> <param-value>192.168.0.1</param-value> </init-param> <init-param> <param-name>proxyPort</param-name> <param-value>8080</param-value> </init-param> </servlet> For downloading: Dump servlet: dumpPackage.jar
See also JSOS - the largest collection of servlets and filters.
|
Also in JSOS:
|