-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathLogoutServlet.java
More file actions
32 lines (26 loc) · 801 Bytes
/
LogoutServlet.java
File metadata and controls
32 lines (26 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.io.IOException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
/**
* Java servlet for logging out the account and displaying the welcome page.
*
* @author Emma He
*/
public class LogoutServlet extends HttpServlet {
/*
* (non-Javadoc)
*
* * @see
* javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*
* Invalidate the session and redirect to the welcome page
*/
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
req.getSession().invalidate();
res.sendRedirect("/welcome");
}
}