milan ID:milan25429688
13070次访问,排名8627(5)好友0人,关注者0
milan25429688的文章
原创 14 篇
翻译 0 篇
转载 1 篇
评论 2 篇
最近评论
alan:感觉有点复杂化
文章分类
收藏
    相册
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 SessionTest收藏

    新一篇: Poll Test | 旧一篇: MyFirstHTML

    这是我第一次自学JSP 内部对象Session 的例子:
    F:\Tomcat 5.0\webapps\ROOT\session
    main.htm
    session1.jsp
    session2.jsp

    1。main.htm

    <html>
    <head><title>session 应用1</title></head>
    <body>
    <form method=post action="session1.jsp">
    请输入出版社名称:
    <input type=text name="yourname">
    <input type=submit value="确定">
    <input type=reset value="重来">
    </form>
    </body>
    </html>


    2。session1.jsp

    <%--测试application 对象--%>
    <%
    application.setAttribute("app","你好,application");
    %>

    <html>
    <head><title>session 应用2</title></head>
    <body>

    <%--测试session 对象--%>
    <%
    String name1 = request.getParameter("yourname");
    session.putValue("username",name1);
    %>
    出版社的名称是:<%= name1 %>
    <p>

    <form method=post action = "session2.jsp">
    最近新出版的书是什么?
    <input type=text  name="book">
    <p>
    <input type=submit value="确定">
    <input type=reset value="重来">
    </form>

    </body>
    </html>


    3。session2.jsp

    <html>
    <head><title>session 应用3</title></head>
    <body>

    <%! String book = "";%>

    <!--测试session对象和application 对象-->
    <%
    String book = request.getParameter("book");
    String name2 =(String) session.getValue("username");

    String appname = (String) application.getAttribute("app");
    %>

    出版社的名称是:<%= name2 %>
    <p>
    最近新出版的书是:<%= book %>
    <p>
    Application 对象赋值String 测试:<%= appname %>

    </body>
    </html>

    发表于 @ 2005年02月02日 12:33:00|评论(loading...)|编辑

    新一篇: Poll Test | 旧一篇: MyFirstHTML

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © milan25429688