I am calling a jsp based on 2 parameters which is passed from jsp 1 in this way.Below i pass 2 parameters into 2.jsp and based on these 2 parameters data is displayed in 2.jsp.I have a loop in which i have a number of hrefs like the one i have described below.Each of these href passes a different set of value to 2.jsp.
out.println("<a href=\"2.jsp?prId=" + prog.getId() + count + "\">" + prog.getName() + "</a>");
I retrieve these 2 parameters in 2.jsp using the following lines
count_id = request.getParameter( "country_id" );
prog_id = Integer.parseInt(request.getParameter( "program_id" ));
Based on these 2 parameters i show the corresponding data in 2.jsp
Now i have a back button in 2.jsp and i call 1.jsp in 2.jsp using the following code
<a href="1.jsp"><img src="/image/back.gif" border="0"></a>
The problem is when i use the back button and go back to 1.jsp and select another href like the one i have described above i get the data related to the previous href selected.
I guess the problem is when i request the page is loaded from cache rather than from the server.
Please advice
You just need to instruct the browser to NOT cache the page. You can do this with help of a servlet filter which sets the following response headers:
Now just map this filter on an URL pattern covering the JSP pages of interest. E.g.
*.jspor/somefolder/*(the@WebFilterin the example does that for all JSPs).Make sure that you clear the browser cache before testing.
See also: