欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Servlet中怎么取得session和application

程序员文章站 2022-07-05 16:28:50
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

 }