⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scopedvars.java

📁 jsp 应用开发技术光盘 是《jsp应用开发技术》这本书的源代码
💻 JAVA
字号:
package servlets;

import java.io.IOException;

import javax.servlet.*;
import javax.servlet.http.*;

public class ScopedVars extends HttpServlet {	
	
	public void doGet(HttpServletRequest request,
			HttpServletResponse response)throws ServletException, IOException {
			
			/*attribute1 的作用域:requestScope*/	
			request.setAttribute("attribute1", "First Value");
			
			/*attribute2 的作用域:requestScope*/
			HttpSession session = request.getSession();
			session.setAttribute("attribute2", "Second Value");
			
			/*attribute3 的作用域:applicationScope*/
			ServletContext application = getServletContext();
			application.setAttribute("attribute3",new java.util.Date());			
												
			RequestDispatcher dispatcher =request.getRequestDispatcher("scoped-vars.jsp");
			dispatcher.forward(request, response);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -