title: Handling the browser 'Back' button in jsp
body: <p>I have a jsp search page (Search.jsp) and a result page (Result.jsp), both of them can choose search criteria. and then passed the parameters to a java controller file (Controller.java) to build a query string and performs query searching. The query string and searched results will be passed to Result.jsp for displaying. </p>
  
  <p>Currently I use servletContext to remember the processed query string, and if users use Result.jsp to select search criteria, Controller.java will append such criteria to the existing query string. If I do a few searches using Result.jsp. For example, query string would display <code>((Query1) AND Query2) AND Query3</code> on the Result.jsp page. Then using the browser's back button to go back to the previous display page. For the same example, query string displays <code>(Query1) AND Query2</code>. Then if I do search again. The query string <code>(((Query1) AND Query2) AND Query3) AND Query4</code> would be used. I know this is expected with my current implementation since Result.jsp does not do any modification with the processed query string.</p>
  
  <p>However, I would like when user uses the browser Back button, for example, query string displays on the page as <code>(Query1) AND Query2</code>, and perform search, the query string should be <code>((Query1) AND Query2) AND Query4</code> in which the query string is build based on the current displayed query string on the Result.jsp page plus the current selection. How can I do that? It sounds quite simple but I have tried several ways of using the  in Result.jsp to update the query string, but still couldn't get it right. Therefore I am wondering maybe my approach of using <code>&lt;c:set&gt;</code> is wrong. I would like to hear your suggestion. Thanks in advance.</p>