File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ For Java Security
4
4
5
5
* [ Custom Error Page] ( #Custom-Error )
6
6
* [ Restrict File to Access] ( #forbidden )
7
+ * [ Broken Session Managment] ( #Session-fix )
7
8
8
9
9
10
@@ -31,3 +32,24 @@ Create web.xml and insert below code
31
32
## forbid.jsp is location of custom error page
32
33
33
34
```
35
+ ## Session-fix
36
+
37
+ using session
38
+
39
+ ```
40
+ request.getSession(false).invalidate();
41
+ HttpSession session = request.getSession(true);
42
+
43
+ session.setAttribute("uname", uname);
44
+ session.setAttribute("pass", pass);
45
+
46
+ response.sendRedirect("welcome.jsp");
47
+ ```
48
+
49
+ on logout
50
+ ```
51
+ HttpSession session = request.getSession();
52
+ session.removeAttribute("uname");
53
+ session.invalidate();
54
+ response.sendRedirect("login.jsp");
55
+ ```
You can’t perform that action at this time.
0 commit comments