I am attempting to execute an in-page JavaScript function from within a JSP page. Here is the code snippet, however, the JavaScript functions do not appear to be executing when the JSP page loads on the client side. Is there anything incorrect with the approach I am taking to call these functions?
<% //additional jsp code
if(count>0) { response.sendRedirect("main.jsp"); %>
<script type="text/javascript> setCookie('user','<%=user1%>',1); </script>
<% } else { response.sendRedirect("index.jsp"); %>
<script type="text/javascript"> alert("please enter proper credentials and log in again"); </script>
<% } // more jsp code %>