Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
rajeshkannan sella
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Albareto McKenzie
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi yaar,
Finally i solved it.willl update you soon my soution thanks
 
rajeshkannan sella
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic