<%@ page import="java.sql.Connection"%> <%@ page import="java.sql.DriverManager"%> <%@ page import="java.sql.Statement"%> <%@ page import="java.sql.ResultSet"%> <%@ page import="java.sql.ResultSetMetaData"%> <% String drv = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/demo"; String usr = "nari"; String pwd = "nari"; %>
<html> <body> welcome<br> </body> </html>
<%@ include file="inc.jsp" %>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
if(username == null || password == null){
response.sendRedirect("index.jsp");
}
boolean isValid = false;
String sql = "select * from user where username='"+username+"'and password='"+password+"'";
out.println("===>"+sql);
try{
Class.forName(drv).newInstance();
Connection conn = DriverManager.getConnection(url, usr,pwd);
Statement stm = conn.createStatement();
ResultSet rs = stm.executeQuery(sql);
if(rs.next())isValid = true;
rs.close();
stm.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
out.println(e);
}
if(isValid){
response.sendRedirect("welcome.jsp");
}else response.sendRedirect("index.jsp");
%>
<% /*
if(username.endsWith("a"))response.sendRedirect("welcome.jsp");
else response.sendRedirect("index.jsp");
*/%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<html>
<head>
<base href="<%=basePath %>"/>
<title>My JSP 'login.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="description" content="This is my page">
</head>
<body>
miThis is my JSP page.<br>
</body>
</html>
<form name="form1" action="login_action.jsp" method="post">
<table width="200" border="1">
<tr>
<td colspan="2">登录窗口</td>
</tr>
<tr>
<td>用户名</td>
<td><input type="text" name="username" size="10"/></td>
</tr>
<tr>
<td>密码</td>
<td><input type ="password" name="password" size="10"/></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="submit" value="登录">
<a href="register.jsp">注册新用户</a></td>
</tr>
</table>
</form>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有