Can anyone please help me with below code
servlet:
below servlet is for statically defining an array.
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class SampleAjax extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException
{
response.setContentType("text/html");
string plociyno = "abd1234";
PrintWriter pw = response.getWriter();
if (policyno.equals("abc1234"))
{
List dataList= new ArrayList();
dataList.add("automated refund possible");
request.setAttribute("data",dataList);
RequestDispatcher dispatcher = request.getRequestDispatcher("refund.jsp");
if (dispatcher != null){
dispatcher.forward(request, response);
}
}
}
and my JSP: JSP for displaying the values of the arraylist in a table. I want to do the same thing but using Ajax. Please help.
<html
<body><table id= "table" border="0" width="303">
<tr>
<td width="250"><b>Your Policy Refund Details is:</b></td>
</tr>
<%Iterator itr; %>
<% ArrayList refund= (ArrayList)request.getAttribute("data");
if(refund != null){
for(itr=refund.iterator(); itr.hasNext();){
%>
<tr>
<td><%=itr.next()%></td>
</tr>
<%}}%>
</table>
</body>
</html>
how can I display this arraylist values using ajax? Please help.