Servlet中怎么取得session和application
程序员文章站
2022-04-08 11:25:14
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.Ser...
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletContext;//和其它的不在一个包
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class X extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session=request.getSession();//得到session
ServletContext application =super.getServletContext();//GenericServlet提供的方法,得到application
}