Hi
I'm trying to use a script in my servlet. When a user creates a query a list of items is generated. On clicking on the item, I want something (i'm trying to use a script but if there are better solutions please tell me) to get the id of the item and open my "show" script.
Unfortunately its going into my script before even displaying the list of items
PrintWriter out = response.getWriter();
try {
out.println("<SCRIPT TYPE='text/javascript'>");
out.println("function openItemDetails(ID) {");
out.println("alert('hello')");
HttpSession ses = request.getSession(true);
ses.setAttribute("item",ID);
response.sendRedirect("Show");
out.println("}");
out.println("</SCRIPT>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ProcessSearch</title>");
out.println("</head>");
out.println("<body>");
for (int i=0; i<items.size(); i++) {
Items itemToGet = (Items)items.get(i);
out.println("<button type='button' onClick='openItemDetails(itemToGet.getId())'>"+itemToGet.getName()+"</button>");
}
}
out.println("<a href='Welcome'>Go back to main page</a>");
out.println("</body>");
out.println("</html>");
} finally {
out.close();
}
Please help me
thnx