It's simple, I've done it before, it works great.
Just take the extension you want to map and map it to the JSP servlet.
JSPs are handled by the servlet, like everything else. Nothing special about them.
So, for Glassfish, this servlet is called "jsp". I don’t know if this is portable (for example, the name), but most likely it works in Glassfish and Tomcat, and probably anywhere where the JSP-JSP compiler is used.
In Glassfish, it is defined in $ glassfish_domain_dir / config / default-web.xml.
So add this to your web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.css</url-pattern> </servlet-mapping> </web-app>
The good thing is that this will work pretty much for direct CSS files if they don't have markup, or with custom ones that you also add markup.
source share