Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How do i read a .properties file with tomcat 5.5/jstl 1.1.2?

Reply
Thread Tools

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

 
 
Dag Sunde
Guest
Posts: n/a
 
      12-19-2006
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...

--
Dag.


 
Reply With Quote
 
 
 
 
Manish Pandit
Guest
Posts: n/a
 
      12-19-2006
> 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

 
Reply With Quote
 
 
 
 
Dag Sunde
Guest
Posts: n/a
 
      12-20-2006
Manish Pandit wrote:
>> 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.
>


Manish... You're a genius!

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

Thank You



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
specifying path for file to be read by servlet with Tomcat Yang Xiao Java 4 05-30-2010 10:14 PM
File.read(fname) vs. File.read(fname,File.size(fname)) Alex Dowad Ruby 4 05-01-2010 08:20 AM
file.read() doesn't read the whole file Sreejith K Python 24 03-24-2009 12:20 PM
Read file from jar when applet loaded by Tomcat Nigel Wade Java 2 04-05-2005 04:25 PM



Advertisments