01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.server.ui;
17:
18: import java.io.BufferedReader;
19: import java.io.IOException;
20:
21: import javax.servlet.ServletException;
22: import javax.servlet.http.HttpServlet;
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.http.HttpServletResponse;
25:
26: /**
27: * Servlet for use with {@link FormPanelTest}.
28: */
29: public class FormPanelTestServlet extends HttpServlet {
30:
31: protected void doGet(HttpServletRequest req, HttpServletResponse rsp)
32: throws ServletException, IOException {
33:
34: rsp.setContentType("text/html");
35:
36: String query = req.getQueryString();
37: if (query != null) {
38: // Echo the query string.
39: rsp.getWriter().write(query);
40: }
41: }
42:
43: protected void doPost(HttpServletRequest req,
44: HttpServletResponse rsp) throws ServletException,
45: IOException {
46:
47: rsp.setContentType("text/html");
48:
49: String query = req.getQueryString();
50: if (query != null) {
51: if (query.equals("sendHappyHtml")) {
52: rsp
53: .getWriter()
54: .write(
55: "<html><body><div id=':)'></div></body></html>");
56: return;
57: }
58: }
59:
60: // Read the request content.
61: BufferedReader reader = req.getReader();
62: char[] buf = new char[req.getContentLength()];
63: reader.read(buf, 0, req.getContentLength());
64:
65: // Echo the request content.
66: rsp.getWriter().write(buf);
67: }
68: }
|