Lines 14-19
Link Here
|
14 |
* Example servlet showing request headers |
14 |
* Example servlet showing request headers |
15 |
* |
15 |
* |
16 |
* @author James Duncan Davidson <duncan@eng.sun.com> |
16 |
* @author James Duncan Davidson <duncan@eng.sun.com> |
|
|
17 |
* @author Stefan Radzom |
17 |
*/ |
18 |
*/ |
18 |
|
19 |
|
19 |
public class CookieExample extends HttpServlet { |
20 |
public class CookieExample extends HttpServlet { |
Lines 26-31
Link Here
|
26 |
{ |
27 |
{ |
27 |
response.setContentType("text/html"); |
28 |
response.setContentType("text/html"); |
28 |
|
29 |
|
|
|
30 |
String cookieName = request.getParameter("cookiename"); |
31 |
String cookieValue = request.getParameter("cookievalue"); |
32 |
Cookie aCookie = null; |
33 |
if (cookieName != null && cookieValue != null) { |
34 |
aCookie = new Cookie(cookieName, cookieValue); |
35 |
response.addCookie(aCookie); |
36 |
} |
37 |
|
29 |
PrintWriter out = response.getWriter(); |
38 |
PrintWriter out = response.getWriter(); |
30 |
out.println("<html>"); |
39 |
out.println("<html>"); |
31 |
out.println("<body bgcolor=\"white\">"); |
40 |
out.println("<body bgcolor=\"white\">"); |
Lines 66-76
Link Here
|
66 |
out.println(rb.getString("cookies.no-cookies")); |
75 |
out.println(rb.getString("cookies.no-cookies")); |
67 |
} |
76 |
} |
68 |
|
77 |
|
69 |
String cookieName = request.getParameter("cookiename"); |
78 |
if (aCookie != null) { |
70 |
String cookieValue = request.getParameter("cookievalue"); |
|
|
71 |
if (cookieName != null && cookieValue != null) { |
72 |
Cookie cookie = new Cookie(cookieName, cookieValue); |
73 |
response.addCookie(cookie); |
74 |
out.println("<P>"); |
79 |
out.println("<P>"); |
75 |
out.println(rb.getString("cookies.set") + "<br>"); |
80 |
out.println(rb.getString("cookies.set") + "<br>"); |
76 |
out.print(rb.getString("cookies.name") + " " |
81 |
out.print(rb.getString("cookies.name") + " " |