Search code examples
jspsessionservletssession-management

How to check whether Session Attribute is successfully set?


I have multiple servlets and jsp pages (around 100) and I want to do session management for these using HttpSession. Is it necessary to check for HttpSession.getAttribute() in each of the servlets and jsp pages after setting the attribute for HttpSession.

Is there any convenient way so that I don't have to check HttpSession.getAttribute() in each of the servlets and jsp files?


Solution

  • I guess what you want to achieve can be done using Servlet Filters. For more info you can check this:- http://www.journaldev.com/1933/java-servlet-filter-example-tutorial

    http://tutorials.jenkov.com/java-servlets/servlet-filters.html