⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 login.jsp

📁 jsp的技术教程
💻 JSP
字号:
<%@ include file="header.inc"%> 
<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />      
<%@ page language="java" import="java.sql.*" %>
<jsp:useBean id="workM" scope="page" class="test.faq" />

<%!
public String getStr(String str)
{
	try
	{
		String temp_p=str;
		byte[] temp_t=temp_p.getBytes("ISO8859-1");
		String temp=new String(temp_t);
		return temp;
	}
	catch(Exception e)
	{
	 
	}
	return "null";
}
%>

<%!
	String logname,logpass;
	boolean loginAttempt = false;
	boolean loginOK = false;
	String errorMessage = "请您登陆";
%>
<%
if(request.getParameterValues("login") != null 
&& request.getParameterValues("login")[0].trim().equals("GO!")
&&request.getParameterValues("logname") != null
&&request.getParameterValues("logpass") != null)
{
	loginAttempt = true;
}
if (loginAttempt)
{	
	logname=request.getParameter("logname");
	logpass=request.getParameter("logpass");
	logname=getStr(logname);
	logpass=getStr(logpass);
	String sql="select * from member where logname='"+logname+"' and password='"+logpass+"'";
	ResultSet RS=workM.executeQuery(sql);
	int rowscount=0;
	try
	{
		while(RS.next())
		{
			rowscount++;
		}
	}
	catch(Exception e)
	{

	}
	if(rowscount!=0)
	{
		errorMessage="成功登陆";
		session.setAttribute("username",logname);
		loginOK=true;
		
		if(loginOK){
		String url;
		url=request.getParameter("url");
		out.println(url);
			if(url==null){
				response.sendRedirect("http://localhost:8080/jspbook/ec");
			}
			else{
				response.sendRedirect("http://localhost:8080"+url);
			}
		}
	}else{ 
	errorMessage="您的用户名或者密码不正确";
	session.setAttribute("username","");
	}
}
%>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=760 align="center">
  <TBODY>
  <tr><td align="left" height=25><%if(session.getAttribute("username")!=null){out.println(session.getAttribute("username"));}%>  当前位置:<a href="../index.jsp">首页</a> -&gt; 成员服务  </td>
  <td align="right"> <%@ include file="date.inc"%> </td>
  </tr>
  <TR bgColor=#3399ff>
    <TD height=1 colspan="2"><IMG height=1 src="images/spacer.gif" 
  width=16></TD></TR>
  <tr><td height=10 colspan="2"><IMG height=1 src="images/spacer.gif" 
  width=16></td></tr>
  </TBODY></TABLE>

  <table align="center" border="0" width="760" cellspacing="0" cellpadding="0" height="355">                  
	<tr>                  
		<td width="150" height="355" valign="top">                  
			<%@ include file="table.inc"%>               
		</td>                  
		<td width="10" height="100%"></td>
		<td width="1" height="100%" bgcolor="#3399ff"></td>
		<td width="10" height="100%"></td>
		<td width="589" height="331" valign="top" background="images/bg1.gif">                       
        <table border="0" width="100%" cellspacing="0" cellpadding="0" height="307">                  
          <tr>                  
            <td width="100%" colspan="2" height="20" bgcolor="#3399ff">&nbsp;<font color="#ffffff">成员登录</font>       
			</td>
		  </tr>

	<tr><td align="right" height="32" width="40%">
	<font color=red><%=errorMessage%></font>	
	</td>
	</tr>
	  		  	<form action="" method="post">
			<tr><td align="right" height="32" width="40%">名字:</td>
            <td>
              <input type="hidden" name="returl" value="">
			  <input type="text" name="logname" value="">
            </td>
          </tr>
          <tr> 
            <td align="right"  height="32">密码:</td>
            <td>
              <input type="password" name="logpass">
            </td>
          </tr>
          <tr> 
            <td align="center" colspan="2" height="32"> | 
			  <a href="findpass.jsp">密码忘了,找一下</a> | 
			  <a href="reg.jsp">注册新用户</a> |
              <input type="submit" name="login" value="GO!">
            </td>
          </tr>
		  </form>
						<tr> 
			  <td colspan="2" align="right">&nbsp;</td>

			</tr>
	   
        </table>                  
        </td>
    </tr>
  </table>
<%@ include file="footer.inc"%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -