HttpSession creation

Posted on 2005-04-13
Last Modified: 2008-02-01

When is an httpSession object created.  For instance if a request is made to a jsp page ie index.jsp, will the httpsession object be created in the first request or will it be created the next time a request is made to the server?

thanks in advance
Question by:inzaghi
    LVL 29

    Accepted Solution

    As I understand it's made at the first request in a JSP unless you have set the session attribute of page to be false. Otherwise every request would be the first one and you would never know about the second! :-)

    <%@page session="false" %>
    LVL 29

    Expert Comment

    You can show this by this jsp as your index.jsp:

    <% session.setAttribute("name" , "sessioniscreated!!!!!!") ;%>
    <%= session.getAttribute("name")%>"

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
    This video teaches viewers about errors in exception handling.
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now