Version 9

    Shotoku Web Filter - read resources from the filesystem

     

    The Shotoku Web component consists (so far ) of one filter, which enables you to develop web applications a bit more easily. To use it, you don't have to use a particular IDE, install plugins etc.

     

    This filter, when used, reads JSP files and other resources from a specified directory in the filesystem, instead of reading them from the deployed application archive.

     

    Imagine you are developing a web application, which displays a JSP file. It is pretty annoying to have to re-deploy the application whenever you make any change to the JSP to see the result in the browser (there are other ways to get rid of that annoying problem, of course; here I'm describing only one way of many). It would be really nice if the JSP file would be read from outside the .war - most preferably, from the directory in which you develop your web application.

     

    That's exactly what this filter does. If a JSP file (or any other resource: image, css file, html page, text, etc - the list of extensions on which the filter is activated is configurable) is requested by your web application - either directly, or through a request dispatcher include/forward - it is copied from a specified directory to the JBoss AS temporary directory, and used instead of the file included in the archive.

     

    Thanks to that, if you are developing web pages, you can view your changes immediately.

     

    Works with ...

     

     

    Example of usage

     

    To use the filter, simply download the jar. It contains one class:

    org.jboss.shotoku.web.ResourceFilter. Add it to the WEB-INF/lib directory of your web application and modify web.xml to include the following:

     

    <filter>
       <filter-name>ResourcesFilter</filter-name>
       <filter-class>org.jboss.shotoku.web.ResourcesFilter</filter-class>
       <init-param>
          <param-name>sourceBasePath</param-name>
          <param-value>/path/to/your/project/root</param-value>
       </init-param>
    </filter>
    
    <filter-mapping>
       <filter-name>ResourcesFilter</filter-name>
       <url-pattern>/*</url-pattern>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       <dispatcher>FORWARD</dispatcher>
    </filter-mapping>
    

     

    Then, change the sourceBasePath parameter so that it matches the path to your project's web directory (the directory with web resources; if a file /pages/hello.jsp is requested, the filter will try to read $/pages/hello.jsp )

     

    And that's it. Deploy your web application, open any page, modify it in your IDE, click refresh in the browser and see the results on your own.

     

    Additional configuration

     

    The filter also accepts another init-param, extensions. It is a a list of extensions that will be filtered, and defaults to jsp,css,html,htm,gif,jpg,jpeg,png,txt,xhtml.

     

    A note about Tomcat settings

     

    If you have changed tomcat's jsp servlet settings, and for example switched off development mode, the filter may work with a delay, that is, changes in files may be picked up only after some time. The configuration of tomact's jsp servlet can be found in (jboss 4.0.5): server/default/deploy/jbossweb-tomcat55.sar/conf/web.xml. But if you didn't change any settings, the filter will work just fine.

     

    Source code

     

    Can be found in svn here.