KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > webapp > servlet > ContentServlet


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.internal.webapp.servlet;
12
13 import java.io.*;
14
15 import javax.servlet.*;
16 import javax.servlet.http.*;
17 /**
18  * Servlet to interface client with remote Eclipse
19  */

20 public class ContentServlet extends HttpServlet {
21     private static final long serialVersionUID = 1L;
22     private EclipseConnector connector;
23
24     /**
25      */

26     public void init() throws ServletException {
27         try {
28             connector = new EclipseConnector(getServletContext());
29         } catch (Throwable JavaDoc e) {
30             throw new ServletException(e);
31         }
32     }
33
34     /**
35      * Called by the server (via the <code>service</code> method) to allow a
36      * servlet to handle a GET request.
37      */

38     protected void doGet(HttpServletRequest req, HttpServletResponse resp)
39             throws ServletException, IOException {
40         req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
41
if (connector != null) {
42             connector.transfer(req, resp);
43         }
44     }
45     /**
46      *
47      * Called by the server (via the <code>service</code> method) to allow a
48      * servlet to handle a POST request.
49      *
50      * Handle the search requests,
51      *
52      */

53     protected void doPost(HttpServletRequest req, HttpServletResponse resp)
54             throws ServletException, IOException {
55         if (connector != null)
56             connector.transfer(req, resp);
57     }
58 }
59
Popular Tags