Yes
when constructing your war be sure to include in your web.xml the init-param
specification

<init-param>

<param-name>application</param-name>

<param-value>ApplicationResources</param-value>

</init-param>

<init-param>

<param-name>config</param-name>

<param-value>/WEB-INF/struts-config.xml</param-value>

</init-param>

(whereas param-value is the java classname which contains MessageResources)

*OR in your struts-config.xml*


<!-- ========== Message Resources Definitions
=========================== -->

<message-resources

parameter="ApplicationResources"/>


Then to quote Stephan Wiesner
create a ApplicationResources.properties in /WEB-INF/classes folder with one
entry
'index.title=Struts Tutorial'

Then create a jsp which will call it
test.jsp created in the webapps/YourProject directory

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tlf" prefix="logic" %>

<html:html locale="true">
<head>
<html:base/>
<title>
     <bean:message key=index.title"/>
</title>
</head>
<body>
</body>
</html:html>

-Martin

----- Original Message ----- 
From: "Kalra, Ashwani" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Tuesday, December 23, 2003 5:32 AM
Subject: RE: retrieving values from application.properties file


> Ok, Thanks. I thought that I could use some struts wrapper class which
will
> provide some fn which takes the key as input. I didnt wanted to load  the
> bundle etc as its already done by struts.
> Any way thanks.
>
>
> >-----Original Message-----
> >From: Shishir K. Singh [mailto:[EMAIL PROTECTED]
> >Sent: Tuesday, December 23, 2003 1:01 PM
> >To: Struts Users Mailing List
> >Subject: RE: retrieving values from application.properties file
> >
> >
> >Use
> >
> >ResourceBundle resource =
> >ResourceBundle.getBundle("resources.application");
> >
> >Else :
> >If you are in Action/Lookup Dispatch Action class
> >
> >MessageResources resource = getResources(request);
> >
> >
> >
> >
> >
> >-----Original Message-----
> >From: Kalra, Ashwani [mailto:[EMAIL PROTECTED]
> >Sent: Tuesday, December 23, 2003 2:24 AM
> >To: Struts Users Mailing List
> >Subject: RE: retrieving values from application.properties file
> >
> >hi,
> >One more thing to add is that I dont have access to request,pagecontext
> >etc.
> >I am writing a Servicelocator class and I want to access some values in
> >that file. Is it possible.
> >Otherwise I have to use my own resource bundle.
> >
> >
> >
> >
> >
> >>-----Original Message-----
> >>From: [EMAIL PROTECTED]
> >>[mailto:[EMAIL PROTECTED]
> >>Sent: Tuesday, December 23, 2003 12:48 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: RE: retrieving values from application.properties file
> >>
> >>
> >>Hi Ashwani
> >>
> >>In a jsp page use follwing code:
> >>
> >>
> >>org.apache.struts.util.PropertyMessageResources res =
> >>
> >>(org.apache.struts.util.PropertyMessageResources)application.ge
> >>tAttribut
> >>e(org.apache.struts.Globals.MESSAGES_KEY);
> >> out.println(res.getMessage("KEYNAME"));
> >>
> >>
> >>Dhiraj
> >>
> >>-----Original Message-----
> >>From: Kalra, Ashwani [mailto:[EMAIL PROTECTED]
> >>Sent: Tuesday, December 23, 2003 12:27 PM
> >>To: Struts (E-mail)
> >>Subject: retrieving values from application.properties file
> >>
> >>hi,
> >>I want to directly access the keys and its values in
> >>applcation.properties ( default resource bundle file in struts). Can
> >>any body tell me which is the class in struts(utility class) which
> >>helps me retrieve the values based on the keys from this file.
> >>
> >>/Ashwani
> >>
> >>____________________________________________________
> >>This message contains information that may be privileged or
> >>confidential and is the property of the Cap Gemini Ernst &
> >Young Group.
> >
> >>It is intended only for the person to whom it is addressed.
> >If you are
> >>not the intended recipient, you are not authorised to read, print,
> >>retain, copy, disseminate, distribute, or use this message or
> >any part
> >>thereof. If you receive this message in error, please notify
> >the sender
> >
> >>immediately and delete all copies of this message.
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >>DISCLAIMER:
> >>This message contains privileged and confidential information and is
> >>intended only for the individual named.If you are not the intended
> >>recipient you should not disseminate,distribute,store,print, copy or
> >>deliver this message.Please notify the sender immediately by
> >e-mail if
> >>you have received this e-mail by mistake and delete this e-mail from
> >>your system.E-mail transmission cannot be guaranteed to be secure or
> >>error-free as information could be
> >>intercepted,corrupted,lost,destroyed,arrive late or incomplete or
> >>contain viruses.The sender therefore does not accept
> >liability for any
> >>errors or omissions in the contents of this message which arise as a
> >>result of e-mail transmission. If verification is required please
> >>request a hard-copy version.
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> >____________________________________________________
> >This message contains information that may be privileged or
> >confidential
> >and is the property of the Cap Gemini Ernst & Young Group. It is
> >intended only for the person to whom it is addressed. If you
> >are not the
> >intended recipient, you are not authorised to read, print,
> >retain, copy,
> >disseminate, distribute, or use this message or any part
> >thereof. If you
> >receive this message in error, please notify the sender immediately and
> >delete all copies of this message.
> >
> >---------------------------------------------------------------------
> >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]
> >
>
> ____________________________________________________
> This message contains information that may be privileged or confidential
and
> is the property of the Cap Gemini Ernst & Young Group. It is intended only
> for the person to whom it is addressed. If you are not the intended
> recipient, you are not authorised to read, print, retain, copy,
disseminate,
> distribute, or use this message or any part thereof. If you receive this
> message in error, please notify the sender immediately and delete all
copies
> of this message.
>
> ---------------------------------------------------------------------
> 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]

Reply via email to