• Post Reply Bookmark Topic Watch Topic
  • New Topic

get init parameter in filter

 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get filter's init parameter in servlet or tag? the servlet isn't implements Filter.java.
thanx
 
Marty Hall
Author
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get filter's init parameter in servlet or tag?

By "filter's init parameter" I take it that you mean "an init param declared in web.xml with the init-param subelement of the filter element." Assuming that is what you mean, you cannot read these params anywhere except in the init method of a filter, since only that method is passed the FilterConfig object.
However, if you want the initialization parameters to be read multiple places, simply declare them a different way. For example, use context-param. Now, these context parameters can be read by calling the getInitParameter method of ServletContext, and you can get the ServletContext from a servlet (getServletContext), a JSP page (the predefined "application" variable), or a filter (FilterConfig.getServletContext).
Cheers-
- Marty
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As to provide more information on the init-parameters... Here is some more explanations...
Context Init Parameters are available throughout the web application and is accessible among the all components in the web app, while Servlet Init Parameters are available to the specific servlet and is not accessible by other components of the web app...
Hope this adds some clarification to the question...
 
dragon ji
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx,guys!
Now I know what shall I do.
thanx,Marty,you let me know how express my question.
Ko ko,you let me know more.
best regards
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!