Hi there,
i want to save some variables in a session inside a spring controller, so here's the code:
running on tomcat this gives me on the first access nothing, on the second it gives me 'foo session message 123...', so far so good, but on the third access, this throws a null pointer exception on the getAttribute(), because sess is nullCode:HttpSession sess = request.getSession( true ); if ( sess == null ) { logger.debug( "session is null" ); } String au = (String) sess.getAttribute("myVar"); if ( au != null ) { logger.debug( au ); } sess.setAttribute( "myVar", "foo session message " + System.currentTimeMillis() );
What am i doing wrong, or is another way to achieve this?
Thank you,
Heiko


Reply With Quote
