What to store in session/request

Hello.
I'd appreciate some input on a design issue that i have. I am building some new components in a system that consists of JSP pages and servlets, which is new technology to me. I will try to describe my question in a simple and straightforward way:
My JSP page has a function where i can retrieve a list of people, based on some filtering criteria. It calls a servlet, that uses underlying components to read the persons from the database and compose an ArrayList of Person objects. It then attaches this ArrayList to the Session bean using the setAttribute method on the HttpSession object.
The JSP page then lists the result list from the search for people and using a control on the page, the user can move one or more persons from the search result list to a list of selected people, creating a team of one or more persons. This team is stored in an ArrayList attached to the session object and it's retreived, updated and re-attached to the session object by the servlet every time the user clicks on the control that selects a person to be added to the team. On form submit, the JSP page stores key information about the selected person in hidden fields in the form and the servlet extracts this information from the request object and updates the ArrayList and re-stores it in the session object.
When the "save team" button is pressed (form submit) and control returns to the servlet, it extracts the selected persons from the request object and uses underlying components to save the list. In essence, the session object is used to "send" the search result and the current list of members in ther team to the JSP page. The request object is used to send the current list of persons in the team from the JSP page to the servlet.
Now to my question: what is the best practice design for a function like this one? Is using the session object to transfer the search result list from a servlet to a JSP page a good solution? Is it a good solution to keep the list of selected persons in an object attached to the session object until it is finally saved a good solution. It is not entirely clear to me when i should store data on the session object and when to use the request. Also, what mechanisms are there to transfer data from the servlet to the JSP page, other than attaching it to the session object?

Can the servlet attach an object to the request object and can the JSP page access it just like it can with objects attached to the session object?Yes. Just use HttpServletRequest#setAttribute() and forward the request to the JSP.
Is there a general guideline for what to store in the session and what to store in the request? Store request scoped variables (form input values, request-specific variables, etc) in request scope and session scoped variables (logged in user, user settings, user specific dropdown list contents, session-specific variables, etc) in session scope.
My picture of this was that the request is something that is generated when a form (JSP page) is submitted and that it cannot be used to transfer data from a servlet to a JSP page. Is that wrong?Yes, it is wrong.

Similar Messages

  • How to store jsp session data of different user in util.hashmap

    how to store jsp session data of different user in java.util.hashmap
    and access the data of all user on the server side
    The same example is given in professional jsp but its not working.
    I can use getIds() of httpsessioncontext but it's depricated

    Hi
    I'm trying to make an example.
    With the following codes you can get the date from the session.
    request.getSession().getAttribute("sessionname")
    To store it in a hashmap you could do it like this ->
    Hashmap hm = new Hashmap();
    hm.put(Object key, request.getSession().getAttribute("sessionname"));
    I hope you understand it if not just write it!
    Cyrill

  • What's up with Session timeout.  That is all I can get anymore?

    What's up with Session timeout?  That is all I get anymore with I Tunes Store.

    The fix was: Turn off Junk Mail filter
    quit mail
    turn on junk mail filter
    (and reset database for good measure)

  • What is the usage of Request Variable ? and how we can use it ?

    Hi All,
    What is the usage of Request Variable ? and how we can use it ?
    Thanks in advance

    Hi,
    A Request variable is the same as a Session variable:
    http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_Variables4.html
    Cheers,
    Daan Bakboord
    Scamander Solutions

  • I am constantly being advised that my information has been accessed by a "new" iMac.  I only have ONE iMac. What gives? And what is with the constant request to "update" my information?

    I am constantly being advised that my information has been accessed by a "new" iMac. I only have ONE iMac. What gives? And what is with the constant request to "update" my information? As well, I have had to change my password a number of times since migrating to Yosemite; again: what's this all about? I Apple going the way of Microsoft for some reason? I left the Microsoft community because of constant problems with their OS and the unending string of "security updates"; is Apple and my iMac becoming "just another crap computer"?

    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • When downloading an update from app store, password is requested from a different user.  How to change user?

    when downloading an update from app store, password is requested from a different user.  How to change user?

    Unfortunately there's no way around this.  you will need that password to update the apps. If he won't give it to you, then i'm not sure what to say.
    You should have kept the account with the Apps you bought yourself.
    Otherwise, as I said, delete the Apps, and buy them again.
    Sorry.

  • Cannot Store HTTP Session error

    We are using SAP MII Version 12.0.11 Build(19)
    In the Netweaver SAP logs we are getting scores of the following error:
    application [XMII] Cannot store HTTP session with id [(J2EE1985000)ID1148896350DB00216050084636765028End] to failover. Session data may be lost. Probably session data is not serializable or a failover storage error has occurred.
    The error is: com.sap.engine.services.failover.exceptions.PersistentStorageException:
    Exception id: [00215AD51B4000C00000922A000017EC00049425438C91E7]
    This is not a "High Availability" server and there isn't a failover storage.
    What does this error really mean? Any ideas?

    It would appear that you are on the latest patch, and I wonder if this issue you mention is a result of item #5 where it mentions that "Session data is not serialized":  https://service.sap.com/sap/support/notes/1512526

  • HT2105 When you get a apple receipt for itunes songs and you paid with a itunes gift card do they charge you or give you store credit what's store credit is it good or bad or does it charge you if you have a free account with no credit cards at all is it

    When you get a apple receipt for itunes songs and you paid with a itunes gift card do they charge you or give you store credit what's store credit is it good or bad or does it charge you if you have a free account with no credit cards at all is it bad?

    iTunes credits are, for example, if you download a song from the store and it's found to be corrupt - if the track can't be fixed then iTunes support will tend to give you a song credit for a free download.
    When you purchase music from the store then any credits that you have will be used first, then any balance that you have (e.g. from iTunes gift cards or allowances), and any remaining amount will be taken from your credit card.

  • Web Service  Stateless Session request using JDeveloepr 11g (JAX-RPC)

    I have been trying to consume web Service by sending Stateless Session request to the system.
    I generated the Java Proxy using JDeveloepr 11g, using JAX-RPC.
    As it is Stateless I need to add following SOAP Header for authentication
    <soap:Header>
    <wsse:Security soap:mustUnderstand="1">
    <wsse:UsernameToken>
    <wsse:Username>[email protected]</wsse:Username>
    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wssusername-
    token-profile-1.0#PasswordText">adminOnDemand</wsse:Password>
    </wsse:UsernameToken>
    </wsse:Security>
    </soap:Header>
    To do this I tried clientuntcredentialprovider as suggested by most of the post online, but found of little help as the server complained of not be able to find the User Name and Password.
    To add to the mess problem I hit was I was not able to View the SOAP Request or Response sent by JDeveloper hence not helping me in debugging the same
    I have tried it on XML SPY by manually adding SOAP Header to the SOAP request and was able to find the response, but I have not been able to do the same using the JDeveloper 11g IDE.
    I have tried HTTP Analyzer assuming it might help, but unfortunately due to the huge size of WSDL, tool hanged my PC each time I loaded it.
    I know it should be fairly straight forward but just feel like missing something.
    Has anybody has got this thing working ?
    Regards,
    Deepak

    What exactly you mean that since your request is stateless you must send a Username token?
    Also, can you put here the code you used to populate the UNT.
    Finally, if possible, can you zip and email your wsdl, the http analyzer should be able to handle wsdls, even if they are huge.
    Thanks,
    Vishal

  • Need to store multiple session values in flex

    Hi,
         I need to store multiple session values in flex based on the user who logged in.
    For Example, if a user logged in as an administrator and in another windows another user logged in as guest, i need to maintain two seperate session for the two different users.
    Is it possible for maintaining different sessions.
    Expecting your valuable response.
    Thanks
    Jude Paul

    Look at Shared Objects. You can store this information in them by creating a unique object for each type of user.

  • Featured tab in app store says " Your request cannot be completed".

    Featured tab in app store says " Your request cannot be completed".
    Only happened after updating to iOS 5?

    Apps can only be downloaded via iTunes on your computer (and then synced to the iPad) or directly on the iPad via the App Store app - have you tried downloading it via either of those ?

  • What is the use of request reverse posting in rsmo?

    what is the use of request reverse posting in rsmo?

    Hi,
    Refer the links:
    Reverse Posting
    Request Reverse Posting
    Re: 0dlv_qty is returning -ve values in BW via 2lis_11_vcitm
    Search teh forums for few more links:
    With rgds,
    Anil Kumar Sharma .P

  • What is purpose of session variables in obiee

    what is purpose of session variables in obiee and how to use it in obiee

    whenever a user logs in, a session variable is initialized for that particular user.
    The session variable can hold values such as Username, loglevel.
    For example, if you have 10 obiee users and u want to set different loglevels depending on their roles, you can create system session variable LOGLEVEL which will be initialized dianamically depending on the initialization block.
    Edited by: Vishal on Jul 5, 2011 10:30 PM

  • What is this apps infusion request that keeps popping up when I visit web sites?

    What is this apps infusion request that keeps popping up when I go to any website? 

    I see.
    You'll get that prompt if (1) you have "Limit website access to location services ... Prompt for each website once each day" selected in Safari > Preferences > Privacy and (2) the website you are visiting requests your location. The other options for (1) are "... Prompt for each website one time only" and "Deny without prompting" in both Lion (10.7) and Mountain Lion (10.8); for privacy reasons, there is no option to allow without prompting.
    It makes sense that the website you were visiting might need your location to provide you with local vendors. If they employ the services of the business technology company names Infusion, that's why the request refers to apps.infusion.com instead of the top-level site you were visiting.
    As for why it started suddenly last week, that could be for any of several reasons.
    * Did you just start visiting that food service site?
    * Maybe the food service site just started using Infusion's services.
    * Maybe Infusion just started using Mac OS X services to obtain your location.

  • What is meant by session Facade design pattern

    please give me

    cripes
    http://www.google.com/search?q=what+is+meant+by+session+Facade+design+pattern
    Who'd have thought it? ;-)
    kind regards,
    Jos

Maybe you are looking for