• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Unable to get the filter to work

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Creator of Enthuware JWS+ V6
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3412
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic