File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes session mangement problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "session mangement problem" Watch "session mangement problem" New topic
Author

session mangement problem

Aniket Kedari
Ranch Hand

Joined: Jan 29, 2008
Posts: 30
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

Joined: Jun 06, 2007
Posts: 2711
    
    5

Looks like the browser is caching the page.
You need to disable it.

Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
Aniket Kedari
Ranch Hand

Joined: Jan 29, 2008
Posts: 30
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

Joined: Jun 06, 2007
Posts: 2711
    
    5

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

Joined: Jan 29, 2008
Posts: 30
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

Joined: Jun 06, 2007
Posts: 2711
    
    5

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

Joined: Jan 29, 2008
Posts: 30
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
 
subject: session mangement problem
 
Similar Threads
session listeners
PathInfo RequestURI ServletPath and RequestPath Query
JSP session
dispatcher.forward(req, res): not able to invoke the jsp page
How to display Buffered Image object in jsp