How do I write and read object from HTTP Session?

Category: jsp.snippets, viewed: 1545 time(s).
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Session Read & Write</title></head>
<body>
<%
    //
    // Creates a session attribute named login-date to store a java.util.Date.
    //
    session.setAttribute("login-date", new Date());

    //
    // Read back the java.util.Date object from the session attribute.
    //
    Date loginDate = (Date) session.getAttribute("login-date");
%>

Login Date: <%= loginDate %>
</body>
</html>
Click here to lend your support to: Kode Java Org and make a donation at www.pledgie.com !

 

Can't find what you are looking for? Join our FORUMS and ask some questions!
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Sponsored Links

Our Friends

Statistics

Locations of visitors to this page
visitor stats