I'm developing an advanced search page for a web application I'm currently working on. Everything's gone fine till i came to pass the query parameter from one page of the results to another. How can I do this without passing the query as a parameter (thus exposing the dynamic query to the user) ?
I've temporarily solved the issue by saving the query as an attribute in the session however I don't think this is an appropriate solution considering that a large number of clients will be accessing the search page.
Putting it on the session isn't a big deal - you just need to be strict about cleaning the state up when the search function is out of scope
Ok but how am I going to know that I've gone out of the search scope? Should I implement the code to remove the query string from session on every page request (action) other than the search action?
Btw, I'm using struts as the framework for my application.
Agreed that's the tricky bit - you could make some arbitary boundary - like if they are on these pages/actions then clean it up - for instance if you have a search / edit /new type ring of pages, you'd probably want to maintain the serach criteria for the search and edit screens, but if the new function is used you can then throw it away.
On the other hand - how much state is this. The user may find it more useful for you to always remember the criteria for the whole session. Lets face it, it's unlikely to be a large amount of data unless you are talking about caching the results of the search rather than the criteria?
Ok I guess that I'll leave it as it is then, ie. leaving the search criteria in the session. Maybe I'll make some profiling in order to have a clearer idea of how much strain is the data in the session putting on the memory... though it very much depends on what is in the search criteria (the 'keywords' text box, which is used for free-text searching, is worrying me a bit... though i think i should define a smaller limit to it now).
Thanks very much for your help :-)