Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSTL unicode xml does not display after x:parse call

 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, thanks in advance for this one.

I am trying to display an xml file on the web using JSTL xml tags. The file is encoded in utf-8 containing ancient Greek characters (x1f92, etc.). The file displays properly from a servlet + xslt (http://163.1.169.41/testapp), but I want to use JSTL.

The JSTL produces intricate spaghetti on the screen (e.g. �†������������� ). I have seen this before --it would seem that unicode is indeed being directed at the screen but is not being interpreted properly. (Not strings of question marks mind you; the unicode seems to be there in this case).

The code producing the spaghetti is below. I am just dumping in on the screen for now and will use xpath calls later for more precise extraction.

Does the JSTL want character entities for the x arse call? I would not think so: parsing a utf-8 file would be a very common operation. How can I get the xml unicode file to display properly using the JSTL below?


[headers]
<%@ page contentType="text/html; charset=utf-8"pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

<!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">

...


<c:import var="papyrus" url="blabula.xml" />
<x arse var="doc" xml="${papyrus}" />
<x ut select="$doc" />

....
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, didn't see the directions. Platform is Tomcat 5.28 and JSTL 1.1.
 
Benjamin Weaver
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Figured it out. Simply add a charEncoding="UTF-8" to the import tag does the trick:

<c:import var="papyrus"
charEncoding="UTF-8" url="blabula.xml" />
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic