You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mailsweeper <ma...@aegonusa.com> on 2001/11/05 21:58:58 UTC

Fw: Re: Multiple resource files

----- Original Message -----
From: <to...@bredband.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Wednesday, October 31, 2001 2:58 AM
Subject: Re: Re: Multiple resource files


> Hi,
> The ActionServlet loads one resourcefile and stores the information at the
servletcontext.
>
> One solution is to have your own "Startup-servlet" to load extra resources
to the servlet context. You can access those later within your application.
If you use Tomcat 4 (Have access to Servlet 2.3 features) you can write a
contextlistener instead.
>
> From Servlet init method:
>
>     ServletContext ctx = config.getServletContext();
>     MessageResourcesFactory myFactory =
(MessageResourcesFactory)MessageResourcesFactory.createFactory();
>     MessageResources errMsgs =
(MessageResources)myFactory.createResources(config.getInitParameter(("errors
")));
>     MessageResources wrnMsgs =
(MessageResources)myFactory.createResources(config.getInitParameter(("warnin
gs")));
>
> ctx.setAttribute "myapp.errors",errMsgs);
> ctx.setAttribute("myapp.warnings",wrnMsgs);
>
> web.xml servlet definition:
> <servlet>
>   <servlet-name>mystartup</servlet-name>
>   <servlet-class>se.bluefish.StartupServlet</servlet-class>
>   <init-param>
>           <param-name>errors</param-name>
>           <param-value>com.bluefish.MyErrorResources</param-value>
>   </init-param>
>   <init-param>
>           <param-name>warnings</param-name>
>           <param-value>com.bluefish.MyWarningResources</param-value>
>   </init-param>
>   <load-on-startup>2</load-on-startup>
> </servlet>
>
> Rgds // Torben
>
> >
> >
> > Not yet. James Holmes is looking into it.
> >
> >
> > At 11:47 am 31-10-2001 +0530, you wrote:
> > >Hello All,
> > >
> > >How can I have multiple resource files ?
> > >
> > >I am trying something like
> > >
> > ><web-app>
> > ><servlet>
> > >  <init-param>
> > >   <param-name>application</param-name>
> > >   <param-value>com.abhi.hello.HelloWorld1Resources</param-value>
> > >  </init-param>
> > >  <init-param>
> > >   <param-name>application</param-name>
> > >   <param-value>com.abhi.hello.HelloWorld2Resources</param-value>
> > >  </init-param>
> > ><servlet>
> > ><web-app>
> > >
> > >But my jsp pages do not find any of the keys defined in the resources
files.
> > >If I define only one file and put everything there then everything
works
> > >fine.
> > >
> > >regards,
> > >Abhishek.
> >
> > --
> > John Yu                       Scioworks Technologies
> > e: john@scioworks.com         w: +(65) 873 5989
> > w: http://www.scioworks.com   m: +(65) 9782 9610
> >
> > Scioworks Camino - "Rapid WebApp Assembly for Struts"
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> .
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>