Hi all I am facing a unique session problem. I am developing an application which takes date and time on index.html. Based on this onfo it draws a graph in Graph.jsp using JFreeChart. I am using bean and servlet to accomplish all this. Code sniplet is as below...
JSP->It instantiates a bean. The bean creats graph and also returns the servlet path info for graph. String tempHamiGraph will contain servlet path with servername:portno to display graph.
BEAN-> The bean creates the graph object and put it in session. It also returns the pathinfo of servlet
SERVLET-> It gets graph from session and passses it to jsp as response
Now my problem is that whenever I give some date and time in index.html it shows me corresponding graph but whenenver I go back using browsers back button and put new values in index.html it shows me same old graph. If I refresh JSP then it shows graph for new values.
Amit thanks but your suggestion doesnt work. I think I am doing a mistake when I save graph in session variable. session.setAttribute("tempHamiGraph", tempHamiGraph); I need new graph to be created for each request, but as I am saving it in session I get the same old one. I tried to use request.setAttribute("tempHamiGraph", tempHamiGraph); but it didnt work.
I need new graph to be created for each request, but as I am saving it in session I get the same old one. I tried to use
If you need the graph on every request then why do you even set the request attribute. Wont the servlet code generate a new one every time it is accessed?
Joined: Jan 29, 2008
Amit, I create graph in a function in bean. This function saves graph in a session variable. It also returns path of a servlet. In JSP I use the servlet path returned by the function in img tag to display graph. In servlet I retrieve the graph stored in session variable which is ultimately displayed in jsp.
Saving the bean in session wont solve the problem. Why dont you use the bean directly in the JSP without going through the servlet, thereby saving the processing time.
Also this will save you of the session variable and solve your problem without any extra work.
Hope this helps
Joined: Jan 29, 2008
The problem was either browser or proxy server was caching the page. Even meta tags didnt work so I changed jsp to add a parameter to the image url that is unique so that it thinks it is a different image Made it