Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need to access the Filter config in web.xml

 
Veronica Lalchandani
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there some API, to read the filters and the filter-mapping defined in the web.xml?
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Hibernate Linux Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Veronica
Welcome to JavaRanch.
What you want to know exactly? About xml file reading or filter mapping?
 
Charles 'King
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veronica Lalchandani wrote:Is there some API, to read the filters and the filter-mapping defined in the web.xml?


If you have access to the DD, why do you need to read it during run-time? Are you interested in accessing filter init parameters?
 
Kris Schneider
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using a Java EE 6 (Servlet 3.0) containter, take a look at the ServletContext.getFilterRegistrations method.
 
Charles 'King
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kris Schneider wrote:If you're using a Java EE 6 (Servlet 3.0) containter, take a look at the ServletContext.getFilterRegistrations method.


And if you're not and you must know all filter names, simply put the names or class names in a filter init parameter of sorts and create your map in a servlet context listener. Seems like a lot of work just for a map of filters
 
Veronica Lalchandani
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a requirement to get the filters ... Thanks everyone for your help
 
Charles 'King
Ranch Hand
Posts: 56
Eclipse IDE Postgres Database Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Veronica Lalchandani wrote:I had a requirement to get the filters ... Thanks everyone for your help


If your component is in the same web context, use the Servlet context method getResourceAsStream("/WEB-INF/web.xml") - Remember to wrap the InputStream into your favorite reader to read each line of the DD -- good luck
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic