-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetCookies.java
More file actions
26 lines (22 loc) · 870 Bytes
/
GetCookies.java
File metadata and controls
26 lines (22 loc) · 870 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
package javaEE.cookies;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
public class GetCookies extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Cookie[] cookie = request.getCookies();
PrintWriter pw = response.getWriter();
pw.println("<html>");
for (Cookie cookies : cookie){
pw.println("<h1>" + "cookies.getName() " + cookies.getName() +"</h1>");
pw.println("<h1>" + "cookies.getValue() " + cookies.getValue() +"</h1>");
}
pw.println("</html>");
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}