Hi, how can i count the users online on site?
followed this guide http://www.stardeveloper.com/articles/display.html?article=2001112001&page=1
but i would like something that updates every 5 minutes and destroy the session when a user logs out
Hi, how can i count the users online on site?
followed this guide http://www.stardeveloper.com/articles/display.html?article=2001112001&page=1
but i would like something that updates every 5 minutes and destroy the session when a user logs out
If the method sessionDestroyed() is declared static it's possible to access it from the logout method using SessionCounter.sessionDestroyed()
.
If the method sessionDestroyed() is declared static it's possible to access it from the logout method using
SessionCounter.sessionDestroyed()
.
okay im using this to logout
<a href="j_acegi_logout" target="_top"><fmt:message key="top.logout"><fmt:param value="${model.user.username}"/></fmt:message></a>
Create a new method in SessionCounter, let's say discount():
public static void discount() {
if(activeSessions > 0)
activeSessions--;
}
Then, call discount() from wherever you do logout, preferable from the servlet:
import com.stardeveloper.web.listener.SessionCounter;
. . .
SessionCounter.discount();
I'm thinking a better method:
HttpSession s = request.getSession(false);
s.invalidate();
Destroying the session directly.
I'm thinking a better method:
HttpSession s = request.getSession(false); s.invalidate();
Destroying the session directly.
Ok do i put this in servlet or jsp?
On the land page (JSP) when a user performs logout.
e.g. if the user goes to home, would be nice to get an attribute and put the destroy code inside a condition.
So, first use request.setAttribute on the logout servlet to set a property to the land page.
Then, get that property from the land page and if that property isn't null execute the destroy code.
Is it possible to add the property to execute the destroy code to the button logout instead of servlet?
It is not possible, the kind of action of the link is to redirect to another page.
Are you using JSP or a Servlet to logout?
Are you using JSP or a Servlet to logout?
Im using jsp
The code performs a redirection after log out?
The code performs a redirection after log out?
yes you will be redricted to the login page.
Ok, you can use sessions. Before redirection, use session.setAttribute("logout", true)
. Then, into the login page you can place if(session.getAttribute( "logout" ).equals(true)){ ... }
with the invalidation session code.
Ok, you can use sessions. Before redirection, use
session.setAttribute("logout", true)
. Then, into the login page you can placeif(session.getAttribute( "logout" ).equals(true)){ ... }
with the invalidation session code.
Thanks it works now! i have a problem with my login page, im using a form and a background but i cant get the form centered on the page, im using this code.
<div class="f2" align="center" style="border:1px solid #222; padding:0px 50px 30px 50px; margin-top:200px">
Post this issue on Web Design/HTML and CSS forum. I think div align="center" is deprecated. margin:0 auto;
before margin-top should work.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.