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

D

Dag Sunde

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...
 
M

Manish Pandit

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
 
D

Dag Sunde

Manish said:
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.

Manish... You're a genius!

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

Thank You
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top