Iam new to using Ajax and I have few doubts. What actually does .responsetext method on the XMLHttp Object retreive in case i use it to Http Get to a servlet. Is it possible I can send a message from servlet when get is done from a servlet as a responsetext, if so how can it be done.Please explain in detail.
Thanks in advance.. [ October 21, 2008: Message edited by: harsha galla ]
Say your servlet returns a well formed XML document. When the readyState property of the XMLHttpRequest object is 4 (i.e. DONE) responseXML will be a DOM Document of the XML and responseText will have a DOMString of the XML.
When your servlet returns some old text and readyState is 4 responseXML will be null but responseText will have the text as a DOMString.
Joined: Aug 05, 2008
You'll need the servlet to handle the Exception and send some error code back to the XMLHttpRequest and handle it that way.
It seems obvious that you can't propagate Java exceptions through XHR. However you could send the Exception stack trace back, but it is probably not a good idea to show this to the user.