• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

session mangement problem

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic