Can I associate a servlet with a particular mime-type, so if the client requests a file of that type, my servlet will be executed?

Wellington Silva

In web.xml you can use a mime-mapping to map the type with a certain extension and then map the servlet to that extension.

e.g.

    <mime-mapping>
        <extension>
            zzz
        </extension>
        <mime-type>
            text/plain
        </mime-type>
    </mime-mapping>

    <servlet-mapping>
        <url>
            *.zzz
        </url>        
        <servlet-name>
            MyServlet
        </servlet-name>
    </servlet-mapping>
So, when a file for type zzz is requested, the servlet gets called.
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact