VOTG
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Servlets
 
RSS feed
 
New topic
Author

Need to access the Filter config in web.xml

Veronica Lalchandani
Greenhorn

Joined: Feb 03, 2010
Messages: 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
Messages: 651

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

SCJP 5.0 97% JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - API - Generics FAQ - JLS - JVM Spec - Java FAQs
Charles 'King
Ranch Hand

Joined: Jul 05, 2009
Messages: 41

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
Sheriff

Joined: Jan 10, 2002
Messages: 36601

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
Messages: 40

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
Messages: 41

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
Messages: 2

I had a requirement to get the filters ... Thanks everyone for your help
Charles 'King
Ranch Hand

Joined: Jul 05, 2009
Messages: 41

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
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Servlets
 
RSS feed
 
New topic
IntelliJ open source