File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes special characters in  JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "special characters in  JSTL" Watch "special characters in  JSTL" New topic

special characters in JSTL

Haiko van der Schaaf

Joined: Jan 19, 2005
Posts: 8

I got a problem with displaying the character �. The code of the jsp is:

<cut value="${someproperty}" escapeXml="false"/>

The static content in the JSP displays the � correctly, but in the out-tag the character is misformed. I have set the page encoding and contentType of the page in utf-8 and the string someproperty correctly shows an � with debugging, but somewhere in the translation from the controller to the view the character is misformed. Has anyone an idea what happens ??

Thanks Haiko
Haiko van der Schaaf

Joined: Jan 19, 2005
Posts: 8
problem was in the <c:import> tag. When I add the attribute charEncoding with the value utf-8 the problem was solved. I did a recursive import in this jsp file(mijnxtranet/notifylevel.jsp). The complete code is:
What a bit strange is that the directive is overruled by the import attribute.

<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/struts-bean-el.tld" prefix="bean-el"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html-el.tld" prefix="html-el"%>
<%@ taglib uri="/WEB-INF/struts-logic-el.tld" prefix="logic-el"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/fmt.tld" prefix="fmt"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>

<html-el:xhtml />

<c:set var="my_node" value="${requestScope.recurse_node}" />

<c:set var="ulclass" value="open" />
<c:if test="${!my_node.uitgeklapt}">
<c:set var="ulclass" value="closed" />

<ul id="<cut value='ul_${my_node.klapTagValue}' />"
class="<cut value='${ulclass}' />">
<c:forEach var="curcat" items="${my_node.children}">
<li id="<cut value='${curcat.klapTagValue}' />">
klapbaar: <cut value="${curcat.klapbaar}" />
uitgeklapt: <cut value="${curcat.uitgeklapt}" />
<c:when test="${curcat.klapbaar}">
<c:when test="${curcat.uitgeklapt}">
<html-el:img src="/images/global/min.gif"
styleId="img_${curcat.klapTagValue}" border="0" alt="" />   
<html-el:img src="/images/global/plus.gif"
styleId="img_${curcat.klapTagValue}" border="0" alt="" />   
<html-el:img src="/images/global/minplusspacer.gif" border="0"
alt="" />   
<c:set var="checked" value="" />
<c:if test="${curcat.checked == true}">
<c:set var="checked" value="checked" />

<input type="checkbox" name="cat_<cut value="${}"/>"
value="<cut value="${}"/>" <cut value="${checked}"/>
<c:if test="${!curcat.allChildrenChecked}"> style="background-color: #ddd"</c:if> />
<cut value="${curcat.naam}" />
<c:if test="${not empty curcat.children}">
<c:set var="recurse_node" value="${curcat}" scope="request" />
<c:import url="../mijnxtranet/notifylevel.jsp" charEncoding="UTF-8"/>
<c:set var="recurse_node" value="${my_node}" scope="request" />
[ August 07, 2006: Message edited by: Haiko van der Schaaf ]
I agree. Here's the link:
subject: special characters in JSTL
It's not a secret anymore!