<html>
<head>
<META http-equiv=Content-Type content="text/html; charset=utf-8"><title>{MENU_NAME}</title>
</head><!--设置默认背景色-->
<body bgcolor="#f4fcff"><!--form名称为 form_main -->
<form name="form_main" action="" method="post">  <!--表格100%居中-->
  <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">    <tr>
      <td><div id="container">
          <table width="100%" id="panel_a">
            <tr>
              <td width="100%"><table width="100%" border="0" cellspacing="5" cellpadding="0" >
                                
               <tr>
                       <td width="25%">&nbsp;</td>
                       <td width="25%" align="center"></td>
                    <td width="50%">&nbsp;</td>
  </tr>   
                    
               <tr>
                       <td colspan="2" align="right">账号:</td>
                    <td><input type="text" name="g_loginUser" id="g_loginUser" size="20" maxLength="50"/></td>
  </tr>   
         
              <tr>
                    <td colspan="2" align="right">密码:</td>
                    <td><input type="password" name="g_loginPassword" id="g_loginPassword" size="20" maxLength="50"/></td>
  </tr>     
                                
              </table></td>
            </tr>
            <tr>
              <td height="44"><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#99BBE8">
                  <tr>
                    <td height="1"></td>
                  </tr>
                </table>
   
                <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td height="33" align="center">
                    <input type="submit" class="buttonSubmit" id="login_btn" value="登&nbsp;录">                      
                    <input type="button" class="buttonSubmit" id="ret_btn" value="返&nbsp;回"></td>
                  </tr>
                </table></td>
            </tr>          </table>
        </div></td>
    </tr>  </table>
</form><script>document.body.style.background='#dfe8f6';</script></body>
</html>
1.当点击登录按钮时,用session保存登录信息?具体实现代码
2.如何获取保存后的session登录信息?
3.session的生命周期在哪里设置?

解决方案 »

  1.   

    jsp页面中可直接获取session,用session.setAttribute("attrName",obj)将对象信息设置到session中,用的时候再界面中session.getAttribute("attrName");就可以找回这个对象,session只保存一次对话。关闭之后就消失
    session的生命周期 session.setMacInactiveInterval(秒数);
      

  2.   

    Servlet页面 
    设置属性:request.setSession().setAttribute("属性名",属性值);
    获取属性:request.getSession().getAttribute("属性名");
    jsp页面
    建议用EL表达式
    获取属性:${sessionScope.属性名}
      

  3.   


    回答很全面session默认的生命周期是30分钟,在服务器的web.xml中有如下配置信息:
     <!-- ==================== Default Session Configuration ================= -->
      <!-- You can set the default session timeout (in minutes) for all newly   -->
      <!-- created sessions by modifying the value below.                       -->    <session-config>
            <session-timeout>30</session-timeout>
        </session-config>
      

  4.   

    1.当点击登录按钮时,用session保存登录信息?具体实现代码
      

  5.   

    1.当点击登录按钮时,用session保存登录信息?具体实现代码
    2.如何获取保存后的session登录信息?
    3.session的生命周期在哪里设置?
    第一:表单中Action="";引号里面写你要提交的Jsp页面。
          然后在jsp页面使用request.getParamter("控件名");获取表单中的提交信息。
          Session.setAttribute("session属性名",从表单中提交的数据);
    第二:使用Session.getAttribute("session属性名");获取登录信息
    第三:请问楼主对JSP内置对象了解有多少。认真看书。session的生命周期不需手动设置,就是浏览器的打开到关闭。关闭浏览器该Session对象就消亡了。
      

  6.   

    1.当点击登录按钮时,用session保存登录信息?具体实现代码
    2.如何获取保存后的session登录信息?
    3.session的生命周期在哪里设置?
    第一:表单中Action="";引号里面写你要提交的Jsp页面。
      然后在jsp页面使用request.getParamter("控件名");获取表单中的提交信息。
      Session.setAttribute("session属性名",从表单中提交的数据);
    第二:使用Session.getAttribute("session属性名");获取登录信息
    第三:请问楼主对JSP内置对象了解有多少。认真看书。session的生命周期不需手动设置,就是浏览器的打开到关闭。关闭浏览器该Session对象就消亡了。
    session 不可以设置吗?session.setTime...什么忘了,这个是干什么的
      

  7.   

    补充一下:session生命周期方法:
    GetLastAccessTime()获取在会话时间内Web容器受到
    SetMaxInatciveInterval()设定服务器程序容器使会话无效之前客户请求之间的最长时间间隔
    GetMaxInatciveInterval()
    Invalidate()使会话失效
    IsNew()判断是否是新的会话。
    GetCreationTime()返回会话的创建时间
      

  8.   

    关于session:
    当客户端浏览器向服务器发送http请求时,服务器会为其做出响应,并且为其分配一定的资源,但是当客户端浏览器在接受到响应而很长时间没有动作时,这样会占用一定的系统资源,所以我们在必要的时候需要为其设定生命周期,以节省系统资源。
      

  9.   

    1.当点击登录按钮时,用session保存登录信息?具体实现代码
    2.如何获取保存后的session登录信息?
    3.session的生命周期在哪里设置?
    1--  session.setAttribute("session属性名",表单中的数据);
    2--  session.getAttribute("session属性名");获取session中保存的登录信息
    3-- session默认的生命周期是30分钟 一般是不用设置的。。
      

  10.   


    有道理,其实就是set和get 的应用
      

  11.   

    我的登录成功后,把信息保存到了session中后,想在bean/servlet中调用seeion中保存的登录用户信息,,,,求高手教教我啊