Using JSP with Buttons
Do something like this:-
<%
if(request.getParameter("buttonName") != null) {
session.setAttribute("status", "guest");
}
%>
<FORM NAME="form1" METHOD="POST">
<INPUT TYPE="HIDDEN" NAME="buttonName">
<INPUT TYPE="BUTTON" VALUE="Button 1" ONCLICK="button1()">
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!--
function button1()
{
document.form1.buttonName.value = "yes";
form1.submit();
}
// -->
</SCRIPT>
either use:
<input type="submit" value="click"/>
and set form action to some servlet/jsp page where you set you'r session attributeuse ajax in onclick button method.
JQUERY SAMPLE:
$.ajax({ url: "srvServlet", //or setJSP.jsp success: function(){ alert ('ok'); } });