If so how do you do this?
(jboss/tomact embedded/jdk 1.5)
not embedded js/css but an actual file...
If so how do you do this?
(jboss/tomact embedded/jdk 1.5)
not embedded js/css but an actual file...
Sure, JSP can output any necessary text you need be that (X)HTML or CSS or JavaScript code. I do this regularly for ERP customization, inject a javascript script at the end of every page and via the context in which it loads able to manipulate necessary data fields on the page without touching the underlying app.
Sure you can. Only thing you need to do is to set the appropriate content type.
<%@page contentType="text/javascript" %>
or
<%@page contentType="text/css" %>
Take care with the fact that some webbrowsers might be picky on the file extension used in the actual request URL. I have never tried it as I normally would use a Servlet
for those purposes, but I won't be surprised if especially MSIE won't eat that.
What you want to do is assign the *.css servlet mapping to the JSPServlet.
In most containers, you will see a mapping like this (this is from Glassfish, in it's default-web.xml):
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
Here, it is declaring the JSP servlet, and mapping "*.jsp" to it. So, in this case, the JSP servlet reference name is, simply 'jsp'.
So you would want to add:
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
When you do that, "suddenly" ALL of your CSS files are, effectively, JSPs, so you can do with them whatever you want.
The detail is I don't know if 'jsp' is the same for ALL containers, so your web.xml MAY NOT be portable.
But that's the gist of what you want to do. If you don't want ALL CSS to be JSPs, you could put the files in their own directory, and map that to the JSP servlet. Then ANYTHING you put in there would be a JSP (css, js, etc.)
Any idea how to do this per webapp, ideally in the web.xml of the webapp?
I do not want to mess with the global config.