Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to get the filter to work

 
Ann Basso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following in my web.xml:

As I understand I am applying the filter on "default" servlet. This is what the specification says for it: "A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path
and the path info is null."

When I access http://localhost:8080/mywebapp/, it shows the index.jsp page and I am also expecting this filter to execute but it is not. I don't understand why. When I chage the url pattern to /*, it does execute but not for /. I tried it on tomcat as well as glassfish.

How to I apply a filter to this default servlet?
thanks!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ann,

You should be able to create a filter on the default servlet.

Can you post the part of your web.xml where you define the default servlet (<servlet> and <servlet-mapping>)?

Regards,
Frits
 
Ann Basso
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frits Walraven wrote:Hi Ann,

You should be able to create a filter on the default servlet.

Can you post the part of your web.xml where you define the default servlet (<servlet> and <servlet-mapping>)?

Regards,
Frits

Hi Frits,
There is no definition for default servlet. That's why it is called the default servlet. When the app context is not able to match the incoming request uri to any of the url-mappings, the request is passed on to the default servlet. It generally looks for index.html/jsp or generates a 404 response. So if you call, http://localhost:8080/mywebapp/, it looks for index.jsp in document root. So I am trying to apply the filter to "/".

thanks!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2534
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ann,

When the app context is not able to match the incoming request uri to any of the url-mappings, the request is passed on to the default servlet.

Correct, and that is the entry in the web.xml with an url-pattern of "/". So you are the one who has to define it.

It generally looks for index.html/jsp

What you describing here is the <welcome-file-list> entry in the web.xml

After you have defined the default servlet for your web-application, you can aply the filter to it:


Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic