jsp登入工作階段的簡單實現_JSP編程

來源:互聯網
上載者:User

jsp登入工作階段的簡單實現

<%@ 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><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>登入介面</title></head><body><form action="test_session2.jsp" method="post"> <table width="300" height="300" border="0" align="center">  <tr height="80" align="center">    <td colspan="2"><font size="24">OO登入</font></td></tr>  <tr height="30">    <td width="80" align="right">使用者名稱:</td>                 <td><input type="text" name="name"></td></tr>  <tr height="30">    <td width="80" align="right"> 密  碼:</td>    <td> <input type="password" name="password"></td></tr>    <tr><td height="40" align="center" colspan="2">    <input type="submit" value="登入"></td></tr> </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><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>登入成功</title></head><body><% String name = new String( request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");session.setAttribute("name", name);out.println(name + "成功登陸");%><a href="test_session3.jsp"><br>跳轉</a></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><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>會話</title></head><body><%String str = "";Object obj = session.getAttribute("name");if(obj != null){  str = obj.toString();  out.println(str + "已經成功登陸");}else{  out.println("會話逾時,請重新登入。");}%></body></html>

以上就是小編為大家帶來的jsp登入工作階段的簡單實現全部內容了,希望大家多多支援雲棲社區~

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.