Blue
Red
Green
Orange
Voilet
Slate
Dark

散分,给个简单的Login画面,包含,JSP/Servlet/Bean, (200分)

L

lvxq

Unregistered / Unconfirmed
GUEST, unregistred user!
立马给分,本日有效
 
L

lvxq

Unregistered / Unconfirmed
GUEST, unregistred user!
xuyao 分的赶快跟啊,部队没关系
 
L

leozmy

Unregistered / Unconfirmed
GUEST, unregistred user!
sun的petstore中就有了
 
S

snjat

Unregistered / Unconfirmed
GUEST, unregistred user!
你要的是例子吧,每个JSP服务器都会有啊,自己看吧
 
O

only you

Unregistered / Unconfirmed
GUEST, unregistred user!
[red]下面的代码为登录页面,文件名为login.jsp[/red]
<%@page contentType="text/html;
charset=gb2312" language="java" import="java.sql.*"%>
<%@ include file="Connections/TradeMark.jsp" %>
<%--本页面为用户验证页面--%>
<jsp:useBean id="JDbconn1" class="JDbconn"/>
<%
String Recordset1__MMColParam1 = "wd";
String Recordset1__MMColParam2 = "ilytdx";
if (request.getParameter("UserName") !=null) {Recordset1__MMColParam1 = (String)request.getParameter("UserName");}
if (request.getParameter("Password") !=null) {Recordset1__MMColParam2 = (String)request.getParameter("Password");}
%>
<%
if (request.getParameter("Register") !=null)
{
//转向注册页
response.sendRedirect(response.encodeRedirectURL("register.jsp"));
}
if (request.getParameter("MM_Login") !=null)
{
//Driver DriverRecordset1 = (Driver)Class.forName(MM_TradeMark_DRIVER).newInstance();
Connection ConnRecordset1 = JDbconn1.getConnection(MM_TradeMark_DRIVER,MM_TradeMark_STRING,MM_TradeMark_USERNAME,MM_TradeMark_PASSWORD);
PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM register WHERE User='" + Recordset1__MMColParam1 + "' and PassWord='"+Recordset1__MMColParam2+"'");
ResultSet Recordset1 = StatementRecordset1.executeQuery();
boolean Recordset1_isEmpty = !Recordset1.next();
boolean Recordset1_hasData = !Recordset1_isEmpty;
Object Recordset1_data;
int Recordset1_numRows = 0;
if(!Recordset1_isEmpty)
{
session.putValue("UserName",Recordset1__MMColParam1);
response.sendRedirect(response.encodeRedirectURL("index.jsp"));
}
else
{
response.sendRedirect(response.encodeRedirectURL("NoneUser.html"));
Recordset1.close();
ConnRecordset1.close();
}
}
%>
<html>
<head>
<title>Untitleddo
cument</title>
<META http-equiv=Content-Type content="text/html;
charset=gb2312">
<STYLE type=text/css>.Titl {
FONT-WEIGHT: bold;
FONT-SIZE: 24pt;
COLOR: #ff9900;
FONT-FAMILY: "楷体_GB2312";
TEXT-DECORATION: none
}
.text {
FONT-SIZE: 95%;
COLOR: #cc0000;
FONT-FAMILY: "宋体";
TEXT-DECORATION: none
}
</STYLE>
</head>
<BODY bgColor=#ffffff leftMargin=0 background=db.gif topMargin=0
onload="MM_preloadImages('image/end_r2_c2_f2.gif')" marginheight="0"
marginwidth="0">
<form method="post" action="" name="form1">
<table align="center">
<TR vAlign=top>
<TD colSpan=5 height=81>
<DIV align=center><IMG height=88 src="banner.jpg"
width=791></DIV></TD></TR>
<TR>
<TD colSpan=5 height=55>
<DIV align=center><FONT class=Titl face=楷体_GB2312 size=5>用户登录</FONT>
</DIV></TD></TR>
<TR>
<TD colSpan=5 height=184>
<DIV class=text align=center>
<TABLE class=text height=215 width=1>
<TBODY>
<TR>
<TD height="39" width="114">
<DIV align=right>用户名:</DIV></TD>
<TD height="39" width="274"><INPUT value="" name=UserName> </TD></TR>
<TR>
<TD height="35" width="114">
<DIV align=right>密&amp;nbsp;&amp;nbsp;码:</DIV></TD>
<TD height="35" width="274"><INPUT value="" name=PassWord type="password"> </TD></TR>
<TR>
<TD colSpan=2 height="75" width="394">
<DIV align=center style="width: 354;
height: 57">
<P><INPUT type=submit value="登 录" name=MM_Login>&amp;nbsp;&amp;nbsp;&amp;nbsp;<input type="submit" value="注 册" name="Register"></P>
 
</DIV>
</TD>
</TR>
<TR>
<TD colSpan=2 height="50" width="394">
<DIV align=center>
<P><SPAN class=text>
<FONT color=#ff3333>请注意您的用户名和密码大小写是否正确</FONT></SPAN><FONT
color=#ff3333>。</FONT></P>
</DIV></TD></TR>
</TBODY></TABLE>
<P>&amp;nbsp;</P>
<P>&amp;nbsp;</P></DIV></TD></TR>
<TR vAlign=center>
<TD colSpan=5 height=68>
<DIV align=center>
</table>
<input type="hidden" name="MM_Login" value="true">
</form>
<p>&amp;nbsp;</p>
<TABLE align=center border=0>
<TBODY>
<TR>
<TH width=791><A href="http://www.beijinghouse.com/wdgf/index.htm"
target=_top><FONT size=2>返回商标注册主页</FONT></A></TH></TR>
<TR>
<TH width=791><IMG height=60 src="banner.gif" width=468></TH></TR>
<TR>
<TH width=791>
<DIV align=left><!-- Image with table -->
<TABLE cellSpacing=0 cellPadding=0 width=791 border=0><!-- fwtable fwsrc="未命名" fwbase="end.
gif" -->
<TBODY>
<TR><!-- Shim row, height 1. -->
<TD><IMG height=1 src="shim.gif" width=624 border=0></TD>
<TD><IMG height=1 src="shim.gif" width=158 border=0></TD>
<TD><IMG height=1 src="shim.gif" width=9 border=0></TD>
<TD><IMG height=1 src="shim.gif" width=1 border=0></TD></TR>
<TR vAlign=top><!-- row 1 -->
<TD colSpan=3><IMG height=2 src="end_r1_c1.gif"
width=791 border=0 name=end_r1_c1></TD>
<TD><IMG height=2 src="shim.gif" width=1 border=0></TD></TR>
<TR vAlign=top><!-- row 2 -->
<TD rowSpan=2><IMG height=13 src="end_r2_c1.gif"
width=624 border=0 name=end_r2_c1></TD>
<TD><A
onmouseover="MM_swapImage('end_r2_c2','','image/end_r2_c2_f2.gif',1);"
onmouseout=MM_swapImgRestore()
href="mailto:jgfn@public.bta.net.cn"><IMG height=10
src="end_r2_c2.gif" width=158 border=0
name=end_r2_c2></A></TD>
<TD rowSpan=2><IMG height=13 src="end_r2_c3.gif" width=9
border=0 name=end_r2_c3></TD>
<TD><IMG height=10 src="shim.gif" width=1
border=0></TD></TR>
<TR vAlign=top><!-- row 3 -->
<TD><IMG height=3 src="end_r3_c2.gif" width=158 border=0
name=end_r3_c2></TD>
<TD><IMG height=3 src="shim.gif" width=1 border=0></TD></TR><!-- This table was automatically created with Macromedia Fireworks 3.0 --><!-- http://www.macromedia.com --></TBODY></TABLE>
</body>
[red]以下代码定义一些常用变量 文件名为trademark.jsp,目录放在login.jsp目录下Connections子目录中[/red]
<%
// FileName="sun_jdbc_odbc_conn.htm"
// Type="JDBC"
// HTTP="false"
// Catalog=""
// Schema=""
//本文件为定义本网站的结构和变量
String MM_TradeMark_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
String MM_TradeMark_USERNAME = "";
String MM_TradeMark_PASSWORD = "";
String MM_TradeMark_STRING = "jdbc:eek:dbc:TradeMark";
%>

[red] 以下代码为数据库连接代码,文件名JDbconn .java [/red]
import java.sql.*;
public class JDbconn {

public static Connection getConnection(String className, String url, String userName, String password) {
try {
Class.forName(className);
return DriverManager.getConnection(url, userName, password);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static Connection getOracleConnection(String driverName, String machine, String orcl, String port, String userName, String password) {
String url = "jdbc:eek:racle:thin:mad:" + machine + ":" + port + ":" + orcl;
return getConnection(driverName, url ,userName, password);
}
public static Connection getSpecialOracleConnection() {
return getOracleConnection("jdbc.oracle.driver.OracleDriver", "127.0.0.1", "ORCL", "1521", "system", "manager");
}
}
 
L

lvxq

Unregistered / Unconfirmed
GUEST, unregistred user!
我不是要例子,我是要人来回答,好发分结束这个帖子。
我自己写的jsp得项目一共4个,老熟了
 

Similar threads

回复
0
查看
684
不得闲
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部 底部