tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Janne Väänänen" <>
Subject RE: disappears
Date Mon, 17 May 2004 10:28:24 GMT
I resolved this. The problem was in execute method.
fixed code in execute method:
if (subject == null){
subject = new Subject();

//I added following two lines
if (principal != null)

session.setAttribute(Globals.SUBJECT_ATTR, subject);

-----Original Message-----
From: Janne Väänänen 
Sent: 17. toukokuuta 2004 12:12
Subject: disappears
Filter detected spam


I'm running tomcat 5 with -security option and I'm using JAAS login module.
In the jsp pages in first request after I have identified my self Subject is null.
When I hit refresh (second request) Subject is correct subject with principals etc.
But after that in all requests Subject is empty, no principals etc.

I use follwing code to get Subject:
 AccessControlContext acc = AccessController.getContext();
 Subject sub = Subject.getSubject(acc);

I checked tomcat src code that it uses attribute to store Subject
in session.

    public void setUserPrincipal(Principal principal) {

        if (System.getSecurityManager() != null){
            HttpSession session = getSession(false);
            if ( (subject != null) && 
                 (!subject.getPrincipals().contains(principal)) ){
            } else if (session != null &&
                        session.getAttribute(Globals.SUBJECT_ATTR) == null) {
                subject = new Subject();
            if (session != null){
                session.setAttribute(Globals.SUBJECT_ATTR, subject);

        this.userPrincipal = principal;

I guess that session.getAttribute(Globals.SUBJECT_ATTR) is somehow null after second request..
Any ideas what is causing this and how can I fix it?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message