Created
April 8, 2010 02:24
-
-
Save pedromtavares/359707 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileWriter; | |
import java.io.IOException; | |
import javax.servlet.http.HttpSessionEvent; | |
import javax.servlet.http.HttpSessionListener; | |
public class Logger implements HttpSessionListener{ | |
public void sessionCreated(HttpSessionEvent e){ | |
java.util.Date data = new java.util.Date(); | |
FileWriter writer = null; | |
try { | |
writer = new FileWriter( "log.txt" ); | |
writer.write( String.format( "Usuário logado em: %s%n", data ) ); | |
writer.flush(); | |
} catch (IOException e1) { | |
e1.printStackTrace(); | |
} finally { | |
if ( writer != null ) { | |
try { | |
writer.close(); | |
} catch ( IOException e1 ) { | |
e1.printStackTrace(); | |
} | |
} | |
} | |
System.out.println("ativei"); | |
} | |
public void sessionDestroyed(HttpSessionEvent e){ | |
System.out.println("desativei"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment