aspose file tools
The moose likes Servlets and the fly likes Need to access the Filter config in web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Need to access the Filter config in web.xml" Watch "Need to access the Filter config in web.xml" New topic
Author

Need to access the Filter config in web.xml

Veronica Lalchandani
Greenhorn

Joined: Feb 03, 2010
Posts: 2
Is there some API, to read the filters and the filter-mapping defined in the web.xml?
Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 754

@Veronica
Welcome to JavaRanch.
What you want to know exactly? About xml file reading or filter mapping?


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Charles 'King
Ranch Hand

Joined: Jul 05, 2009
Posts: 56

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?
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 48799

There is no supported API to so this. Why do you need to?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Kris Schneider
Ranch Hand

Joined: Feb 14, 2001
Posts: 71
If you're using a Java EE 6 (Servlet 3.0) containter, take a look at the ServletContext.getFilterRegistrations method.
Charles 'King
Ranch Hand

Joined: Jul 05, 2009
Posts: 56

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

This message was edited 1 time. Last update was at by Charles 'King

Veronica Lalchandani
Greenhorn

Joined: Feb 03, 2010
Posts: 2
I had a requirement to get the filters ... Thanks everyone for your help
Charles 'King
Ranch Hand

Joined: Jul 05, 2009
Posts: 56

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
 
 
subject: Need to access the Filter config in web.xml
 
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture