KickJava   Java API By Example, From Geeks To Geeks.

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


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.IOException JavaDoc;
14
15 import javax.servlet.ServletException JavaDoc;
16 import javax.servlet.http.HttpServlet JavaDoc;
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18 import javax.servlet.http.HttpServletResponse JavaDoc;
19
20 import org.eclipse.help.internal.base.BaseHelpSystem;
21 import org.eclipse.help.internal.webapp.data.WebappPreferences;
22
23 /**
24  * Servlet to handle live help action requests
25  */

26 public class LiveHelpServlet extends HttpServlet JavaDoc {
27     private static final long serialVersionUID = 1L;
28     /**
29      */

30     public void init() throws ServletException JavaDoc {
31         if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_INFOCENTER) {
32             throw new ServletException JavaDoc();
33         }
34     }
35
36     /**
37      * Called by the server (via the <code>service</code> method) to allow a
38      * servlet to handle a GET request.
39      */

40     protected void doGet(HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc resp)
41             throws ServletException JavaDoc, IOException JavaDoc {
42         if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_INFOCENTER) {
43             return;
44         }
45         if (!new WebappPreferences().isActiveHelp()) {
46             return;
47         }
48         req.setCharacterEncoding("UTF-8"); //$NON-NLS-1$
49
String JavaDoc pluginID = req.getParameter("pluginID"); //$NON-NLS-1$
50
if (pluginID == null)
51             return;
52         String JavaDoc className = req.getParameter("class"); //$NON-NLS-1$
53
if (className == null)
54             return;
55         String JavaDoc arg = req.getParameter("arg"); //$NON-NLS-1$
56
BaseHelpSystem.runLiveHelp(pluginID, className, arg);
57     }
58     /**
59      *
60      * Called by the server (via the <code>service</code> method) to allow a
61      * servlet to handle a POST request.
62      *
63      * Handle the search requests,
64      *
65      */

66     protected void doPost(HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc resp)
67             throws ServletException JavaDoc, IOException JavaDoc {
68         doGet(req, resp);
69     }
70 }
71
Popular Tags