File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes accessing web.xml from java bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "accessing web.xml from java bean" Watch "accessing web.xml from java bean" New topic
Author

accessing web.xml from java bean

Faris Syed
Greenhorn

Joined: Jun 25, 2004
Posts: 8
Is it possible to read properties in web.xml file from a java bean?

I know from servlet we can get reference to ServletContext and from JSP pages we can do that by using application.
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Yes you can do this. You want to use the "open the resource as steam" using the classloader's resources so it loads from the war instead of the filesystem. Check out the api docs for more information.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Faris Syed
Greenhorn

Joined: Jun 25, 2004
Posts: 8
Thanks Nathaniel, for your reply.

I just added getServletcontext(ServletContext context) method in my bean so who ever uses the bean needs to pass the reference to a servlet context. And it works fine for me now.
 
 
subject: accessing web.xml from java bean