how to display values of an arraylist defined in servlet using ajax call
- by veena123
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 displayng 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