java left logo
java middle logo
java right logo
 

Home arrow Java EE Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4094
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
JSTL - Localizing messages E-mail
User Rating: / 27
PoorBest 

This tip shows how to use the JSTL internationalization actions. Our web application consists of a JSP page and required number of resource bundles (English is given in example).

Switching locales is easy for the JSP page - just change the value specified for the action. The resource bundle has a base name set to my.messages. That resource bundle base name tells the JSP container that your messages resource bundle corresponds to a properties file (or a Java class file) in the WEB-INF/classes/my/:

English properties file

   page.title=Localizing Messages
   company.name=My Company, Inc.
   company.slogan=We Are The Best
<%@ taglib uri='http://java.sun.com/jstl/fmt' prefix='fmt'%>

<html>
	<head>

////////////// specify a locale and a resource bundle base name for the 
////////////// <fmt:message> actions in this page
		<fmt:setLocale value='en'/>
		<fmt:setBundle basename='my.messages'/>
		<%-- Use <fmt:message> to display the page title --%>
		<title>
			<fmt:message key='page.title'/>
		</title>
	</head>

	<body>

////////////// Use <fmt:message> to display localized messages from the 
////////////// com.acme.messages resource bundle 
		<font size='5'>
			<fmt:message key='company.name'/>
		</font>
		<p><fmt:message key='company.slogan'/> </p>
		<hr />
	</body>
</html>


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.