Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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ÐÂÎÅ·¢²¼ÏµÍ³Ô´Âë androidgo.cn

JSPÐÂÎÅ·¢²¼ÏµÍ³androidÐж¯Íø
´ËÍøÕ¾µÄÑÝʾµØַΪ:http://www.androidgo.cn
²âÊÔÍøÖ·: http://ja00028.j01.netjsp.com
ÏÂÔصØÖ·::http://download.csdn.net/source/1653791
¼¼ÊõʵÏÖ:²ÉÓÃJSTL±êÇ©,»ùÓÚservlet,jdbc¿ª·¢¡£Ê¹ÓÃmysqlÊý¾Ý¿â¡£
Éè¼ÆÓÅÊÆ:Ò»Çм¼ÊõʹÓÃ×îµ×²ãµÄ£¬Ã»ÓÐʹÓÃssh¿ò¼Ü£¬¿ÉÒÔÔÚÈκιúÄÚµÄjs ......

ÈçºÎÏòÒ»¸öjsp´«µÝÁ½¸öÒÔÉϵIJÎÊý

ÓÐÁ½ÖÖ´«²Î·½Ê½
Ò»¡¢get·½Ê½£º
        ÕâÖÖ·½Ê½½«²ÎÊýдÔÚurlÖУ¬¾ÙÀýÀ´Ëµ£¬Èç¹ûÄ¿±ê´«²ÎÒ³ÃæÊÇtarget.jsp,ÄÇôÔÚurlÀï¿ÉÒÔÕâôд£º
        http://..../target.jsp? <Param1> = <value1> & <Param2> = <value2> &...
    &n ......

JSP¶ÁÎļþ´úÂë

<%@ page contentType="text/html; charset=gbk" language="java" import="java.io.*" buffer="64kb" %>
      <%
 
   String path_in = "";
   String content = "";
 
   path_in = request.getRealPath("/")+"admin"+File.separator+ ......

jspÉÏ´«×é¼þʹÓúͽéÉÜ

jspʹÓÃ×é¼þ½øÐÐÎļþÉÏ´«
WEBÎļþÉÏ´«¿ÉÄÜÊÇÍøÕ¾½¨ÉèÖÐ×î³£ÓõŦÄÜÖ®Ò»£¬ÎÒÔÚÏîÄ¿¿ª·¢Öм¸ºõ¶¼ÐèҪʵÏÖÎļþÉÏ´«¹¦ÄÜ£®Ç°¶Îʱ¼ä×Ô¼ºËѼ¯ÁËһЩÉÏ´«×é¼þ£®ÕâƪÎÄÕÂÖн«½éÉÜÕâЩ×é¼þµÄʹÓ÷½·¨£¬²¢ÇұȽϸ÷×ÔµÄÓÅÁÓ£®
Ò»£¬smartupload×é¼þ£®
ÎÒÏëÖ»Òª×ö¸öÎļþÉÏ´«µÄÅóÓѶ¼ÖªµÀÕâ¸ö×é¼þ£¬ÎÒÈÏʶµÄÈËÖÐʹÓÃ×î¶àµÄÒ²ÊÇËü£¡ÎÒ¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ