Results 1 to 3 of 3
  1. #1
    bekir is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default get Object contents from session variable

    Hello,

    I need get the object contents from a session variable. The session variable has an object inside. I want link the object to the session variable. Here is a sample:

    PHP Code:
    <% UserBean currentUser = (UserBean(session.getAttribute("currentSessionUser"))); %>
    		Welcome
    		<%= currentUser.getFirstName() + " " + currentUser.getLastName() %>
    This is not working. Could you help me?

    Regards,

    Bekir

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    1.) How is it not working? What happens when you try to run/compile? Don't make people guess when you already know the behavior.

    2.) When you wrote
    Java Code:
    (UserBean(session.getAttribute("currentSessionUser")));
    did you mean
    Java Code:
     ((UserBean)session.getAttribute("currentSessionUser"));
    ?

    3.) Don't use Java code in JSPs. Use EL
    Java Code:
    ${sessionScope.currentSessionUser.firstName}

  3. #3
    bekir is offline Member
    Join Date
    Apr 2011
    Posts
    4
    Rep Power
    0

    Default

    Quote Originally Posted by r035198x View Post
    1.) How is it not working? What happens when you try to run/compile? Don't make people guess when you already know the behavior.

    2.) When you wrote
    Java Code:
    (UserBean(session.getAttribute("currentSessionUser")));
    did you mean
    Java Code:
     ((UserBean)session.getAttribute("currentSessionUser"));
    ?

    3.) Don't use Java code in JSPs. Use EL
    Java Code:
    ${sessionScope.currentSessionUser.firstName}
    Sorry, this is the first time on this forum. thank you very much, it worked. I will work on EL.

Similar Threads

  1. Accessing session variable from Java Class
    By Rohit Pokhrel in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 12-08-2010, 05:07 PM
  2. Saving the contents of a variable to disk
    By ckannan90 in forum New To Java
    Replies: 2
    Last Post: 08-11-2010, 11:37 PM
  3. Session Variable corruption example..
    By joe131 in forum Advanced Java
    Replies: 1
    Last Post: 05-10-2010, 03:51 PM
  4. how to use user name as a session variable in jsp
    By mudit222 in forum JavaServer Pages (JSP) and JSTL
    Replies: 4
    Last Post: 05-05-2010, 10:09 AM
  5. how to use session variable in my problem
    By Arif Baig in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-27-2008, 08:23 AM

Posting Permissions

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