自学记录(4.14)

学习时间:6h

  代码量:约600行

  今天web课进行了对session和cookie的学习,以下是我的作品:

<%@ page language= "java" contentType= "text/html; charset=UTF-8"
         pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>金属乐新人推荐</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
/*设置超链接样式*/
table {
	border-collapse: collapse;
	border-spacing: 0;
}

a {
	color: #5086a5;
	text-decoration: none;
	font-size: 12px;
}

a:hover {
	color: #5086a5;
	text-decoration: underline;
	font-size: 12px;
}

a:visited {
	color: #5086a5;
	font-size: 12px;
}
/*整个tab层居中,宽度为600px*/
#tabDiv {
	width: 600px;
	margin: 1em auto;
	padding-bottom: 10px;
	border-right: #b2c9d3 1px solid;
	border-top: #b2c9d3 1px solid;
	border-left: #b2c9d3 1px solid;
	border-bottom: #b2c9d3 1px solid;
	background: #ffffff;
}
/*tab头的样式*/
#tabsHead {
	padding-left: 0px;
	height: 26px;
	background-color: #e8f7fc;
	font-size: 1em;
	margin: 1px 0px 0px;
	color: #5086a5;
	line-height: 26px;
}
/*已选tab头(超链接)的样式*/
.curtab {
	padding-top: 0px;
	padding-right: 10px;
	padding-bottom: 0px;
	padding-left: 10px;
	border-right: #b2c9d3 1px solid;
	font-weight: bold;
	float: left;
	cursor: pointer;
	background: #ffffff;
}
/*未选tab头(超链接)的样式*/
.tabs {
	border-right: #c1d8e0 1px solid;
	padding-top: 0px;
	padding-right: 10px;
	padding-bottom: 0px;
	padding-left: 10px;
	font-weight: normal;
	float: left;
	cursor: pointer;
}
p {
	font-size: 12pt;
	text-indent: 2em;
}
li {
  	border-bottom-style: solid;
  	border-bottom-color: #EEE;
  	border-bottom-width: thin;
  	height: 25px;
	font-family: "宋体";
	font-size: 12pt;
}
</style>
<script type="text/jscript">	
        //显示tab(tabHeadId:tab头中当前的超链接;tabContentId要显示的层ID)
        function showTab(tabHeadId,tabContentId) 
        {
            //tab层
            var tabDiv = document.getElementById("tabDiv");
            //将tab层中所有的内容层设为不可见
            //遍历tab层下的所有子节点
            var taContents = tabDiv.childNodes;
            for(i=0; i<taContents.length; i++) 
            {
                //将所有内容层都设为不可见
                if(taContents[i].id!=null && taContents[i].id != 'tabsHead')
                {
                    taContents[i].style.display = 'none';
                }
            }
            //将要显示的层设为可见
            document.getElementById(tabContentId).style.display = 'block';          
            //遍历tab头中所有的超链接
            var tabHeads = document.getElementById('tabsHead').getElementsByTagName('a');
            for(i=0; i<tabHeads.length; i++) 
            { 
                //将超链接的样式设为未选的tab头样式
                tabHeads[i].className='tabs'; 
            }
            //将当前超链接的样式设为已选tab头样式
            document.getElementById(tabHeadId).className='curtab';
            document.getElementById(tabHeadId).blur();
        }
</script>
</head>
<%
String name="游客";
Cookie[] cookies =request.getCookies();
if(cookies!=null)
{
for(Cookie cookie : cookies)
{
	if(!cookie.getName().equals("JESSIONID"))
	{
	name=cookie.getValue();
	session.setAttribute("ID",name);
	}
}
}
%>
<body>
	<div style="width: 100%; font-family: 微软雅黑; text-align: center; font-size: 20pt;">金属乐入门推荐</div>
     <center><marquee width="500px" height="100px" behavior="alternate"style="border: 2px solid white">
     
            <marquee behavior="alternate" style="color: blue">
                欢迎<%=name%>进入本网页。 
                </marquee>
        </marquee>
        </center>
       <%if(session.getAttribute("ID")==null)
		{
    	 %>
		<center><input type="submit" name="登录" value="登录" onclick="location.href='Denglu.jsp'"></center>
		<%
		}
		%>
		<%if(session.getAttribute("ID")!=null)
		{
    	 %>
		<center><input type="submit" name="重新登录" value="重新登录" onclick="location.href='Denglu.jsp'"></center>
		<%
		}
		%>
	<div id="tabDiv" style="width: 1000px">
	
		<div id="tabsHead">
			<a id="tabs1" class="curtab" href="javascript:showTab('tabs1','tabContent1')">早期版本</a> <a id="tabs2" class="tabs" href="javascript:showTab('tabs2','tabContent2')">激流金属</a><a id="tabs3" class="tabs" href="javascript:showTab('tabs3','tabContent3')">其他金属形式</a>
		</div>
		<div id="tabContent1" style="display: block">
			<table style="border-width: 0; width: 100%">
				<tr>
					<td rowspan="3" style="width: 300px; text-align: center"><img alt="金属" src="img/metal.jpg" style="width: 280px" /></td>
					<td colspan="3" rowspan="3">
						<table border="1" style="border-left-color: aqua; border-bottom-color: aqua; width: 701px; border-top-style: solid; border-top-color: aqua; border-right-style: solid; border-left-style: solid; height: 380px; border-right-color: aqua; border-bottom-style: solid">
							<tr>
								<td>金属乐(Metal)是一种音乐形式,以重金属为主,包括黑金属,死亡金属,激流金属,新金属,厄运金属,华丽金属,重金属,工业金属等重型音乐。</td>
							</tr>
							<tr>
								<td>推荐乐队</td>
							</tr>
							<tr>
								<td align="center"><a href="Black_Sabbath.jsp">Black Sabbath</a></td>
							</tr>
							<tr>
								<td align="center"><a href="Led_Zeppelin.jsp">Led Zeppelin</a></td>
							</tr>
							<tr>
								<td align="center"><a href="Deep_Purple.jsp">Deep Purple</a></td>
							</tr>
							<tr>
								<td align="center"><a href="Rainbow.jsp">Rainbow</a></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<div id="tabContent2" style="display: none">
			<table style="border-width: 0; width: 100%">
				<tr>
					<td rowspan="3" style="width: 300px; text-align: center"><img alt="激流" src="img/jiliu.jpg" style="width: 280px" /></td>
					<td colspan="3" rowspan="3">
						<table border="1" style="border-left-color: aqua; border-bottom-color: aqua; width: 701px; border-top-style: solid; border-top-color: aqua; border-right-style: solid; border-left-style: solid; height: 380px; border-right-color: aqua; border-bottom-style: solid">
							<tr>
								<td style="width: 100%">鞭鞑金属(Thrash Metal,或称激流金属)本质上就是80年代的地下重金属(Heavy Metal)乐,它主要使用一种用于节奏吉他的推进性的敲击方法(多亏了手掌闷音这一技巧的产生及运用),具有很强的攻击性。鞭鞑金属通常具有吉他技术娴熟、节奏快而狠的特点,有时还会用无调的吉他连复段代替旋律。但是以上这些概括远不是绝对的标准。</td>
							</tr>
							<tr>
								<td>推荐乐队</td>
							</tr>
							<tr>
								<td align="center"><a href="Metallica.jsp">Metallica</a></td>
							</tr>
							<tr>
								<td align="center"><a href="Megadeth.jsp">Megadeth</a></td>
							</tr>
							<tr>
								<td align="center"><a href="Slayer.jsp">Slayer</a></td>
							</tr>
							<tr>
								<td align="center"><a href="Anthrax.jsp">Anthrax</a></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
		<!--以下为乐器部分内容-->
		
		<div id="tabContent3" style="display: none">
		<table style="border-width: 0; width: 100%">
				<tr>
					<td rowspan="3" style="width: 300px; text-align: center"><img alt="郭永辉" src="img/metal1.jpg" style="width: 270px"  /></td>
					<td colspan="3" rowspan="3">
						<table border="1" style="border-left-color: aqua; border-bottom-color: aqua; width: 701px; border-top-style: solid; border-top-color: aqua; border-right-style: solid; border-left-style: solid; height: 380px; border-right-color: aqua; border-bottom-style: solid">
							<tr>
								<td>工业金属是采用大量冰冷的电脑采样音效,穿插以机械或金属器具的撞击声代替传统打击乐器,加上电子式的节拍,是很像科技舞曲的重金属乐,但仍保留重金属的大量失真效果。</td>
							</tr>
							<tr>
								<td align="center"><a href="Marilyn_Manson.jsp">Marilyn Manson</a></td>
							</tr>
							<tr>
								<td>哥特金属 Goth Metal(港台地区则译作哥德金属)是一种揉合了重金属音乐及哥特风格音乐的混合物。它的发源时间始于九十年代初的欧美。</td>
							</tr>
							<tr>
								<td align="center"><a href="Nightwish.jsp">Nightwish</a></td>
							</tr>
							<tr>
								<td>新金属一般是主唱以说唱形式展现,配乐为重金属形式,使其节奏感加强,有强烈的RIFF。新金属与其他金属的最大的特点是主音吉他在乐曲中基本没有SOLO,SOLO的段落多被华丽的RAP或打碟和偶尔鼓手在曲中快节奏的变奏所代替。</td>
							</tr>
							<tr>
								<td align="center"><a href="Slipknot.jsp">Slipknot</a></td>
							</tr>
						</table>
					</td>
				</tr>
		</div>
	</div>
	<hr />
	<div style="text-align: center; width: 100%; font-size: 12px; color: #333;">©版权所有:石家庄铁道大学信息科学与技术学院</div>
</body>
</html>

  

<%@ page language= "java" contentType= "text/html; charset=UTF-8"
         pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>登录</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
/*设置超链接样式*/
table {
	border-collapse: collapse;
	border-spacing: 0;
}

a {
	color: #5086a5;
	text-decoration: none;
	font-size: 12px;
}

a:hover {
	color: #5086a5;
	text-decoration: underline;
	font-size: 12px;
}

a:visited {
	color: #5086a5;
	font-size: 12px;
}
/*整个tab层居中,宽度为600px*/
#tabDiv {
	width: 600px;
	margin: 1em auto;
	padding-bottom: 10px;
	border-right: #b2c9d3 1px solid;
	border-top: #b2c9d3 1px solid;
	border-left: #b2c9d3 1px solid;
	border-bottom: #b2c9d3 1px solid;
	background: #ffffff;
}
/*tab头的样式*/
#tabsHead {
	padding-left: 0px;
	height: 26px;
	background-color: #e8f7fc;
	font-size: 1em;
	margin: 1px 0px 0px;
	color: #5086a5;
	line-height: 26px;
}
/*已选tab头(超链接)的样式*/
.curtab {
	padding-top: 0px;
	padding-right: 10px;
	padding-bottom: 0px;
	padding-left: 10px;
	border-right: #b2c9d3 1px solid;
	font-weight: bold;
	float: left;
	cursor: pointer;
	background: #ffffff;
}
/*未选tab头(超链接)的样式*/
.tabs {
	border-right: #c1d8e0 1px solid;
	padding-top: 0px;
	padding-right: 10px;
	padding-bottom: 0px;
	padding-left: 10px;
	font-weight: normal;
	float: left;
	cursor: pointer;
}
p {
	font-size: 12pt;
	text-indent: 2em;
}
li {
  	border-bottom-style: solid;
  	border-bottom-color: #EEE;
  	border-bottom-width: thin;
  	height: 25px;
	font-family: "宋体";
	font-size: 12pt;
}
</style>
</head>
<form action="Denglu_back.jsp" method="get">
<body>
	<div style="width: 100%; font-family: 微软雅黑; text-align: center; font-size: 20pt;">登录</div>
	<div id="tabDiv" style="width: 1000px">
		<div id="tabContent1" style="display: block">
        <center>I D<input type="text" name="ID" ></center>
        <br>
        <center>密码<input type="password" name="password" ></center>
        <br>
        <center><input type="submit" value="登录" ></center>
        </div>
		</div>
	<hr />
	<div style="text-align: center; width: 100%; font-size: 12px; color: #333;">©版权所有:石家庄铁道大学信息科学与技术学院</div>
</body>
</html>

  

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<%
	

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

    session.setAttribute("ID",ID);
    
    Cookie cookie=new Cookie("Aoc",ID);
	cookie.setMaxAge(60*5);
	response.addCookie(cookie);

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

    session.setAttribute("password",password);
    
    if(ID==""||password=="")
    {
        out.print("<script language='javaScript'> alert('用户ID或密码输入为空'); window.history.back(); </script>");
    }
    else
    {
                if(ID.equals(password))
                {
                    out.print("<script language='javaScript'> alert('登录成功');</script>");
                    response.setHeader("refresh", "0;url=Menu.jsp");
                }
                else
                {
                    out.print("<script language='javaScript'> alert('用户ID和密码不匹配'); window.history.back(); </script>");
                }
    }
%>
</table>
</body>
</html>

  

<%@ page language= "java" contentType= "text/html; charset=UTF-8"
         pageEncoding= "UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Black Sabbath</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
/*设置超链接样式*/
table {
	border-collapse: collapse;
	border-spacing: 0;
}

a {
	color: #5086a5;
	text-decoration: none;
	font-size: 12px;
}

a:hover {
	color: #5086a5;
	text-decoration: underline;
	font-size: 12px;
}

a:visited {
	color: #5086a5;
	font-size: 12px;
}
/*整个tab层居中,宽度为600px*/
#tabDiv {
	width: 600px;
	margin: 1em auto;
	padding-bottom: 10px;
	border-right: #b2c9d3 1px solid;
	border-top: #b2c9d3 1px solid;
	border-left: #b2c9d3 1px solid;
	border-bottom: #b2c9d3 1px solid;
	background: #ffffff;
}
/*tab头的样式*/
#tabsHead {
	padding-left: 0px;
	height: 26px;
	background-color: #e8f7fc;
	font-size: 1em;
	margin: 1px 0px 0px;
	color: #5086a5;
	line-height: 26px;
}
/*已选tab头(超链接)的样式*/
.curtab {
	padding-top: 0px;
	padding-right: 10px;
	padding-bottom: 0px;
	padding-left: 10px;
	border-right: #b2c9d3 1px solid;
	font-weight: bold;
	float: left;
	cursor: pointer;
	background: #ffffff;
}
/*未选tab头(超链接)的样式*/
.tabs {
	border-right: #c1d8e0 1px solid;
	padding-top: 0px;
	padding-right: 10px;
	padding-bottom: 0px;
	padding-left: 10px;
	font-weight: normal;
	float: left;
	cursor: pointer;
}
p {
	font-size: 12pt;
	text-indent: 2em;
}
li {
  	border-bottom-style: solid;
  	border-bottom-color: #EEE;
  	border-bottom-width: thin;
  	height: 25px;
	font-family: "宋体";
	font-size: 12pt;
}
</style>

<script type="text/jscript">	
        //显示tab(tabHeadId:tab头中当前的超链接;tabContentId要显示的层ID)
        function showTab(tabHeadId,tabContentId) 
        {
            //tab层
            var tabDiv = document.getElementById("tabDiv");
            //将tab层中所有的内容层设为不可见
            //遍历tab层下的所有子节点
            var taContents = tabDiv.childNodes;
            for(i=0; i<taContents.length; i++) 
            {
                //将所有内容层都设为不可见
                if(taContents[i].id!=null && taContents[i].id != 'tabsHead')
                {
                    taContents[i].style.display = 'none';
                }
            }
            //将要显示的层设为可见
            document.getElementById(tabContentId).style.display = 'block';          
            //遍历tab头中所有的超链接
            var tabHeads = document.getElementById('tabsHead').getElementsByTagName('a');
            for(i=0; i<tabHeads.length; i++) 
            { 
                //将超链接的样式设为未选的tab头样式
                tabHeads[i].className='tabs'; 
            }
            //将当前超链接的样式设为已选tab头样式
            document.getElementById(tabHeadId).className='curtab';
            document.getElementById(tabHeadId).blur();
        }
</script>
</head>
<%
	if(session.getAttribute("ID")==null)
	{
		response.sendRedirect("Denglu.jsp");
	} 
%>
<body>
	<div style="width: 100%; font-family: 微软雅黑; text-align: center; font-size: 20pt;">Black Sabbath</div>
     <center><marquee width="500px" height="100px" behavior="alternate"style="border: 2px solid white">
     
            <marquee behavior="alternate" style="color: blue">
                欢迎<%=session.getAttribute("ID") %>进入本网页。 
                </marquee>
        </marquee>
        </center>
     <%if(session.getAttribute("ID")==null)
     {
    	 %>
	<center><input type="submit" name="登录" value="登录" onclick="location.href='Denglu.jsp'"></center>
	<%
	}
		%>
	<div id="tabDiv" style="width: 1000px">
	
		<div id="tabsHead">
			<a id="tabs1" class="curtab" href="javascript:showTab('tabs1','tabContent1')">乐队介绍</a>
		</div>
		<div id="tabContent1" style="display: block">
			<table style="border-width: 0; width: 100%">
				<tr>
					<td rowspan="3" style="width: 300px; text-align: center"><img alt="Black Sabbath" src="img/Black_Sabbath.jpg" style="width: 280px" /></td>
					<td colspan="3" rowspan="3">
						<table border="1" style="border-left-color: aqua; border-bottom-color: aqua; width: 701px; border-top-style: solid; border-top-color: aqua; border-right-style: solid; border-left-style: solid; height: 380px; border-right-color: aqua; border-bottom-style: solid">
							<tr>
								<td>诞生于1969年伯明翰的乐队是由贝司手GEEZER BUTLER,吉他手TONY IOMMI,鼓手BILL WARD,歌手Ozzy Osbourne组成。1969年乐队把原名“Earth”改成了“BLACK SABBATH”他们以使用纯正音色,极度简化的音乐和魔术般的联想著称。1970年推出了第一张同名专辑《BLACK SABBATH》。他们的第二张专辑《PARANOID》中的同名专辑也取得了一次瞬间的轰动。在八十年代BLACK SABBATH的人员一直在处于不断的变化中,只有TONY IOMMI一人一直留在乐队中。2017年2月4日正式解散</td>
							</tr>
							<tr>
								<td>推荐乐曲</td>
							</tr>
							<tr>
								<td align="center">Iron Man</a></td>
							</tr>
							<tr>
								<td align="center">Black Sabbath</a></td>
							</tr>
							<tr>
								<td align="center">Paranoid</a></td>
							</tr>
							<tr>
								<td align="center">NIB</a></td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<hr />
	<div style="text-align: center; width: 100%; font-size: 12px; color: #333;">©版权所有:石家庄铁道大学信息科学与技术学院</div>
</body>
</html>

  

 

posted @ 2023-04-14 21:50  霍普金斯大学丁真  阅读(14)  评论(0)    收藏  举报