0

I want to use expression language in some of my javascript files. So I set up a JSPServlet, mapped to all javscript files, so they could be evaluated:

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>weblogic.servlet.JSPServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.js</url-pattern>
</servlet-mapping>

Then it turned out that one of my js-files crashes on EL-evaluation, and I suddenly need to specify only the files that should be evaluated. I quickly found out that exceptions to a filter is not supported. Instead I changed the name of the js-files that contains expression language, to end with -el.js. Then I updated all of my references to those scripts, and made my silter mapping url pattern look like this instead:

<servlet>
    <servlet-name>jsp</servlet-name>
    <servlet-class>weblogic.servlet.JSPServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*-el.js</url-pattern>
</servlet-mapping>

Turns out this is not accepted. I have tried to find the rules of URL-patterns, but been unable to locate them. I know I could just put the relevant files in a specific subfolder, and then use the folder as the url pattern, but after painstakingly updating every reference to all of the files, I was hoping that there might be an easier way to do this. And no matter what, I would definitely like to know the rules of url-patterns.

So what exactly are the rules of url patterns for java servlets? Can I use filenames-ending-with, where more than the file extension is specified, in any way?

jumps4fun
  • 3,994
  • 10
  • 50
  • 96
  • From http://stackoverflow.com/questions/8570805/can-we-use-regular-expressions-in-web-xml-url-patterns - no, you can't have this kind of expression. The best you can do is check it against a list like you started to do. – stdunbar Nov 10 '16 at 17:25
  • Thanks for linking to that question. It answers my own question perfectly – jumps4fun Nov 11 '16 at 08:46

0 Answers0