Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:include corrupts characters

 
Kelly Dolan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have the following...

// HTML page
<html>
<head>
<script type="text/javascript" src="scripts.jsp"></script>
...

// scripts.jsp
<%@page contentType="text/javascript" %>
<jsp:include page="page1.js" />
...

// page1.js
var obj = new Array();
obj[obj.length] = "str1";
obj[obj.length] = "str2";
obj[obj.length] = "str &PlusMinus ing";


we noticed a problem when the HTML displayed the "±" value found in obj[] - it was some weird funky character, obviously corrupt. if I inspect page1.js, the "&PlusMinus" is the correct character. if I inspect scripts.jsp after the jsp:include and before it is sent to the browser, the "±" is corrupted. therefore, i can only come to the conclusion that the jsp:include is corrupting the character.

a) this is a problem for more than just ±
b) jsp:include doesn't seem to have a parameter or attribute that can be set re: charset
c) JSP documentation states that adding "charset:UTF-8" to the @page declaration has no affect on jsp:include
d) I cannot use the other "include" because our content is dynamic, not static
e) I cannot reference page1.js from the HTML directly because some of our pages are not actually in web-accessible locations

help! how does one get jsp:include to use the correct charset so not to corrupt the characters of the content being included?

thanks!
kelly
 
Stefan Evans
Bartender
Posts: 1721
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please define what "corrupted" means?
How did you determine it was corrupted?

If you try and load scripts.jsp directly, does it load the content you are after? (including in the view source?)

What would you expect the &plusMinus to do in a javascript string in any case?

 
Kelly Dolan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>> Can you please define what "corrupted" means? How did you determine it was corrupted?

Sure. And my mistake I left an important piece of info out... The ± is in an XML file that gets passed thru a Transformer (XSL) that generates page1.js. When it is in page1.js, it is no longer ± but C2B1. This was determined by opening page1.js in a HEX editor.

Following this, we used a debugger to see the result of scripts.jsp on the server before it is returned as the HTTP response. The character is no longer C2B1.

>> If you try and load scripts.jsp directly, does it load the content you are after? (including in the view source?)

If you mean enter the URL to scripts.jsp directly in the browser, the result is the same. Yes, we get the full content we expect but the character is corrupt.

>> What would you expect the &plusMinus to do in a javascript string in any case?

Technically nothing. But the javascript creates HTML at run-time given these values and places this value in let's say a <div> tag. Instead of seeing a true plus/minus sign, we see garbled characters (e.g., A, boxes).
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My HTML reference says you want amp plusmn ; to get ± (without spaces of course)
which has the decimal value 177 get the plus/minus character.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic