请问怎么通过HttpServletRequest或HttpServletResponse对象取得ServletContext对象

03-06-29 lina
请问怎么通过HttpServletRequest或HttpServletResponse对象取得ServletContext对象

lvimei
2003-07-02 17:11
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
public final class SaveRegistrationAction extends Action {

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

{
servlet.getServletContext().getAttribute(Constants.DATABASE_KEY);
}

}

这个是在struts中应用sevletContext的例子,在servlet中是可以直接获犁