You should be using URLEncoding.encode() to encode the
response. This will replace ampersands with %26. The
only problem is that the space character is also
converted to a '+'. You then need to replace '+' with
%20 on the server after using URLEncoder.encode() so
that the JavaScript can decode it correctly.

-Richard

--- "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 &amp; 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" <[EMAIL PROTECTED]>
> 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" <[EMAIL PROTECTED]>
> 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:
> >> >> > dataValue="United States & US Vargin
> Islands"
> >> />>
> >> >> dataValue="Australia" />
> >> >>
> >> >>
> >> >>
> >> >> "Frank W. Zammetti" wrote:
> >> >> Let me see if I'm all caught up here (I'm just
> >> back to work from
> 
=== message truncated ===



        
                
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

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

Reply via email to