(HttpServletRequest request, HttpServletResponse response)
| 36 | private static final long serialVersionUID = 1L; |
| 37 | |
| 38 | @Override |
| 39 | public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
| 40 | ResourceBundle rb = ResourceBundle.getBundle("LocalStrings", request.getLocale()); |
| 41 | |
| 42 | String cookieName = request.getParameter("cookiename"); |
| 43 | String cookieValue = request.getParameter("cookievalue"); |
| 44 | Cookie aCookie = null; |
| 45 | if (cookieName != null && cookieValue != null) { |
| 46 | aCookie = new Cookie(cookieName, cookieValue); |
| 47 | aCookie.setPath(request.getContextPath() + "/"); |
| 48 | response.addCookie(aCookie); |
| 49 | } |
| 50 | |
| 51 | response.setContentType("text/html"); |
| 52 | response.setCharacterEncoding("UTF-8"); |
| 53 | |
| 54 | PrintWriter out = response.getWriter(); |
| 55 | out.println("<!DOCTYPE html><html>"); |
| 56 | out.println("<head>"); |
| 57 | out.println("<meta charset=\"UTF-8\" />"); |
| 58 | |
| 59 | String title = rb.getString("cookies.title"); |
| 60 | out.println("<title>" + title + "</title>"); |
| 61 | out.println("</head>"); |
| 62 | out.println("<body bgcolor=\"white\">"); |
| 63 | |
| 64 | out.println("<a href=\"../cookies.html\">"); |
| 65 | out.println( |
| 66 | "<img src=\"../images/code.gif\" height=24 " + "width=24 align=right border=0 alt=\"view code\"></a>"); |
| 67 | out.println("<a href=\"../index.html\">"); |
| 68 | out.println( |
| 69 | "<img src=\"../images/return.gif\" height=24 " + "width=24 align=right border=0 alt=\"return\"></a>"); |
| 70 | |
| 71 | out.println("<h3>" + title + "</h3>"); |
| 72 | |
| 73 | Cookie[] cookies = request.getCookies(); |
| 74 | if ((cookies != null) && (cookies.length > 0)) { |
| 75 | HttpSession session = request.getSession(false); |
| 76 | String sessionId = null; |
| 77 | if (session != null) { |
| 78 | sessionId = session.getId(); |
| 79 | } |
| 80 | out.println(rb.getString("cookies.cookies") + "<br>"); |
| 81 | for (Cookie cookie : cookies) { |
| 82 | String cName = cookie.getName(); |
| 83 | String cValue = cookie.getValue(); |
| 84 | out.print("Cookie Name: " + HTMLFilter.filter(cName) + "<br>"); |
| 85 | out.println(" Cookie Value: " + HTMLFilter.filter(CookieFilter.filter(cName, cValue, sessionId)) + |
| 86 | "<br><br>"); |
| 87 | } |
| 88 | } else { |
| 89 | out.println(rb.getString("cookies.no-cookies")); |
| 90 | } |
| 91 | |
| 92 | if (aCookie != null) { |
| 93 | out.println("<P>"); |
| 94 | out.println(rb.getString("cookies.set") + "<br>"); |
| 95 | out.print(rb.getString("cookies.name") + " " + HTMLFilter.filter(cookieName) + "<br>"); |
no test coverage detected