These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: error of two open sessions on clicking twice on tab
PostPosted: Mon May 26, 2008 5:28 am 
Newbie

Joined: Mon May 26, 2008 5:18 am
Posts: 2
Location: Mumbai
Hi All,
In my project,we are using frameworks like Struts and hibernate. But major concern is the following:
If user clicks twice on particular tab,then it gives error of two open sessions and goes back to login page.
If anybody knows how to resolve this problem,then plz help me out.

Thanks in advace.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 26, 2008 1:03 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
This really isn't a Hibernate problem, so much as it's a web design problem.

Solving the double submit problem in a Java based web application has been discussed by much better looking people than me. You might want to take a look here:

http://faq.javaranch.com/java/DoubleSubmitProblem

Quote:
Double Submit problem:

Two most frequently used HTTP request methods are GET and POST. GET method retrieves resource from a web server. Resource is identified by base location and optional query parameters. Generally, parameters of GET request are used to narrow the result and do not change server state. The same GET request can be sent to the server as many times as needed.

On the contrary, parameters of POST request usually contain input data, which can change state of server application. Same data submitted twice may produce unwanted results, like double withdrawal from a bank account or storing two identical items in a shopping cart of an online store. Submission of the same data more than once in a POST request is undesirable and got its own name: Double Submit problem.

It can happen when clicking "Reload" on a page that was generated by a POST, or when clicking "Back" takes you to a page that was generated by POST. In both cases the browser will generally issue a warning, but from that it's not clear whether it will or will not have bad consequences. So it's better to avoid the situation entirely. Another way to try to avoid double submits is to set a cookie on the first submit, and then issue a warning if a cookie exists if another submit is attempted. This, too, isn't infallible.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: re:error of two open sessions on clicking twice on tab
PostPosted: Mon May 26, 2008 2:11 pm 
Beginner
Beginner

Joined: Fri Jun 29, 2007 11:12 am
Posts: 25
Hello,
this is truly an httpSession object nothing to do with JPA or hibernate. Struts2 has interceptor 'FlashInterceptor', apply it around the action youre submitting. That should solve it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 3:03 am 
Newbie

Joined: Mon May 26, 2008 5:18 am
Posts: 2
Location: Mumbai
But its giving me error of hibernate as following:
HibernateException : Illegal attempt to associate two open sessions.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 27, 2008 10:15 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Yes, but the point is, this will be solved at the web programming level, not the Hibernate level.

It's like driving into a brick wall and blaming the car. Sure, the car went into the wall, but it wouldn't have if the driver didn't steer into it.

Steer clear of this at the web level, and you won't have this problem.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.