Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: sessionScope.

  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts

    sessionScope.

    In a JSP:

    for a field of <input Value="${testBean.lastName}" />

    Now this "testBean" is a bean which is placed on the session, such as:

    request.getSession().setAttribute("testBean", ResultBean);

    But more often, I saw:


    <input Value="${sessionScope.testBean.lastName}" />


    Then why <input Value="${testBean.lastName}" /> also works? How does the ${} know the testBean is a bean on the session?

    How does it get resolved?


    Thanks

    Scott

  • #2
    Regular Coder brad211987's Avatar
    Join Date
    Sep 2005
    Location
    Ohio
    Posts
    631
    Thanks
    10
    Thanked 50 Times in 50 Posts
    sessionScope is an implicit object available in JSP. This is why you can use the sessionScope.bean.property method of getting at a value. If you do not specify a scope, and instead just use bean.property, I'm assuming that the container looks through all of the scopes to find the object that you specify and in your case finds it in the session scope. It will take a bit of brushing up on JSP to remember all of this for sure, so someone please correct me if I'm wrong, but I believe this is the general idea.
    Last edited by brad211987; 12-12-2008 at 08:01 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •