这是第一种使用的是onload方法其中的test是自己的servlet
<html> <body onload = "test"> </body> </html>下面是用的js调用servlet实现
<script language='javascript'> function test(){ window.open('','','')//参数可设你要调用的servlet, //可让此页面在台运行 } </script>现在在jsp中使用session验证用户是否登录
<% if(session.getAttribute("userinfo") == null) { %> <script type="text/javascript" language="javascript"> alert("您还没有登录,请登录..."); window.document.location.href="userlogin.html"; </script> <% } %>
版权声明:本文为博主原创文章,未经博主允许不得转载。
启动网页时候自动加载servlet如果不使用strus最常用的两种方式
原文地址:http://blog.csdn.net/bluezhangfun/article/details/46698027