This module is view-only. You do not have an enrolement for this module.

Replace MiltonServlet with MiltonFilter

Finally we just need to integrate the new milton filter into your web.xml file.

The old MiltonServlet would be integrated something like this:

    <servlet>
        <servlet-name>milton</servlet-name>
        <servlet-class>com.mycompany.ScratchServlet</servlet-class>
        <init-param>
            <param-name>resource.factory.class</param-name>
            <param-value>com.mycompany.TResourceFactory</param-value>
        </init-param>
        <init-param>
            <param-name>not.found.url</param-name>
            <param-value>/404.jsp</param-value>
        </init-param>    
    </servlet>

    <servlet-mapping>
        <servlet-name>milton</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

To use the new milton filter you would do this:

      <filter>
        <filter-name>MiltonFilter</filter-name>
        <filter-class>io.milton.servlet.MiltonFilter</filter-class>
        
        <!-- This param shows how to exclude certain paths from the MiltonFilter -->
        <!-- These paths will "fall through" the filter and be handled as normal servlet resources -->
        <init-param>
            <param-name>milton.exclude.paths</param-name>
            <param-value>/myExcludedPaths,/moreExcludedPaths</param-value>
        </init-param>
        <init-param>
            <param-name>resource.factory.class</param-name>
            <param-value>com.mycompany.TResourceFactory</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>MiltonFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>