Thursday 12 July 2012

Expose local directory images through Tomcat Sever


Option 1
Enable directory listing for specific URL pattern in web.xml

    listImages
    org.apache.catalina.servlets.DefaultServlet
    
        debug
        0
    
    
        listings
        true
    
    100



    listImages
    /listImages/*


Option 2 NOTE: This will affects all folders in the webapp. It is best to enable directory listing only for an individual folder by writing own Servlet to handle the request.

1.Create a Context element in an XML file: Image.xml




2.Copy the Image.xml file to $CATALINA_HOME/conf/Catalina/localhost/.

3.Enable Directory listing in in Tomcat. Edit the default servlet in the {$CATALINA_HOME}/conf/web.xml file.

    
        default
        org.apache.catalina.servlets.DefaultServlet
        
            debug
            0
        
        
            listings
            true
        
        1
    

4.Change the param-value; to true for the param-name listing section.
        
            listings
            true