Java Reference
In-Depth Information
LISTING 21.2
Continued
35: out.println(“<p><input type=\”text\” name=\”color\” value=\”” +
36: pageColor + “\” SIZE=40>”);
37: out.println(“<p><input type=\”submit\” value=\”submit\”>”);
38: out.println(“</form>”);
39: out.println(“</body>”);
40: out.println(“</html>”);
41: }
42:
43: public void doGet(HttpServletRequest req, HttpServletResponse res)
44: throws ServletException, IOException {
45:
46: doPost(req, res);
47: }
48:
49: String translate(String input) {
50: StringBuffer output = new StringBuffer();
51: if (input != null) {
52: for (int i = 0; i < input.length(); i++) {
53: char inChar = input.charAt(i);
54: if ((inChar >= 'A') & (inChar <= 'Z')) {
55: inChar += 13;
56: if (inChar > 'Z')
57: inChar -= 26;
58: }
59: if ((inChar >= 'a') & (inChar <= 'z')) {
60: inChar += 13;
61: if (inChar > 'z')
62: inChar -= 26;
63: }
64: output.append(inChar);
65: }
66: }
67: return output.toString();
68: }
69:
70: String retrieveColor(Cookie[] cookies) {
71: String inColor = “#FFFFFF”;
72: for (int i = 0; i < cookies.length; i++) {
73: String cookieName = cookies[i].getName();
74: if (cookieName.equals(“color”)) {
75: inColor = cookies[i].getValue();
76: }
77: }
78: return inColor;
79: }
80: }
21
 
Search WWH ::




Custom Search