JSP – Session Page Directive

Session Attribute Of JSP Page Directive

This attribute checks whether JSP page is in a particular HTTP session or not. It can have true or false value. Default value is true.

Syntax:

<%@ page session=”value”%>

welcome.jsp:

<%@ page session=”true” %>
<html>
            <head>
                        <title>session page directive example</title>
            </head>
            <body>
                        <h2>In JSP Session automatically created</h2>
                        <h2>Every session has unique ID</h2>
                        <%
                                    out.print(“Session id:” + session.getId());
                        %>
            </body>
</html>

Scroll to Top