Gareth, you are correct abut ajax being independent. In my case, the
interesting thing is that the servlet is using database to look up the data and
requires where cause as a parameter so that it can generate a query, retrieve
data from database, create xml to be passed to the calling .jsp page.:
i.e.: here are the steps
1. onchange() getdataValues.jsp?state='NY'
2. in servlet, ( multiple checks...)
if (state != null && state.length() > 0)
{
searchFor = "COUNTRY_ID, COUNTRY_NAME";
whereIs= "STATE = '" + state + "'";
}
sql = "SELCT " + searchFor + " FROM DATA_TABLE WHERE " + whereIs;
3. compile data from that query to xml and return to browser.
In this case, the database holds the ampersand. not the parameters that are
passed to the servlet. When I print out the results that the servlet rturned.
It looks like this:
<?xml version="1.0" encoding="UTF-8" ?><root><dataSet dataID="USA"
dataValue="United States & US Vargin Islands" /><dataSet dataID="AUS"
dataValue="Australia" /></root>
The drop down populates when I delete the USA record from the database. So, it
seems that the data that is returned needs to be parsed somehow before AJAX can
parse and populate the country dropdown. Does this help?
Gareth Evans <[EMAIL PROTECTED]> wrote:
Hi Bob,
Even so, the request that your making to your 'ajax servlet', the url depends
on the value of the
first select box. Somthing like 'myajaxservlet?firstvalue=Australia'
are you building this url in javascript before making the request? thats the
point at which you want
to encode it. If you are doing it this way, the servlet will be unable to
handle the request as you
expected because it will take "United States" and "US Vargin Islands" as
separate parameters rather
than a single one. Why? because '&' is used as the delimeter. If you use the
javascript escape
function e.g javascript:escape('United States & US Vargin Islands'), your
servlet will handle this
as a single parameter.
It doen't matter that your not using struts, ajax is independant of your
servlet side code, it could
be written in asp if you are that way inclined ;-)
Gareth
---------------------------------
Click here to donate to the Hurricane Katrina relief effort.