I have two jsp pages, index.jsp and Result.jsp. In index.jsp I have a text box and a Div. When user writes something in the textbox, the text with current date should appears in Div. On keyup event of text box I am sending an Ajax request to Result.jsp. With responseText method everything is working fine. But when I am sending an xml from server and trying to getting that with responseXML method, that is not working with following Result.jsp -
<%@ page import="java.util.Date"%>
<%
response.setContentType("text/xml");
Date now = new Date();
StringBuffer sb = new StringBuffer("<?xml version='1.0' ?><root>");
String name = request.getParameter("name");
sb.append("<data>");
sb.append(name + " / " + now);
sb.append("</data>");
sb.append("</root>");
out.print(sb);
%>
In this case responseXML is returning null.
But its working with following Result.jsp -
<%
response.setContentType("text/xml");
java.util.Date now = new java.util.Date();
StringBuffer sb = new StringBuffer("<?xml version='1.0' ?><root>");
String name = request.getParameter("name");
sb.append("<data>");
sb.append(name + " / " + now);
sb.append("</data>");
sb.append("</root>");
out.print(sb);
%>
I am not able to understand what is the problem with <%@ page import="java.util.Date"%> in previous case.