The issues that are being encountered here are that
XML has some special characters that need to be
encoded in order for parsing to work correctly.
Namely, these are the '&','<', '>', '"', and '''
characters. The URLEncoder class is meant to perform
URL encoding and decoding which has a different set of
special characters. The URLEncoder rules for encoding
are as follows:
The ASCII characters 'a' through 'z', 'A' through 'Z',
'0' through '9', and ".", "-", "*", "_" remain the
same. 

The space character ' ' is converted into a plus sign
'+'. 

All other characters are converted into the
3-character string "%xy", where xy is the two-digit
hexadecimal representation of the lower 8-bits of the
character. 

As you can see, the space character is converted by
the URLEncoder to a '+' which then would not get
decoded back to a space by the JavaScript XML
functions.

I suppose the proper thing to do on the server side is
to use an XML encoding method rather than the
URLEncoder method.

-Richard

--- [EMAIL PROTECTED] wrote:

> Thank you Gareth, Frank and Richard.  It worked...  
>  
> I replaced & with %26 in my servlet and used
> javascript unescape to to get is back they way it
> should
>  
> I tried URLEncoder.encode() the values in servlet
> but it seems that the unscape is not converting + to
> spaces.  In any case, it works.  Thanks so much for
> your time.
>  
> 
> "Frank W. Zammetti" <[EMAIL PROTECTED]> wrote:
> I think he said he tried that, buit now I'm
> thinking... I think he tried
> replacing it with an HTML entity... how about using
> the URL encoded
> version (%27 I think?). Is there maybe an
> XML-specific way to encode it?
> (I would have thought the & entity would have worked
> frankly, but he
> said it didn't).
> 
> -- 
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> 
> On Tue, September 6, 2005 12:09 pm, Richard Yee
> said:
> > Is the ampersand part of the XML message being
> sent
> > back to the browser from the servlet? If so, you
> need
> > to escape the ampersand in the servlet before it
> is
> > sent in the servlet response. The ampersand is a
> > special character in XML.
> >
> > -Richard
> >
> > --- "Frank W. Zammetti" wrote:
> >
> >> That's kind of what I was afraid of... makes it
> more
> >> difficult to deal with.
> >>
> >> The getAttribute() method is actually a method of
> >> the node object, which
> >> is what your dealing with by that point in the
> code.
> >> It's not even an
> >> AJAX question at that point. You might try doing
> >> items[i].nodeValue
> >> instead, or perhaps even .innerHTML might work
> (note
> >> these are properties,
> >> not methods)... I lost the XML you sent
> perviously,
> >> and I don't remember
> >> if your values were attributes or the content of
> a
> >> tag.
> >>
> >> The only note of interest I found was that if you
> >> are using IE,
> >> getAttribute() can return the value as a string,
> >> number or boolean,
> >> whereas other browsers will return it as a string
> >> exclusively... if you
> >> happen to be using IE, that could be the problem,
> >> and going after the
> >> nodeValue itself *might* get around it.
> >>
> >> --
> >> Frank W. Zammetti
> >> Founder and Chief Software Architect
> >> Omnytex Technologies
> >> http://www.omnytex.com
> >>
> >> On Tue, September 6, 2005 11:37 am,
> >> [EMAIL PROTECTED] said:
> >> > Gareth, try/catch didn't reveal anything.
> >> >
> >> > Frank, after numerous alerts, the problem seems
> to
> >> be in getAttribute(...)
> >> > function of AJAX:
> >> >
> >> > for (var i = 0; i < items.length; i++) {
> >> > alert("ID:" + items[i].getAttribute('dataID'));
> >> > alert("Value:" +
> >> items[i].getAttribute('dataValue'));
> >> > }
> >> >
> >> > Here is that AppendValues(...) method
> >> >
> >> > function AppendValues(col,arr,label)
> >> > {
> >> > col.options[col.options.length] = new
> >> Option(label);
> >> > col[col.length-1].value = arr;
> >> > }
> >> >
> >> >
> >> > "Frank W. Zammetti" wrote:
> >> > Ok, two things...
> >> >
> >> > (1) Throw an alert in right before the call to
> >> AppendValues() :
> >> >
> >> > alert(items[i].getAttribute('dataID') + " = " +
> >> > items[i].getAttribute('dataValue'));
> >> >
> >> > Make sure you see the ampersand in there.
> >> >
> >> > (2) Assuming you do see the ampersand in that
> >> alert, let's see the code
> >> > for AppendValues(), because it has to be where
> the
> >> problem is then.
> >> >
> >> > Frank
> >> >
> >> > --
> >> > Frank W. Zammetti
> >> > Founder and Chief Software Architect
> >> > Omnytex Technologies
> >> > http://www.omnytex.com
> >> >
> >> > On Tue, September 6, 2005 10:43 am,
> >> [EMAIL PROTECTED] said:
> >> >> Here you go Frank:
> >> >>
> >> >> AJAX CODE:
> >> >>
> >> >> function getNewXMLHttpRequest() {
> >> >> var _req;
> >> >> // branch for native XMLHttpRequest object
> >> (safari/mozilla)
> >> >> if (window.XMLHttpRequest) {
> >> >> _req = new XMLHttpRequest();
> >> >> }
> >> >> // branch for IE/Windows ActiveX version
> >> >> else if (window.ActiveXObject) {
> >> >> _req = new ActiveXObject("Microsoft.XMLHTTP");
> >> >> }
> >> >> return _req;
> >> >> }
> >> >> function getdataValues(fieldname){
> >> >> var state =
> >> >>
> >>
> >
>
document.actionForm.state[document.actionForm.state.selectedIndex].value;
> >> >> var url = "getXMLValues.jsp?state="+state;
> >> >> var xmlhttp = getNewXMLHttpRequest();
> >> >> xmlhttp.open("GET",url,true);
> >> >> xmlhttp.onreadystatechange = function() {
> >> >> if (xmlhttp.readyState == 4) {
> >> >> if (xmlhttp.responseXML != null) {
> >> >> var items =
> >> >>
> >>
> xmlhttp.responseXML.getElementsByTagName("dataSet");
> >> >> var culumnname = eval("document.actionForm." +
> >> fieldname);
> >> >> for (var i = 0; i < items.length; i++) {
> >> >> AppendValues(culumnname,
> >> items[i].getAttribute('dataID'),
> >> >> items[i].getAttribute('dataValue'));
> >> >> }
> >> >> culumnname.selectedIndex=0;
> >> >> }
> >> >> }
> >> >> }
> >> >> xmlhttp.send(null);
> >> >> }
> >> >>
> >> >>
> >> >> JSP CODE:
> >> >> > Select a State>
> >> >> > Select a Country>
> >> >>
> >> >> SERVLET CODE (modified...)
> >> >>
> >> >> ( multiple checks...)
> >> >> if (state != null && state.length() > 0) {
> >> >> searchFor = "COUNTRY_ID, COUNTRY_NAME";
> >> >> whereIs= "STATE = '" + state + "'";
> >> >> }
> >> >>
> >> >> sql = "SELECT " + searchFor + " FROM
> DATA_TABLE
> >> WHERE " + whereIs;
> >> >>
> >> >> Compile data from that query to xml and return
> to
> >> browser.
> >> >> eg:
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to