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. *

* 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(""+bundle.getString("TitleLaunch")+""); os.println("

"+bundle.getString("TitleLaunch")+"

"); String typeName= req.getParameter("type"); String projectName = req.getParameter("project"); if ((typeName==null) || (typeName.equals(""))) { os.println("

"+bundle.getString("ErrorBadParametersType")); return; } if ((projectName==null) || (projectName.equals(""))) { os.println("

"+bundle.getString("ErrorBadParametersProject")); return; } os.println("

"+bundle.getString("InfoConnect")); Workspace workspace = ToolEnv.connectToWorkspace(); if (workspace == null) { os.println("

"+bundle.getString("ErrorConnect")); return; } os.println("

"+bundle.getString("InfoFindProject")); Project project = workspace.loadedProjectNamed(projectName); if (project == null) { os.println("

"+bundle.getString("ErrorFindProject")); return; } os.println("

"+bundle.getString("InfoFindType")); Type type = workspace.loadedTypeNamed(typeName); if (type == null) { os.println("

"+bundle.getString("ErrorFindType")); return; } try { os.println("

"+bundle.getString("InfoLaunchBrowser")); type.openBrowser(); os.println("

"+bundle.getString("LaunchSucceeded")); } catch (IvjException e) { os.println("

"+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."; } }