I have a page and there are 3 images in that so now when click an image want to set session attribute like this
<a href="voting.jsp"><img onclick="myfunction('image_one')" src="image_one.jpg"></a>
<a href="voting.jsp"><img onclick="myfunction('image_two')" src="image_two.jpg"></a>
<a href="voting.jsp"><img onclick="myfunction('image_three')" src="image_three.jpg"></a>
<script>
function myfunction(name)
if(name='image_one')
<% session.setAttribute("user","image_one") %>
else if(name='image_two')
<% session.setAttribute("user","image_two")%>
elseif(name='image_three')
<% session.setAttribute("user","image_three")%>
</script>
now the answer is alway image_three when i use session.getAttribute in the voting.jsp page why