下面的例子通过简单的session实现验证:
<%@page contentType="text/html;charset=gb2312" %>
<%@page import="java.util.*" %>
<html>
<head>
<title>对请求的访问权限判断
</title>
</head>
<body>
<center>
<%
String id;
String user_name;
id=(String)session.getValue("user_id");
user_name=(String)session.getValue("user_name");
%>
<%if ((id==null)||(user_name==null))
out.print("<font size=4 color=red>抱歉,非法用户不能进入系统!</font>");
%>
<br>
<%if ((id!=null)&&(user_name!=null))
out.print("欢迎使用本系统功能!");
%>
</center>
</body>
</html>