<%
if(session.getAttribute("userName") == null){
%>
<SCRIPT language=JavaScript>
alert("您无权访问该网页,或者您离开的时间太久了,请先登陆!");
window.location="aaaenter.jsp";
</SCRIPT>
<%
}
else{
%>
if(session.getAttribute("userName") == null){
%>
<SCRIPT language=JavaScript>
alert("您无权访问该网页,或者您离开的时间太久了,请先登陆!");
window.location="aaaenter.jsp";
</SCRIPT>
<%
}
else{
%>
description:
request:null
post:null
session:
--%>
<SCRIPT language=JavaScript>
</SCRIPT>
<html>
<head>
<title>
中国!
</title>
<link rel="stylesheet" href="STYLE1.CSS">
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import = "java.sql.*"%>
</head>
<body bgcolor="#ffffff" leftMargin=0 topMargin="50%">
<table width = "700" border = 0 bgcolor="#F8D2C9" align="center" bordercolor="#000000" cellpadding="1">
<tr>
<jsp:useBean id = "db" scope = "page" class = "ydsp.aaaOpen"/>
<%
String userName = request.getParameter("userName").trim();
String userKey = request.getParameter("userKey").trim();
db.setQuerystatement("select * from username where name = '"+userName+"' and nameKey = '"+userKey+"'");
int intclass = 0;
String userclass = "";
ResultSet rs = db.getResult();
if(rs.next()){
%>
<SCRIPT language=JavaScript>
window.location="aaaindex.jsp";
</SCRIPT>
<%
intclass = rs.getInt("class");
userclass = String.valueOf(intclass);
session.setAttribute("userName", userName);
session.setAttribute("userKey", userKey);
session.setAttribute("userclass", userclass);
}
else{
%>
<SCRIPT language=JavaScript>
alert("对不起,验证没有通过!");
window.location="aaaenter.jsp";
</SCRIPT>
<%
}
rs.close();
%>
<td> </td>
</tr>
</table>
</body>
</html>
我是出学者,还没用到BEAN,不太清楚它的用法,我不会用BEAN,而是直接连好数据库后用SQL操作的.另外,这些代码是否应写在"登陆页"与"目标页"之间的"过渡页"中,然后通过"过渡页"进入"目标页"呢?
if(!(session.getValue("userName")).equals("yourrequestusername")){
%>
<SCRIPT language=JavaScript>
alert("您无权访问该网页,或者您离开的时间太久了,请先登陆!");
self.location="aaaenter.jsp";
</SCRIPT>
<%
}
else{
%>
//用getValue () 和putValue("", var)吧相对简单