• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Libphonenumber Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * @author Philippe Liard
17  */
18 
19 package com.google.i18n.phonenumbers;
20 
21 import java.io.ByteArrayInputStream;
22 import java.io.IOException;
23 
24 import javax.servlet.http.HttpServlet;
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.http.HttpServletResponse;
27 
28 /**
29  * A servlet that invokes the geocoding data combination tool.
30  */
31 public class CombineGeoDataServlet extends HttpServlet {
32   @Override
doPost(HttpServletRequest req, HttpServletResponse resp)33   public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
34     resp.setContentType("text/html;charset=UTF-8");
35     String input = req.getParameter("geodata");
36     resp.getOutputStream().print("<html><head>");
37     resp.getOutputStream().print(
38         "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"></head>");
39     resp.getOutputStream().print("<body>");
40     CombineGeoData combineGeoData = new CombineGeoData(
41         new ByteArrayInputStream(input.getBytes()), resp.getOutputStream(), "<br>");
42     combineGeoData.run();
43     resp.getOutputStream().print("</body></html>");
44     resp.getOutputStream().flush();
45   }
46 }
47