Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

AJAX servlet to responseXML responseText

843841Dec 28 2005 — edited Dec 28 2005
How Ajax decides, which response it will set to responseXML and which to responseText.

private void writeResponse(HttpServletResponse resp, String output) throws IOException {
resp.setContentType("text/xml");
resp.setHeader("Cache-Control", "no-cache");
//resp.getWriter().write(output);
PrintWriter out = resp.getWriter();
out.write(output);
//out.println(output);
//out.flush();
}

if I use the above function in my servlet, I don't get the responseText, but if I use the following function I get responseText.

private void writeResponse(HttpServletResponse resp, String output) throws IOException {
resp.setContentType("text/xml");
resp.setHeader("Cache-Control", "no-cache");
//resp.getWriter().write(output);
PrintWriter out = resp.getWriter();
//out.write(output);
out.println(output);
out.flush();
}

Please clarify.
regards,
Saptarshi
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 25 2006
Added on Dec 28 2005
1 comment
171 views