how to display values of an arraylist defined in servlet using ajax call

Posted by veena123 on Stack Overflow See other posts from Stack Overflow or by veena123
Published on 2012-04-03T11:10:15Z Indexed on 2012/04/03 11:30 UTC
Read the original article Hit count: 225

Filed under:
|

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

© Stack Overflow or respective owner

Related posts about java

Related posts about AJAX