This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
There is no HttpSession.getServletContext() method.
Here are the ways I know of to get a ServletContext:
1) ServletConfig.getServletContext() 2) GenericServlet implements ServletConfig, so HttpServlets all have a getServletContext() method 3) In a Filter you have access to the FilterConfig which is set in the init(FilterConfig fc) callback. You can use FilterConfig.getServletContext(). 4) In a ServletContextListener or a ServletContextAttributeListener, the event passed to the listener methods has a getServletContext() method.
Joined: Nov 14, 2004
Ooops, Mikalai is right. I am so tired I can't read javadoc.
HttpServlet, of course, does have a getServletContext() method. Thanks. Maybe I'll get this question right on the test now.