Servlet gets session and application

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 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324738688&siteId=291194637