Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

How do i read a .properties file with tomcat 5.5/jstl 1.1.2?

Thread view: 
Dag Sunde - 19 Dec 2006 13:28 GMT
I have Tomcat 5.5.20 and jakarta-taglibs-standard-1.1.2

I try to use the form: "<fmt:message key="tittel"/>" in a JSP page,
but it shows up as:  "???tittel???"

I've copied the jstl .jar files to my WEB-INF/lib directory, and fmt.tld &
c.tld
to the WEB-INF directory.

I have updated the web.xml file with the following:
<jsp-config>
<taglib>
 <taglib-uri>http://jakarta.apache.org/taglibs/core</taglib-uri>
 <taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
<taglib>
 <taglib-uri>http://jakarta.apache.org/taglibs/fmt</taglib-uri>
 <taglib-location>/WEB-INF/fmt.tld</taglib-location>
</taglib>
</jsp-config>

My .jsp file looks like this:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
 <title>Insert title here</title>
 <link rel="stylesheet" type="text/css"href="styles/fotoproto.css"
media="screen" />
</head>
<body>
 <fmt:setBundle basename="labels"/>
 <div style="text-align: center;">
  <h1><fmt:message key="tittel"/></h1>
  <a href="PictureResult.jsp">Ta bilde!</a>
 </div>
</body>
</html>

The content of "labels.properties" id:
 tittel=Press the link below to take picture
 linklabel=Take picture...

I tried to put my "labels.properties" file in both the
WEB-INF/ and the WEB-INF/lib/ directory, but my

   <fmt:message key="tittel"/>

show up as "???tittel???"

Can anybody explain this/help me?

TIA...

Signature

Dag.

Manish Pandit - 19 Dec 2006 19:25 GMT
> I tried to put my "labels.properties" file in both the
> WEB-INF/ and the WEB-INF/lib/ directory, but my

The file must be in the container classpath. So you got WEB-INF/lib or
WEB-INF/classes.
You can jar it up as a resource and then put in WEB-INF/lib, or simply
put the plain-text file in WEB-INF/classes folder. Also, try renaming
it to labels_en.properties if your locale is english.

-cheers,
Manish
Dag Sunde - 20 Dec 2006 01:53 GMT
>> I tried to put my "labels.properties" file in both the
>> WEB-INF/ and the WEB-INF/lib/ directory, but my
[quoted text clipped - 4 lines]
> put the plain-text file in WEB-INF/classes folder. Also, try renaming
> it to labels_en.properties if your locale is english.

Manish... You're a genius!

"put the plain-text file in WEB-INF/classes"...
(I had it in WEB-INF/lib).

Thank You


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.