Session can be obtained through request.getSession();
The application can be obtained through this.getServletContext() or request.getSession.getServletContext()
1 public class ServletTest extends HttpServlet { 2 public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 3 HttpSession session = request.getSession(); 4 ServletContext application = this.getServletContext(); 5 } 6 }