• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL unicode xml does not display after x:parse call

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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" />
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic