web 第二次实验
一个介绍东西的简单网页
项目目录如下:
代码如下:
1) index.css文件代码
a:link{
color: #000000;
text-decoration: none;
font-size: 35px;
}
a:hover {
color: #5086a5;
text-decoration: underline;
font-size: 35px;
}
a:visited {
color: #000000;
font-size: 35px;
}
#zhu{
text-align:center;
padding: 15px;
}
#huazi{
margin:0 auto;
width:1000px;
height:35px;
}
.catalogue{
font-size:35px;
margin-top:10px;
text-align:left;
}
2) web.css文件代码
a:link{
color: #000000;
text-decoration: none;
font-size: 35px;
}
a:hover {
color: #5086a5;
text-decoration: underline;
font-size: 35px;
}
a:visited {
color: #000000;
font-size: 35px;
}
#shiwen{
margin:100px auto;
padding:50px;
width:1000px;
height:100%;
background:yellow;
}
#shiming{
font-size:30px;
color:red;
text-align:center;
}
.shiwen1{
font-weight:bold;
font-size:20px;
}
#zhushi{
color:#77FFFF;
font-size:35px;
font-weight:bold;
}
.zhushi_neirong{
font-weight:bold;
text-indent:2em
}
#fanyi{
color:#77FFFF;
font-size:35px;
font-weight:bold;
}
#return{
text-align:center;
}
3) Check.jsp文件代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>web实验二</title>
<style type="text/css">
</style>
</head>
<body background="images/R-C.jpg">
<%
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
String a="2";
Cookie nameCookie = new Cookie("name",name);
nameCookie.setMaxAge(60*10);
response.addCookie(nameCookie);
Cookie birthdayCookie = new Cookie("id",a);
birthdayCookie.setMaxAge(60*10);
response.addCookie(birthdayCookie);
String send=new String();
send+=name;
send+=" ";
send+="2";
if (name.equals(pwd)){%>
<span style="text-align: center;display:block;font-size:30px;margin-top:50px;" ><font color=red>登录成功,<br>5秒钟后转入主页面</font></span>
<%response.setHeader("refresh","5;URL=index.jsp?send="+send); %>
<%} %>
<%if (!name.equals(pwd)){%>
<span style="text-align: center;display:block;font-size:30px;margin-top:50px;"><font color=red>登录失败,<br>2秒钟后转入登录页面</font></span>
<%response.setHeader("refresh","2;URL='login.jsp'"); %>
<%} %>
</body>
</html>
4) Index.jsp文件代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>web实验二</title>
<link href="css/index.css" rel="stylesheet" type="text/css"/>
<script type="text/jscript">
function jump(adress,a){
if(adress=='web1'){
if (a=="1")
window.location.href='login.jsp';
if (a=="2")
window.location.href='web1.jsp';
}
if(adress=='web2'){
if (a=="1")
window.location.href='login.jsp';
if (a=="2")
window.location.href='web2.jsp';
}
if(adress=='web3'){
if (a=="1")
window.location.href='login.jsp';
if (a=="2")
window.location.href='web3.jsp';
}
}
</script>
</head>
<body background="images/R-C.jpg">
<%! String a="1";%>
<%! String b=""; %>
<%! String c="";%>
<%
String send="";
if(request.getParameter("send")!=null){
send=request.getParameter("send");
Cookie[] cook = request.getCookies();
if(cook !=null){
c=cook[0].getValue();
a=cook[1].getValue();
}
}
// for(int i=0;i < send.length();i++){
// if((i!= send.length()-2)&&(i!= send.length()-1))
// c+=send.charAt(i);
// if(i==send.length()-1)
// a="";
// a+=send.charAt(i);
// }
if(a.equals("1"))
{
b="游客";
}
if(a.equals("2")){
a="2";
b=c;
}
%>
<div id="huazi">
<marquee behavior="alternate" scrollamount=14>
<font face="隶书" color="#0066FF" size="5" ><%=b %>,欢迎访问本网站!</font>
</marquee>
</div>
<div id="zhu">
<p style="font-size:30px;color:orange"></p>
<br>
<br>
<div><a href="javascript:jump('web1',<%=a %>)" class="catalogue"> </a></div>
<div><a href="javascript:jump('web2',<%=a %>)" class="catalogue"></a></div>
<div><a href="javascript:jump('web3',<%=a %>)" class="catalogue"> </a></div>
<div><a href="login.jsp" class="catalogue">登录</a></div>
</div>
</body>
</html>
5) Login.jsp文件代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>web实验二</title>
<style>
#zhu{
text-align:center;
padding: 15px;
}
</style>
</head>
<body background="images/R-C.jpg">
<div id="zhu">
<p style="font-size:30px;color:orange">登录页面</p>
<br>
<br>
<form action="check.jsp" >
<p>用户名: <input type="text" name="name"/></p>
<p>密码: <input type="text" name="pwd"/></p>
<p><input type="submit" value="登录"></p>
</form>
</div>
</body>
</html>
6) Web.jsp文件代码
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link href="css/web.css" rel="stylesheet" type="text/css"/>
</head>
<body background="images/R-C.jpg">
<div id="shiwen">
<p id="shiming"></p>
<p class="shiwen1"></p>
<p class="shiwen1"></p>
<p id="zhushi">注释</p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p class="zhushi_neirong"></p>
<p id="fanyi">翻译</p>
<p class="zhushi_neirong">大江之水滚滚不断向东流去,淘尽了那些千古风流的人物。在那久远古战场的西边地方,说是三国周瑜破曹军的赤壁。四面石乱山高两岸悬崖如云,惊涛骇浪猛烈地拍打着对岸,卷起浪花仿佛冬日的千堆雪。江山如此的美丽如图又如画,一时间涌出了多少英雄豪杰。</p>
<p class="zhushi_neirong">遥想当年的周郎名瑜字公瑾,小乔刚刚嫁给了他作为妻子,英姿雄健风度翩翩神采照人。手中执着羽扇头上著着纶巾,从容潇洒地在说笑闲谈之间,八十万曹军如灰飞烟灭一样。如今我身临古战场神游往昔,可笑我有如此多的怀古柔情,竟如同未老先衰般鬓发斑白。人生如同一场朦胧的梦似的,举起酒杯奠祭这万古的明月。</p>
</div>
<div id="return">
<a href="index.jsp"> 返回主页</a>
</div>
</body>
</html>
以上皆为模板
具体内容需要自己填写。