当前位置:网站首页>Web resource sharing
Web resource sharing
2022-07-23 08:05:00 【delighted_ qian】
1、Request Implement request forwarding ( And the following Response Implement redirection distinguish )

Request to forward resource sharing data : Use Request object
void setAttribute(String name,Object o) Store data to request domain
Object getAttribute(String name) according to key Get value
void removeAttribute(Sting name) according to key, Delete the key-value pair
Case study web-demo01


2、Response Implement redirection
response.sendRedirect("/web-demo01/resp02");Case study web-demo01

3、Cookie

4、Session
\
1 brand-demo The increased Delete It should all be used request Of
request.getRequestDispatcher("/selectAllServlet").forward(request,response);2 brand-demo The query uses Just save the data
// Package to request domain
request.setAttribute("brand",brand);
// forward
request.getRequestDispatcher("update.jsp").forward(request,response);3 brand-demo The login page of is
Landing successful Session Resource sharing
// session Shared resources
HttpSession session = request.getSession();
session.setAttribute("user",user);
// Implement redirection
response.sendRedirect("/brand-demo/selectAllServlet");I think of myself
// request.setAttribute("login_name", user.getUsername());
// request.getRequestDispatcher("/selectAllServlet").forward(request, response);Login failed It's using
// Store information to request Domain
request.setAttribute("login_msg", " Wrong user name or password ");
// forward
request.getRequestDispatcher("/login.jsp").forward(request, response);I think of myself
// HttpSession session = request.getSession();
// session.setAttribute("login_msg"," Wrong user name or password ");
// response.sendRedirect("/brand-demo/login.jsp");4 brand-demo The login page verification code of is Cookie
// The user checked remember user
Cookie c_username = new Cookie("username", username);
Cookie c_password = new Cookie("password", password);
// Remember the time
c_username.setMaxAge(60*60*24*7);
c_password.setMaxAge(60*60*24*7);
// send out Cookie
response.addCookie(c_username);
response.addCookie(c_password);边栏推荐
- Qt+vtk+pcl pictures are converted to grayscale images and displayed with grayscale as the Y axis
- 直播预告 | 开源安全治理模型和工具直播研讨会
- 机器学习笔记 - 基于深度学习(HomographyNet)的图像单应性估计
- ZABBIX agent creates monitoring items
- ASP. Net core creates MVC projects and uploads multiple files (streaming)
- 2022年中国软件产品全国巡回展即将启航
- 实验四 DPCM
- pip更新一个package
- text-align:center居中
- 数据库基础及安装
猜你喜欢
随机推荐
Scala学习——泛型[T]的6种使用
Qt+VTK+PCL图片转灰度图且以灰度为Y轴显示
Worthington:来自酵母的己糖激酶的特性及其它参数说明
Codeforces Round #809 (Div. 2)(C和D1两题)
Etcdv3 · watch operation implementation and relevant key instructions
Bottom compulsory of large factory: "communication realization between application program and AMS"
RN underlying principle -- 1. Component and purecomponent analysis
Worthington纯化酶制剂助力新生儿心肌细胞分离系统研究
Experiment 4 DPCM
大厂底层必修:“应用程序与 AMS 的通讯实现”
【读书笔记->统计学】12-01 置信区间的构建-置信区间概念简介
Spark疑难杂症排查-Premature EOF: no length prefix available
Experiment III LZW
初出茅庐的小李第109篇博客之如何打开Keil中文件的真是路径
[day 31] given an integer n, find the base and exponent of each prime factor | basic theorem of arithmetic
Worthington哺乳动物乳酸脱氢酶研究——特点及测定方案
初出茅庐的小李第110篇博客之详细剖析STM32中__NVIC_SetPriorityGrouping(uint32_t PriorityGroup)函数
Building a sylixos environment in VMWare
FastAPI学习(二)——FastAPI+Jinjia2模板渲染网页(跳转返回渲染页面)
The boss asked me to do an IP territorial function and an open source library!









