本文主要是介绍第二次网信实验,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
第二次网信实验
先写个页面跳转
然后跳到主界面
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<html>
<head><title> mypage </title>
</head>
<body><%@ include file="index.jsp"%><h1>Welcome to Paris Saint-Germain F.C.!</h1><h3>Here are three forward members</h3><p>Click on pictures to learn more!</p><!--注释是这样写的 --><!-- 前面是一些基础文字设置--><a target="_blank" href="https://baike.baidu.com/item/%E5%86%85%E9%A9%AC%E5%B0%94%C2%B7%E8%BE%BE%E5%B8%AD%E5%B0%94%E7%93%A6/4460782?fromtitle=%E5%86%85%E9%A9%AC%E5%B0%94&fromid=3431139&fr=aladdin/"><img src="jp/Neymar.jpg" alt="Neymar" width="237" height="332"/></a><a target="_blank" href="https://baike.baidu.com/item/%E5%9F%BA%E5%88%A9%E5%AE%89%C2%B7%E5%A7%86%E5%B7%B4%E4%BD%A9/19408535?fromtitle=%E5%A7%86%E5%B7%B4%E4%BD%A9&fromid=19416599&fr=aladdin/"><img src="jp/mbappe.jpg" alt="Mbappe" width="237" height="332"/></a><a target="_blank" href="https://baike.baidu.com/item/%E5%AE%89%E8%B5%AB%E5%B0%94%C2%B7%E8%BF%AA%E9%A9%AC%E5%88%A9%E4%BA%9A/2551279?fromtitle=%E8%BF%AA%E9%A9%AC%E5%88%A9%E4%BA%9A&fromid=5426107&fr=aladdin"><img src="jp/dimaria.jpg" alt="DiMaria" width="237" height="332"/></br></a><hr><!--三封图片,加下划线,下面弄个发邮件 --><h4>Contact to LPZ, the Website Maker</h4><a target="_blank" href="mailto:2018211094@bupt.edu.cn" alt="email address">send E-mail</a><hr><!--下面表单--><!--一组额外的标签 details 和 summary,把反馈界面单独列出来了--><form name="data" action="testresponse.jsp" method="post">Please leave your information~<br><br>username:<input type="text" name="user" /> <br/><br/>password:<input type="text" name="password" /><br/><br/>how's your experience<input type="text" name="experience" /> <br/><br/>phone:<input type="text" name="phone" /><br/><br/><input type="submit" value="end" /></form>now the time is:<%response.setHeader("refresh","100");out.println(new Date().toString());%><hr><a href="redmypage.html">Change to red!</a><br/>
<%Cookie temp = null;
int count=1;
String currenttime = new Date().toString();
String lasttime = null;
int lastcount=0;
Cookie[] cookies = request.getCookies();
if(cookies!=null){
for(int i=0;i<cookies.length;i++){
temp=cookies[i];
if (temp.getName().equals("accessCount")){
lastcount = Integer.parseInt(temp.getValue());%>
the time you came here until now is <%= lastcount %><br/><% count=lastcount+1;
temp.setValue(Integer.toString(count));
response.addCookie(temp);
}
if (temp.getName().equals("date")){ /
lasttime=temp.getValue();%>
you last time online is <%= lasttime %>
<% lasttime=currenttime;
temp.setValue(lasttime);
response.addCookie(temp);
}
}
}
if (lastcount==0){
lastcount = count+1;
Cookie accessCount = new Cookie("accessCount", String.valueOf(lastcount)); //创建记录浏览次数的cookie
accessCount.setMaxAge(30*24*60*60);%>
<%= count %><br/>
<% response.addCookie(accessCount);
}
%></body>
</html>
参考上次的,还加了cookie
输入表单后
用session最后
附一个基础版
创建了就是这样的
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><base href="<%=basePath%>"><title>My JSP 'index.jsp' starting page</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--></head><body>This is my JSP page. <br></body>
</html>
再附一个8080端口被占用的问题解决
https://blog.csdn.net/weixin_44886869/article/details/110390571
因为是校内作业,就不放源代码了,可参考思路。想搜的也都能搜到。
这篇关于第二次网信实验的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!