aspose file tools*
The moose likes Struts and the fly likes i have a requirement in struts, need to use 2 properties file for two jsp's? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "i have a requirement in struts, need to use 2 properties file for two jsp Watch "i have a requirement in struts, need to use 2 properties file for two jsp New topic
Author

i have a requirement in struts, need to use 2 properties file for two jsp's?

rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
i have a requirement in struts

1. i have two applicationresources.properites file
one for english - ApplicationResources.properties
one for welsh language - ApplicationResources_cy.properties

2. and i have separate forms for both the laguage
english - lost.jsp
english - lost_cy.jsp

i want to use the properites file corresponding to their forms?
Suggest me some ideas.

Thanks in advance
Rajesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61596
    
  67

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
You have to ask yourself, do you need two jsps?
How do you store the information in the properties?

Wow, welsh is a crazy language!
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
Hi yaar,
Finally i solved it.willl update you soon my soution thanks
rajeshkannan sella
Greenhorn

Joined: Apr 23, 2009
Posts: 25
How to use more than one ApplicationResources.properties in struts.

SCENARIO
The scenario is you have two properties files
1. one for english(For Example) - ApplicationResources.properties
1. one for welsh(For Example) - ApplicationResources-cy.properties

The two jsp one is for english 1. lost.jsp
for welsh 2. lost-cy.jsp

The change to be made in the
1. web.xml 2. struts config.xml 3. lost-cy.jsp

<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>/WEB-INF/classes/com/example/ApplicationResources.properties</param-value>
</init-param>
<init-param>
<param-name>application1</param-name>
<param-value>/WEB-INF/classes/com/example/ApplicationResources-cy.properties</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>lost.jsp</welcome-file>
</welcome-file-list>
</web-app>

<message-resources parameter="com.example.ApplicationResources" null="false"/>
<message-resources parameter="com.example.ApplicationResources-cy" key="welsh" null="false" />


To access ApplicationResources.properites, use <bean:message key="aKey"/>

Then to access ApplicationResources-cy.properties,

just use <bean:message bundle="welsh" key="anotherKey"/>

Both the properties file having the Key is same but the value differs.

Follow the above to work successfully with two properties file for two jsp thats differs in language

This example Matches only for the scenario at the top
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i have a requirement in struts, need to use 2 properties file for two jsp's?