2014-03-19 43 views

回答

1

JSP包含隱式對象,您可以從會話中獲取值。

一些的是,這些方法是

Methods of session object: 

setAttribute(String, object) 
getAttribute(String name) 
getAttributeNames 
isNew() 
getCreationTime 
getId 
invalidate() 
getLastAccessedTime 
getMaxInactiveInterval 
removeAttribute(String name) 

參考link

1

JSP有稱爲會話可以直接使用會話對象 在scriplet或表達在JSP作爲隱式對象:

<% 
String name = (String) session.setAttribute("attribute_name"); 
%> 
1

看看這裏:

JSP Tutorial

您可以從一個會話中獲取數據以這樣的方式

String name = request.getParameter("username"); 

,並輕鬆添加:

session.setAttribute("theName", name);