Session Handling is one of the most important task in web application. Same is true for EGL generated Java/j2ee code. In this article we will discuss about session handling in EGL targetting to Java/J2ee code. Also we will see how to deal with the scenerio when user tries to access the application pages without login.
Use Case:
1) When session expires, if the user clicks any of the link/buttons in the application, the application should log out and take the user to login page
2) When user enter the url of a page directly in the brower without validating itself, it should take you to login page.
One possible approach:
For session handling to work firstly we have to make an entry in the web.xml as session-timeout set to integer variable greater than 0.
In the application we should have a template. This template will be used by all the pages in the application except for login page. In general template is used to get a consistent look and feel through out the application. It may have header, footer, menus and so on. That means before loading individual pages it will first load template. So we have to write the session handling code in the template.
Sample code snippet:
You can do something like below in onConstructor
if(userId == null StrLib.clip(userId) == "")
urlPath string = urlType+server+":"+serverPort+contextPath;
//clear all session attributes
J2EELib.clearEGLSessionAttrs();
forward to url urlPath;
end
This way we can achieve the use case 2.
Regards
Monu
Use Case:
1) When session expires, if the user clicks any of the link/buttons in the application, the application should log out and take the user to login page
2) When user enter the url of a page directly in the brower without validating itself, it should take you to login page.
One possible approach:
For session handling to work firstly we have to make an entry in the web.xml as session-timeout set to integer variable greater than 0.
In the application we should have a template. This template will be used by all the pages in the application except for login page. In general template is used to get a consistent look and feel through out the application. It may have header, footer, menus and so on. That means before loading individual pages it will first load template. So we have to write the session handling code in the template.
Sample code snippet:
You can do something like below in onConstructor
if(userId == null StrLib.clip(userId) == "")
urlPath string = urlType+server+":"+serverPort+contextPath;
//clear all session attributes
J2EELib.clearEGLSessionAttrs();
forward to url urlPath;
end
This way we can achieve the use case 2.
Regards
Monu






No comments:
Post a Comment