Resource servlet 1.3


Simple component you may use for the extracting resources from war files (packages web applications). How to get JavaScript file packaged with your application? How to set reference to the packaged image file etc.? It is what Resource servlet is for. How to use it:

1) download resourcePackage.jar and save it in WEB-INF/lib

2) describe Resource servlet in web.xml file  


    <servlet>
     <servlet-name>ResourceServlet</servlet-name>
     <servlet-class>com.jsos.resource.ResourceServlet</servlet-class>
    </servlet>

3) define a mapping:
 


    <servlet-mapping>
     <servlet-name>ResourceServlet</servlet-name>
     <url-pattern>/servlet/ResourceServlet</url-pattern>
    </servlet-mapping>

you can pass the following parameters for this servlet:

path - describes a path for your resource
type - Optional parameter. Describes a content type for your resource.
expires - Optional parameter. Describes a caching time (in seconds) for the extracted resource.

E.g.:
 


<img src="http://your_host/servlet/ResourceServlet?path=/picture.gif&type=image/gif">
or
<link rel="stylesheet" href="http://your_host/servlet/ResourceServlet?path=/css/my.css" type="text/css">

For JSP see also Resource taglib in Coldtags suite

For downloading:

servlet: resourcePackage.jar  
 

 © Coldbeans    Comments?
 

See also JSOS - the largest collection of servlets and filters.

Also in Coldtags: