<TABLE>
<TR>
<TD>
<% for(int i=0;i<categories.size();i++){ %>
<button name="<%=categories.get(i)%>" type="button" onclick=<% session.setAttribute("category", categories.get(i));%> >
<%= categories.get(i)%>
</button>
<% } %>
</TD>
</TR>
<TR>
<TD>
<%
if(session.getAttribute("category") != null){
for(int i =0; i< pr.products.size();i++){
if(pr.products.get(i).category.equals(session.getAttribute("category"))){
out.print(pr.products.get(i).name);
}
}
}%>
</TD>
</TR>
</TABLE>
I'm trying to show the products in a category when clicking a button but since the page is not refreshed nothing changes and I can't call sendRedirect when a button is pressed.
How do I get around this?
<button name="Phones" type="button" onclick="">
Phones
</button>