Results 1 to 3 of 3
  1. #1
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default what is the best way to pass around an object in many jsp pages

    hi, thanks for reading

    just like what is stated above, what would be the best way to pass around an object between jsp pages. specifically, that object would be an ArrayList. it should hold some information that needs to be retrieved over time by a couple of jsp pages.

    one way our instructor told us is to put the object in the session object, like
    Java Code:
    session.setAttribute(key, 'arraylist object');
    but is it possible to have that array list object be declared in a separate java file and have the arraylist object declared as static? would that be a possible way to pass around an object?

    any suggestions would be appreciated.

    thanks,
    simon

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    but is it possible to have that array list object be declared in a separate java file and have the arraylist object declared as static? would that be a possible way to pass around an object?
    You don't provide enough information to answer this question directly. The solution your instructor gave you would work fine for sharing values between pages in a Session. Each session is a per user basis, so if you want to keep values for a given session set a session attribute. If you have something which needs to be shared across all users and would be considered more of a constant/global than anything else, try using a static.

  3. #3
    kulangotski is offline Senior Member
    Join Date
    Feb 2009
    Posts
    117
    Rep Power
    0

    Default

    I'm sorry for my vague explanation but you already answered my question. and even more, thanks for explaining the difference between session and static :D

    regards,
    simon

Similar Threads

  1. pass a variable from one object to another
    By kev670 in forum New To Java
    Replies: 3
    Last Post: 11-25-2010, 01:20 AM
  2. Pass multiple object types to one function
    By desmo in forum New To Java
    Replies: 3
    Last Post: 10-08-2010, 07:51 AM
  3. can i process two web pages at once?
    By saurabh208 in forum Java Servlet
    Replies: 2
    Last Post: 08-25-2010, 09:11 AM
  4. Replies: 1
    Last Post: 03-04-2009, 06:14 PM
  5. Getting all the pages from a domain
    By eva in forum New To Java
    Replies: 0
    Last Post: 12-25-2007, 11:41 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
  •