• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

jsp:include corrupts characters

 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic