Tutorial66.com
@Share Application Development Skill.



Tutorial is tutorial...66 is My Country Code Up to 10 Years EXP for Application Development Role in Thailand.
collapse

Tutorial Category



Topic: Session in JSP Example to use Sessing Object in JSP  (Read 203 times)


My Development skill
Java JSP Servlet EJB
Spring Framework
Hibernate Framework
iReport Jasper Report
Apache CXF
PHP Codigniter
Oracle PLSQL
Unix Shell Script
Session in JSP Example to use Sessing Object in JSP
« on: November 11, 2011, 05:15:30 AM »
Session in JSP Example to use Sessing Object in JSP
You can use Session object  in jsp  with object  "session"
Example Code for JSP session
This Example Show you for
 - How to set object to session
 - How to get value from session by key
 - How to get Session ID
 - How to collect attribute name from session
 - How to destroy session
Code: [Select]
<%
//You can put object  to session with key and value
session.setAttribute("key","Value Object");
session.setAttribute("key1","Value1");
// Get Data from Session by Key
String data=(String)session.getAttribute("key1");
// Get Session id  from session object
String sessionID=session.getId();
//Load all  attribute name  from session to Enumeration
Enumeration em=session.getAttributeNames();
while(em.hasMoreElements()){
out.println(em.nextElement());
}

//Destroy session
session.invalidate();
%>

« Last Edit: November 11, 2011, 05:17:46 AM by Admin »




SimplePortal 2.3.3 © 2008-2010, SimplePortal