Thanks Craig & Jason, Yes, the string in <display-name> can be queried via
this.getServlet().getServletContext().getServletContextName() from any Struts Action. Thanks very much. Ivan. -----Original Message----- From: Craig McClanahan [mailto:[EMAIL PROTECTED] Sent: Monday, July 12, 2004 5:09 PM To: Struts Users Mailing List Subject: Re: How to read <display-name> from web.xml? Ivan Vasquez wrote: >Hi, > >How can I read from web.xml, say, the application's display name? I've >tried several things, but no luck. This isn't really Struts-specific, >but I'm sure this is an easy one for many of you. > >Thanks, >Ivan. > > > The web.xml file is available as a resource that can be accessed via the ServletContext for your webapp. For example, you can say something like: ServletContext context = ...; // Get a reference to our servlet context InputStream stream = context.getResourceAsStream("/WEB-INF/web.xml"); Now you've got an input stream to read the contents ... you'll probably want to use an XML parser to parse the contents -- google for JAXP to see the API that Java provides for this purpose. Or, you might consider using the Commons Digester package (included with Struts), which is what Struts itself uses to parse this very resource, in order to figure out how the controller servlet is mapped. Looking at the source code for ActionServlet should give you some useful clues. Craig --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]