CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 session lost

Print topic Send  topic

Author Message
Espen Dahl
Posted: 11/29/2004, 5:12 AM

I have several restricted pages in my webapp and quite frequently I have to login again when going from one restricted page to the next. Any ideas?
Anton Hinxman
Posted: 12/08/2004, 2:05 AM

Put in a listener class and monitor the CCS attributes being created in the session. It is quite enlightening although verbose.

I have a class which monitors and maintains the login status of users and then updates my user table with such status. It forms a licence restriction function as well - if required.

Perhaps your TomCat session timeout is way too small?

  
public final class UserLoginListener extends java.util.Date  
  implements   
	HttpSessionAttributeListener,   
	HttpSessionListener,   
	HttpSessionBindingListener,   
	ServletContextListener,  
	ServletContextAttributeListener {  
  
You will need to monitor:  
  
  public void valueBound(HttpSessionBindingEvent event) {  
	try {  
		com.codecharge.util.CCLogger.getInstance().debug("Attribute "+ event.getName()+ " has been created"+  
			", value ="+ event.getValue());  
	} catch (Exception ex){  
		com.codecharge.util.CCLogger.getInstance().error(".valueBound has error:"+ ex.getMessage());   
		ex.printStackTrace();  
	}  
  }  
  public void valueUnbound(HttpSessionBindingEvent event) {  
	try {  
		com.codecharge.util.CCLogger.getInstance().debug("Attribute "+ event.getName()+ " has been removed"+   
			", value ="+ event.getValue());  
		if("UserLogin".equals(event.getName())) {  
			// event.getValue()  
			reset(""+event.getValue());  
			com.codecharge.util.CCLogger.getInstance().debug("Unbinding: "+ event.getValue());  
		}  
	} catch (Exception ex){  
		com.codecharge.util.CCLogger.getInstance().error(".valueUnbound has error:"+ ex.getMessage());   
		ex.printStackTrace();  
	}  
  }  
  
  public void attributeAdded(HttpSessionBindingEvent event) {  
	try {  
		// We look for...  
		// "UserID" String Log Name  
		// "UserLogin" String login name  
		// "GroupID" numeric as string?  
		// Ignore the following (repeatedly recreated)  
		if("YOURDBCONNAMEDateFormat".equals(event.getName()) || "YOURDBCONNAMEBooleanFormat".equals(event.getName()) ) {  
			return;  
		}  
		com.codecharge.util.CCLogger.getInstance().debug("Attribute "+ event.getName()+ " has been added " +  
			"in HttpSession HttpSession ="+ event.getSession()+   
			", value ="+ event.getValue());  
		if("UserLogin".equals(event.getName())) {  

etc.


Plumbed into Tomcat application via:

<!-- Define application events listeners -->
<listener>
<listener-class>
UserLoginListener
</listener-class>
</listener>

You can then see what is going on.

Regards

Anton

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.