jsp隐式对象 (输入/输出对象) request response out
1:request对象
用户输入的数据用来存放在Request对象中,用javax.servlet.HttpServletRequest执行
*接受数据
<body> <% out.println("协议版本类型和版本号:"+request.getProtocol()+"<br>"); out.println("当前连接使用的协议:"+request.getScheme()+"<br>"); out.println("服务器:"+request.getScheme()+"<br>"); out.println("端口号:"+request.getServerName()+"<br>"); out.println("请求方式:"+request.getMethod()+"<br>"); out.println("客户端ip:"+request.getRemoteAddr()+"<br>"); %> </body>
*设置页面请求数据编码(只适用post)
<% //放在getParamater前 request.setCharacterEncoding("UTF-8"); %>
*设置属性,取得属性,删除属性
<% //设置属性 request.setAttribute("userId",strUserId); //取得属性 request.setAttribute("userId"; //删除属性 request.removeAttribute("userId");
<% request.setAttribute("username","zhangsan"); request.setAttribute("password","456"); %> <% out.println("用户名"+request.getAttribute("username")); out.println("密码"+request.getAttribute("password")); %>
*请求转发
*获得session
<% HttpSession mySession =request.getSession(); %>
原文地址:https://www.cnblogs.com/kukudemumubuku/p/12633073.html
时间: 2024-11-06 01:04:33