Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Tomcat 4: web.xml url-pattern question...  RSS feed

 
Brian Woo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to use a filter in Tomcat 4.1.30 (servlet 2.3 compatible). My problem is in the web.xml at the url-pattern tag.

I have the following filter and filter mapping:

<filter>
<filter-name>transcoderFilter</filter-name>
<filter-class>com.cj.h2w.transcoderFilter</filter-class>
<init-param>
<param-name>dir</param-name>
<param-value>/home/bwoo/workspace/imsld/COMP200_wml</param-value>
</init-param>
<init-param>
<param-name>url</param-name>
<param-value>http://192.168.2.6:8080/imsld/COMP200</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>transcoderFilter</filter-name>
<url-pattern>testWml.html</url-pattern>
</filter-mapping>

However, the filter will not startup and give the following exception:

SEVERE: End event threw exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> testWml.html in filter mapping
at org.apache.catalina.core.StandardContext.addFilterMap(StandardContext.java:1509)

But why? I have read the Sun's Servlet 2.3 Spec and it says it's possible to specify whole file name to match, but it's not working at all. Is it a bug in Tomcat 4.1.x?

Thanks very much.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try:
 
Brian Woo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.

I have done what you told me: having "/testWml.html" in the url-pattern in web.xml.

I also have debug statements in the doFilter() but when I access http://server:8080/imsld/COMP200/testWml.html, there is nothing printed out.

Tomcat is not recognizing the url-pattern. Has anybody have the similar problem? Any solution?

Thanks.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<url-pattern>/COMP200/testWml.html</url-pattern>
 
Brian Woo
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That works!! Thanks very much for your help. Really appriecated.
 
Shijo Joseph
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Woo


Why the first case is not working.

I mean to say <uri-patter>xyz.html</uri-pattern>

I have a similar problem.

In may case

I have <uri-patter>xyz.do</uri-pattern>

When I change like this, Tomcat is not even picking *.do mapping

Since i use the same filter in more than one(e.g. /xyz/xyz.do and
/pqr/xyz.do) I like to put the same mapping so that both the subfolders
use the same mapping.

Will u pls give a clue to the problem?


Regards
Shijo Joseph


Regards
Shijo Joseph
 
Chris DeGreef
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the specification only allows for <url-pattern> not <uri-pattern>.
 
Shijo Joseph
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's <url-patter>xyz.do</url-pattern>

Sorry, I put it as uri pattern.


Thanks & Regards
Shijo Joseph
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!