File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session mangement problem

 
Aniket Kedari
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Can anybody tell me where I am going wrong?
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like the browser is caching the page.
You need to disable it.

Hope this helps
 
Aniket Kedari
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Aniket Kedari
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Amit Ghorpade
Bartender
Posts: 2851
10
Fedora Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Aniket Kedari
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

code]<img src="<%=tempHamiGraph%>?r=<%=System.currentTimeMillis()%>" border=0 usemap="#imageMap">[[/code]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic