home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-07-27 | 3.5 KB | 105 lines |
- package com.ibm.ivj.toolserver.samples;
-
- // Licensed Material - Property of IBM
- // IBM(R) VisualAge(R) for Java(TM), Version 3.0
- // (C) Copyright IBM Corp. 1997, 1999 - All Rights Reserved.
- // US Government Users Restricted Rights - Use, duplication or disclosure
- // restricted by GSA ADP Schedule Contract with IBM Corp.
- // Licensed Material - Property of IBM
- // (C) Copyright IBM Corp. 1997, 1999 - All Rights Reserved
- // DISCLAIMER:
- // The following [enclosed] code is sample code created by IBM
- // Corporation. This sample code is not part of any standard IBM product
- // and is provided to you solely for the purpose of assisting you in the
- // development of your applications. The code is provided 'AS IS',
- // without warranty or condition of any kind. IBM shall not be liable for any damages
- // arising out of your use of the sample code, even if IBM has been
- // advised of the possibility of such damages.
-
- import com.ibm.ivj.toolserver.servletclasses.servlet.*;
- import com.ibm.ivj.toolserver.servletclasses.servlet.http.*;
- import com.ibm.ivj.toolserver.server.servlet.http.*;
- import com.ibm.ivj.toolserver.server.servlet.*;
- import com.ibm.ivj.util.base.*;
- import java.io.*;
- import java.util.*;
-
-
- /**
- * Launches a VisualAge for Java class browser on a class.
- * <p>
- * Usage: http://localhost:<port>/servlet/com.ibm.ivj.toolserver.samples.LaunchBrowserServlet?project=<project>&type=<type>
- */
-
- public class LaunchBrowserServlet extends HttpServlet {
- private ResourceBundle bundle;
- public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
-
- res.setContentType("text/html");
- PrintWriter os = res.getWriter();
-
-
- if (bundle==null) {
- try {
- bundle = ResourceBundle.getBundle("com.ibm.ivj.toolserver.samples.SamplesBundle");
- } catch (MissingResourceException mre) {
- os.println(mre.getMessage());
- return;
- }
- }
-
- os.println("<title>"+bundle.getString("TitleLaunch")+"</title>");
- os.println("<h3>"+bundle.getString("TitleLaunch")+"</h3>");
-
- String typeName= req.getParameter("type");
- String projectName = req.getParameter("project");
-
- if ((typeName==null) || (typeName.equals(""))) {
- os.println("<p>"+bundle.getString("ErrorBadParametersType"));
- return;
- }
-
- if ((projectName==null) || (projectName.equals(""))) {
- os.println("<p>"+bundle.getString("ErrorBadParametersProject"));
- return;
- }
-
- os.println("<p>"+bundle.getString("InfoConnect"));
- Workspace workspace = ToolEnv.connectToWorkspace();
- if (workspace == null) {
- os.println("<p>"+bundle.getString("ErrorConnect"));
- return;
- }
-
-
- os.println("<p>"+bundle.getString("InfoFindProject"));
- Project project = workspace.loadedProjectNamed(projectName);
- if (project == null) {
- os.println("<p>"+bundle.getString("ErrorFindProject"));
- return;
- }
- os.println("<p>"+bundle.getString("InfoFindType"));
- Type type = workspace.loadedTypeNamed(typeName);
- if (type == null) {
- os.println("<p>"+bundle.getString("ErrorFindType"));
- return;
- }
-
- try {
- os.println("<p>"+bundle.getString("InfoLaunchBrowser"));
- type.openBrowser();
- os.println("<p>"+bundle.getString("LaunchSucceeded"));
- } catch (IvjException e) {
- os.println("<p>"+bundle.getString("ErrorLaunchBrowser")+e);
- return;
- }
-
- }
- public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
- doGet(req, res);
- }
- public String getServletInfo() {
- return "HTTP servlet that launches launches a VisualAge for Java class browser.";
- }
- }
-