在线等大神!!帮我看看 这个jsp代码,我想把管理和用户jsp分开,但是运行说有错.求解答~
<%@pagecontentType="text/html;charset=gb2312"import="java.sql.*"%><jsp:useBeanid="con...
<%@ page contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="conn" property="connStr" value="jdbc:odbc:mydesign"/>
<%
request.setCharacterEncoding("gb2312");
session.setMaxInactiveInterval(-1);
String user=request.getParameter("user");
String pw=request.getParameter("pw");
String sql="select * from user where name='"+user+"' and password='"+pw+"'";
ResultSet rs=conn.executeQuery(sql);
if(rs.next())
{
if(session.getAttribute("type").equals("1"))
{
session.setAttribute("type",rs.getString("type"));
session.setAttribute("id",rs.getString("id"));
session.setAttribute("name",rs.getString("name"));
rs.close();
conn.close();
}
%>
<jsp:forward page="management.jsp"/>
<% else{
session.setAttribute("type",rs.getString("type"));
session.setAttribute("id",rs.getString("id"));
session.setAttribute("name",rs.getString("name"));
}
}
%>
<jsp:forward page="home.jsp"/>
<%
else
{
rs.close();
conn.close();
}
%>
<jsp:forward page="index.jsp">
<jsp:param name="warning" value="对不起,您的用户名或密码不正确"/>
</jsp:forward> 展开
<jsp:useBean id="conn" class="dbBean.DBBean" scope="session"/>
<jsp:setProperty name="conn" property="connStr" value="jdbc:odbc:mydesign"/>
<%
request.setCharacterEncoding("gb2312");
session.setMaxInactiveInterval(-1);
String user=request.getParameter("user");
String pw=request.getParameter("pw");
String sql="select * from user where name='"+user+"' and password='"+pw+"'";
ResultSet rs=conn.executeQuery(sql);
if(rs.next())
{
if(session.getAttribute("type").equals("1"))
{
session.setAttribute("type",rs.getString("type"));
session.setAttribute("id",rs.getString("id"));
session.setAttribute("name",rs.getString("name"));
rs.close();
conn.close();
}
%>
<jsp:forward page="management.jsp"/>
<% else{
session.setAttribute("type",rs.getString("type"));
session.setAttribute("id",rs.getString("id"));
session.setAttribute("name",rs.getString("name"));
}
}
%>
<jsp:forward page="home.jsp"/>
<%
else
{
rs.close();
conn.close();
}
%>
<jsp:forward page="index.jsp">
<jsp:param name="warning" value="对不起,您的用户名或密码不正确"/>
</jsp:forward> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询