信息网络应用基础.docx

上传人:b****5 文档编号:3962607 上传时间:2022-11-26 格式:DOCX 页数:41 大小:4.94MB
下载 相关 举报
信息网络应用基础.docx_第1页
第1页 / 共41页
信息网络应用基础.docx_第2页
第2页 / 共41页
信息网络应用基础.docx_第3页
第3页 / 共41页
信息网络应用基础.docx_第4页
第4页 / 共41页
信息网络应用基础.docx_第5页
第5页 / 共41页
点击查看更多>>
下载资源
资源描述

信息网络应用基础.docx

《信息网络应用基础.docx》由会员分享,可在线阅读,更多相关《信息网络应用基础.docx(41页珍藏版)》请在冰豆网上搜索。

信息网络应用基础.docx

信息网络应用基础

《信息网络应用基础》第2次实验:

动态页面制作

专业姓名班级学号班内序号

作业提交说明:

1、严格按实验要求制作动态页面,并在“实现功能介绍”标题下,按实验要求描述完成情况,尽可能体现个性;

2、雷同代码or网上代码没有实验成绩;

3、在“源代码及显示效果”标题下,按不同文件名粘贴源代码及显示效果(浏览器效果截图),页面和显示效果对应,如范例所示(贴页面内容时请删去范例);

4、仅提交本文档;

5、文件命名格式严格按照模板提供的方式补齐,邮件标题和文件名一致。

1实验要求:

1.主题:

设计网上商店或个人网站的主页(任选一);

2.使用基本JSP元素和内置对象设计动态页面;

3.主页面命名使用mypage.jsp/html,以便检查;

4.使用request、response对象完成登录处理功能:

能提取表单信息、登录有误能实现重定向,选作:

页面刷新功能;

5.使用session对象完成在多个页面中的数据转发功能;

6.尽量完成使用Cookie实现访客计数或显示上次浏览时间的功能,选作:

使用application对象实现网站计数功能;

7.选作:

使用include指令标识/动作元素、使用

forward>动作元素

8.如果遇到问题记录到文档中(包括解决方法)。

2实现功能介绍

2.1功能描述

1.使用了request、response对象完成登录处理功能:

能提取表单信息、登录有误能实现重定向。

Request对象的getParameter()以及getParameterValue()方法,可以用来获取用户提交的数据。

使用了sendRedirect()实现登录错误时重定向。

2.使用了response对象的setHeader()方法设置HTTP头中的值,程序用到了日期的方法,用page指令导入java.util.*类,实现了页面刷新功能,并显示当前时间。

3.使用了session对象完成了在多个页面中的数据转发功能,这里session内置对象使用setAttribute()和getAttribute()方法创建及获取客户的用户名信息。

实现了用户名在多个页面转发功能。

4.使用Cookie实现了访客计数。

2.2操作流程

如有多个页面,请简要描述它们的关系。

Mypage.jsp主页面,若只输入密码,则登录页面重置,还是返回到主页面。

主页面显示第几次访问该网站。

输入用户名和密码登录,跳转到veri.jsp欢迎页面。

点击products进入产品介绍页面

在products页面里可以选择想买的商品,点击提交会跳转到购物车页面。

点击abouts可以跳转到花语大全页面哦。

Abouts.jsp页面可以显示当前时间。

3源代码及显示效果

<%@pagelanguage="java"contentType="text/html;charset=GB18030"

pageEncoding="GB18030"%>

<%@pageimport="java.util.*"%>

DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

//www.w3.org/1999/xhtml">

mylittleshop

*{

padding:

0px;

margin:

0px;

}

div#header{

width:

"100%"

}

#k{

width:

80%;

height:

200px;

background-image:

url(images/header.jpg);

background-repeat:

no-repeat;

margin-left:

auto;

margin-right:

auto;

}

div#templatemo_main{

width:

100%;

height:

900px;

text-align:

center;

/*margin-top:

210px;*/

background-color:

pink;

position:

relative;

}

div#templatemo_menu{

width:

100%;

text-align:

center;padding-top:

0px;background-image:

url(images/templatemo_menu.png);

background-size:

100%70px;

}

#menuul{

list-style-type:

none;

width:

100%;

}

#menuul>li{

display:

inline-block;

width:

20%;

height:

40px;

line-height:

40px;

}

 

div#login{

/*margin-top:

"auto";*/

width:

"230px";

height:

"190px";

padding-top:

"0px";

/*float:

left;*/

/*绝对定位浮在父元素之上,用leftrighttopbottom定位*/

position:

absolute;

right:

80px;

top:

90px;

}

/*定位到h1那行字*/

#templatemo_main>h1{

/*vertical-align:

sub;*/

margin-top:

50px;

margin-bottom:

30px;

width:

100%;

font-size:

50px;

font-style:

italic;

}

 

  • Home
  • Products
  • About
  • Carts
  • ---->

    50%000";border="1"background="images/login.png">

    用户名:

    密  码:

    /*登录成功后跳转到Verification.jsp*/

    50px000"align:

    "center">

    浪漫花语

    红玫瑰:

      爱情    热恋

    白玫瑰:

      天真    纯洁

    蓝玫瑰:

      妖娆    神秘

    红蔷薇:

      高贵    美丽

    蓝蔷薇:

      梦幻    温柔

    百合:

       清新    脱俗

    郁金香:

      表白    祝福

    康乃馨:

      母爱    真情

    石竹花:

      才能    大胆

     

     

    30px000">

     

    welcometomyshop!


    <%

    response.setContentType("text/html;charset=UTF-8");

    //PrintWriterout=response.getWriter();

    Cookie[]cookies=request.getCookies();/*使用cookie完成了访客计数*/

    if(cookies!

    =null){

    out.write("您上次访问的时间是:

    ");

    for(inti=0;i

    Cookiecookie=cookies[i];

    if(cookie.getName().equals("lastAccessTime")){

    LonglastAccessTime=Long.parseLong(cookie.getValue());

    Datedate=newDate(lastAccessTime);

    out.write(date.toLocaleString());

    }

    }

    }else{

    out.write("这是您第一次访问本站!

    ");

    }

     

    Cookiecookie=newCookie("lastAccessTime",System.currentTimeMillis()+"");

    response.addCookie(cookie);

    %>

    0002%"align="cenetr"border:

    "2"border-width:

    "2px5px5px2px">

    你的倩影就好似一道美丽晨曦

    一生有你可知一生有你我都陪在你身边

    灿烂笑容谢谢你灿烂的笑容

    不变的承诺你像那沾满露珠的花瓣

    爱的最高点如果你是美丽海岸

    恋恋花语你是我最特别的存在

    朝朝暮暮我把誓言一生一世戴在你手指

    一生的期盼喜欢你是淡淡的爱

    天使的祝福愿你每天都快乐幸福

     

    Verification.jsp

    <%@pagelanguage="java"contentType="text/html;charset=GB18030"

    pageEncoding="GB18030"%>

    <%@pageimport="java.util.*"%>

    DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http:

    //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    //www.w3.org/1999/xhtml">

    mylittleshop

    *{

    padding:

    0px;

    margin:

    0px;

    }

    div#header{

    width:

    "100%"

    }

    #k{

    width:

    80%;

    height:

    200px;

    background-image:

    url(images/header.jpg);

    background-repeat:

    no-repeat;

    margin-left:

    auto;

    margin-right:

    auto;

    }

    div#templatemo_main{

    width:

    100%;

    height:

    900px;

    text-align:

    center;

    /*margin-top:

    210px;*/

    background-color:

    pink;

    position:

    relative;

    }

    div#templatemo_menu{

    width:

    100%;

    text-align:

    center;padding-top:

    0px;background-image:

    url(images/templatemo_menu.png);

    background-size:

    100%70px;

    }

    #menuul{

    list-style-type:

    none;

    width:

    100%;

    }

    #menuul>li{

    display:

    inline-block;

    width:

    20%;

    height:

    40px;

    line-height:

    40px;

    }

     

    div#login{

    /*margin-top:

    "auto";*/

    width:

    "230px";

    height:

    "190px";

    padding-top:

    "0px";

    /*float:

    left;*/

    /*绝对定位浮在父元素之上,用leftrighttopbottom定位*/

    position:

    absolute;

    right:

    80px;

    top:

    90px;

    }

    /*定位到h1那行字*/

    #templatemo_main>h1{

    /*vertical-align:

    sub;*/

    margin-top:

    40px;

    margin-bottom:

    20px;

    width:

    100%;

    font-size:

    50px;

    font-style:

    italic;

    }

  • Home
  • Products
  • About
  • Carts
  • ---->

    <%Stringstr=null;

    str=request.getParameter("user");/*使用request获取用户名*/

    session.setAttribute("user",str);/*使用session完成用户名在页面之间的转发*/

    if(str==null)

    {str="";

    }

    byteb[]=str.getBytes("ISO-8859-1");

    str=newString(b);

    if(str.equals(""))

    {response.sendRedirect("mypage.jsp");/*使用sendRedirect完成页面重定向功能*/

    }

    else{out.print(str+",");

    }

    %>

    您好,
    亲爱的<%Stringusername=request.getParameter("user");%><%=username%>,
    欢迎来到我的小店!


    展开阅读全文
    相关资源
    猜你喜欢
    相关搜索

    当前位置:首页 > 小学教育 > 数学

    copyright@ 2008-2022 冰豆网网站版权所有

    经营许可证编号:鄂ICP备2022015515号-1