jsp—MySql制作B/s登陆的好例子 学习笔记
建立条件首先一定要确定自己的mysql,tomcat,eclipse连接是正确的。
index.jsp很简单,就一个跳转。
<%
response.sendRedirect("lg.jsp");
%>
lg.jsp 实现登录框架
<%@ page contentType="text/html; charset=utf-8" %>
<html>
<head>
<title>
login
</title>
</head>
<center>
Prease input UserName and Pssword!!
</center>
<body bgcolor="#ffffff">
<%String flag=request.getParameter("flag");
if(flag!=null&&flag.equals("0")){
out.println("Pls input valid username and password!<br><br>");
}
%>
<form name="form1" method="post" action="login.jsp">
<center>
<input name="UserName" type="text" ><br/>
<input name="Password" type="password"><br/>
<input name="submit" type="submit" value="submit">
<input name="reset" type="reset" value="reset">
</center>
</form>
</body>
</html>
login.jsp 文件
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<head>
<title>用户登陆</title>
</head>
<body>
<%
String UserName=request.getParameter("UserName");
String Password=request.getParameter("Password");
ResultSet rs=null;
Statement stmt=null;
Connection con=null;
boolean flag=false;
try{
//驱动程序名
String driverName="com.mysql.jdbc.Driver";
//数据库用户名
String userName="test";
//密码
String userPasswd="123456";
//数据库名
String dbName="along";
//表名
String tableName="user";
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
Class.forName("com.mysql.jdbc.Driver").newInstance();
con=DriverManager.getConnection(url);
stmt = con.createStatement();
String sql="select * from user where UserName='"+UserName+"' and Password='"+Password+"'";
System.out.println("login: "+sql);
rs = stmt.executeQuery(sql);
//System.out.printl
相关文档:
JSP新闻发布系统android行动网
此网站的演示地址为:http://www.androidgo.cn
测试网址: http://ja00028.j01.netjsp.com
下载地址::http://download.csdn.net/source/1653791
技术实现:采用JSTL标签,基于servlet,jdbc开发。使用mysql数据库。
设计优势:一切技术使用最底层的,没有使用ssh框架,可以在任何国内的js ......
'-------------------------------------------------------------------以下是登录代码
<%@ page contentType="text/html; charset=gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3 ......
运行自己配置的web应用,往往只能看见weblogic编译之后的class文件。而看不见编译前的java的文件。为了调试方便,我们有时候是想看编译前的java文件。
在weblogic.xml中加入
<jsp-descriptor>
<jsp-param>
<param-name>keepgenerated</param-name>
<param-value>true</par ......
<body style="height:100%;">
-------------------------------------------------------------------一开始的页面----------------------
fdasfsdfadf
<input name="button2" onclick="ShopConfirm('fdsaf')" value="点我" type="button"/>
--------------------------------------------------------- ......
在开发中验证码是比较常用到有效防止这种问题对某一个特定注册用户用特定程序破解方式进行不断的登陆尝试的方式。
此演示程序包括三个文件:
1.login.jsp:登录页面
2.code.jsp:生成验证码图片页面
3.check.jsp:验证结果
code.jsp
程序代码 ==================================================
<%@ page co ......