Example usage for javax.servlet ServletContext getRealPath

List of usage examples for javax.servlet ServletContext getRealPath

Introduction

In this page you can find the example usage for javax.servlet ServletContext getRealPath.

Prototype

public String getRealPath(String path);

Source Link

Document

Gets the real path corresponding to the given virtual path.

Usage

From source file:org.red5.server.tomcat.TomcatLoader.java

/**
 * Starts a web application and its red5 (spring) component. This is
 * basically a stripped down version of init().
 * //  w w  w . j av  a  2  s  .  c  o  m
 * @return true on success
 */
public boolean startWebApplication(String applicationName) {
    log.info("Starting Tomcat - Web application");
    boolean result = false;

    //get a reference to the current threads classloader
    final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();

    log.debug("Webapp root: {}", webappFolder);

    // application directory
    String contextName = '/' + applicationName;

    Container ctx = null;

    if (webappFolder == null) {
        // Use default webapps directory
        webappFolder = System.getProperty("red5.root") + "/webapps";
    }
    System.setProperty("red5.webapp.root", webappFolder);
    log.info("Application root: {}", webappFolder);

    // scan for additional webapp contexts

    // Root applications directory
    File appDirBase = new File(webappFolder);

    // check if the context already exists for the host
    if ((ctx = host.findChild(contextName)) == null) {
        log.debug("Context did not exist in host");
        String webappContextDir = FileUtil.formatPath(appDirBase.getAbsolutePath(), applicationName);
        log.debug("Webapp context directory (full path): {}", webappContextDir);
        // set the newly created context as the current container
        ctx = addContext(contextName, webappContextDir);
    } else {
        log.debug("Context already exists in host");
    }

    final ServletContext servletContext = ((Context) ctx).getServletContext();
    log.debug("Context initialized: {}", servletContext.getContextPath());

    String prefix = servletContext.getRealPath("/");
    log.debug("Path: {}", prefix);

    try {
        Loader cldr = ctx.getLoader();
        log.debug("Loader delegate: {} type: {}", cldr.getDelegate(), cldr.getClass().getName());
        if (cldr instanceof WebappLoader) {
            log.debug("WebappLoader class path: {}", ((WebappLoader) cldr).getClasspath());
        }
        final ClassLoader webClassLoader = cldr.getClassLoader();
        log.debug("Webapp classloader: {}", webClassLoader);

        // get the (spring) config file path
        final String contextConfigLocation = servletContext.getInitParameter("contextConfigLocation") == null
                ? defaultSpringConfigLocation
                : servletContext.getInitParameter("contextConfigLocation");
        log.debug("Spring context config location: {}", contextConfigLocation);

        // get the (spring) parent context key
        final String parentContextKey = servletContext.getInitParameter("parentContextKey") == null
                ? defaultParentContextKey
                : servletContext.getInitParameter("parentContextKey");
        log.debug("Spring parent context key: {}", parentContextKey);

        //set current threads classloader to the webapp classloader
        Thread.currentThread().setContextClassLoader(webClassLoader);

        //create a thread to speed-up application loading
        Thread thread = new Thread("Launcher:" + servletContext.getContextPath()) {
            @SuppressWarnings("cast")
            public void run() {
                //set current threads classloader to the webapp classloader
                Thread.currentThread().setContextClassLoader(webClassLoader);

                // create a spring web application context
                XmlWebApplicationContext appctx = new XmlWebApplicationContext();
                appctx.setClassLoader(webClassLoader);
                appctx.setConfigLocations(new String[] { contextConfigLocation });

                // check for red5 context bean
                ApplicationContext parentAppCtx = null;

                if (applicationContext.containsBean(defaultParentContextKey)) {
                    parentAppCtx = (ApplicationContext) applicationContext.getBean(defaultParentContextKey);
                } else {
                    log.warn("{} bean was not found in context: {}", defaultParentContextKey,
                            applicationContext.getDisplayName());
                    // lookup context loader and attempt to get what we need from it
                    if (applicationContext.containsBean("context.loader")) {
                        ContextLoader contextLoader = (ContextLoader) applicationContext
                                .getBean("context.loader");
                        parentAppCtx = contextLoader.getContext(defaultParentContextKey);
                    } else {
                        log.debug("Context loader was not found, trying JMX");
                        MBeanServer mbs = JMXFactory.getMBeanServer();
                        // get the ContextLoader from jmx
                        ObjectName oName = JMXFactory.createObjectName("type", "ContextLoader");
                        ContextLoaderMBean proxy = null;
                        if (mbs.isRegistered(oName)) {
                            proxy = (ContextLoaderMBean) MBeanServerInvocationHandler.newProxyInstance(mbs,
                                    oName, ContextLoaderMBean.class, true);
                            log.debug("Context loader was found");
                            parentAppCtx = proxy.getContext(defaultParentContextKey);
                        } else {
                            log.warn("Context loader was not found");
                        }
                    }
                }
                if (log.isDebugEnabled()) {
                    if (appctx.getParent() != null) {
                        log.debug("Parent application context: {}", appctx.getParent().getDisplayName());
                    }
                }

                appctx.setParent(parentAppCtx);

                appctx.setServletContext(servletContext);
                // set the root webapp ctx attr on the each
                // servlet context so spring can find it later
                servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
                        appctx);
                appctx.refresh();
            }
        };
        thread.setDaemon(true);
        thread.start();

        result = true;
    } catch (Throwable t) {
        log.error("Error setting up context: {} due to: {}", servletContext.getContextPath(), t.getMessage());
        t.printStackTrace();
    } finally {
        //reset the classloader
        Thread.currentThread().setContextClassLoader(originalClassLoader);
    }

    return result;
}

From source file:com.dominion.salud.pedicom.configuration.PEDICOMInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.dominion.salud.pedicom.configuration");
    ctx.setServletContext(servletContext);
    PEDICOMConstantes._NOMBRE_CONFIG = servletContext.getInitParameter("NOMBRE_CONFIG");
    System.setProperty("pedicom.conf.home", findConfigurationAndLogger(ctx));
    ctx.refresh();// w  w w. j a  va  2 s.com

    // Spring Dispatcher
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(ctx));
    dispatcher.setInitParameter("contextClass", ctx.getClass().getName());
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/");
    dispatcher.addMapping("/controller/*");
    servletContext.addListener(new ContextLoaderListener(ctx));

    // Configuracion general
    PEDICOMConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator)
            ? servletContext.getRealPath("/")
            : servletContext.getRealPath("/") + File.separator;
    PEDICOMConstantes._CONF_HOME = ctx.getEnvironment().getProperty("pedicom.conf.home");
    PEDICOMConstantes._TEMP = PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "temp" + File.separator;
    PEDICOMConstantes._VERSION = ResourceBundle.getBundle("version").getString("version");
    PEDICOMConstantes._LOGS = PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator
            + "logs";
    PEDICOMConstantes._CONTEXT_NAME = servletContext.getServletContextName();
    PEDICOMConstantes._CONTEXT_PATH = servletContext.getContextPath();
    PEDICOMConstantes._CONTEXT_SERVER = servletContext.getServerInfo();
    PEDICOMConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank(
            ResourceBundle.getBundle("application").getString("pedicom.enable.technical.information"))
                    ? Boolean.parseBoolean(ResourceBundle.getBundle("application")
                            .getString("pedicom.enable.technical.information"))
                    : false;
    PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = StringUtils
            .isNotBlank(ResourceBundle.getBundle("application").getString("pedicom_scheduler_send_mail_cron"))
                    ? PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = ResourceBundle.getBundle("application")
                            .getString("pedicom_scheduler_send_mail_cron")
                    : PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON;
    PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON = StringUtils.isNotBlank(
            ResourceBundle.getBundle("application").getString("pedicom_scheduler_update_existencias_cron"))
                    ? PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON = ResourceBundle.getBundle("application")
                            .getString("pedicom_scheduler_update_existencias_cron")
                    : PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON;

    // Configuracion de LOGS DEL MODULO
    if (StringUtils.isBlank(
            ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())) {
        ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE"))
                .setFile(PEDICOMConstantes._HOME + "WEB-INF" + File.separator + "classes" + File.separator
                        + "logs" + File.separator + "mpr-desktop.log");
    }
    PEDICOMConstantes._LOGS = new File(
            ((FileAppender) org.apache.log4j.Logger.getRootLogger().getAppender("LOGFILE")).getFile())
                    .getParent();

    Environment env = ctx.getEnvironment();

    XmlUnmarshaler xml = new XmlUnmarshaler();
    Datos datos = (Datos) xml.unmarshal();
    logger.info("          Datasources");
    for (Datasources dat : datos.getDatasources()) {
        if (dat.getNombreDatasource().equals("Central")) {
            PEDICOMConstantes.EXISTENCIAS_EXISTE = true;
        }
        logger.info("               codCentro: " + dat.getCodCentro());
        logger.info("               nombreDatasource: " + dat.getNombreDatasource());
        logger.info("               driverClassName: " + dat.getDriverClassName());
        logger.info("               jndi: " + dat.getJndi());
        logger.info("               url: " + dat.getUrl());
        logger.info("               username: " + dat.getUsername());
        logger.info("               usernameEmail: " + dat.getUsernameEmail());
        logger.info("               passwordEmail: " + dat.getPasswordEmail());
        logger.info("               from: " + dat.getFrom());
        logger.info("               host: " + dat.getHost());
        logger.info("               port: " + dat.getPort());
        logger.info("               TLS: " + dat.getTLS());
        logger.info("               SSL: " + dat.getSSL());
    }
    //        ctx.refresh();
    //        PropertyConfigurator.configureAndWatch("log4j");

    logger.info("          Configuracion general del sistema");
    logger.info("               pedicom.home: " + PEDICOMConstantes._HOME);
    logger.info("               pedicom.conf.home: " + PEDICOMConstantes._CONF_HOME);
    logger.info("               pedicom.temp: " + PEDICOMConstantes._TEMP);
    logger.info("               pedicom.version: " + PEDICOMConstantes._VERSION);
    logger.info("               pedicom.logs: " + PEDICOMConstantes._LOGS);
    logger.info("               pedicom.context.name: " + PEDICOMConstantes._CONTEXT_NAME);
    logger.info("               pedicom.context.path: " + PEDICOMConstantes._CONTEXT_PATH);
    logger.info("               pedicom.context.server: " + PEDICOMConstantes._CONTEXT_SERVER);
    logger.info("          Parametrizacion del sistema");
    logger.info("               pedicom.enable.technical.information: "
            + PEDICOMConstantes._ENABLE_TECHNICAL_INFORMATION);
    logger.info(
            "               pedicom_scheduler_send_mail_cron: " + PEDICOMConstantes._SCHEDULER_SEND_MAIL_CRON);
    logger.info("               pedicom_scheduler_update_existencias_cron: "
            + PEDICOMConstantes._SCHEDULER_UPDATE_EXISTENCIAS_CRON);
    logger.info("     Modulo configurado correctamente");
    logger.info("MODULO INICIADO CORRECTAMENTE");
}

From source file:com.netspective.sparx.navigate.NavigationControllerServlet.java

/**
 * Initializes the web resource locators to the following:
 * - APP_ROOT/resources/sparx (will only exist if user is overriding any defaults)
 * - APP_ROOT/sparx (will exist in ITE mode when sparx directory is inside application)
 * - [CLASS_PATH]/Sparx/resources (only useful during development in SDE, not production since it won't be found)
 * TODO: this method is _not_ thread-safe because two requests could call the method at the same time FIX IT
 *//*from  www  .j  a v a2 s  . com*/
protected UriAddressableFileLocator getResourceLocator(HttpServletRequest request) throws ServletException {
    if (resourceLocator != null)
        return resourceLocator;

    ServletContext servletContext = getServletContext();
    try {
        String[] webAppLocations = TextUtils.getInstance().split(servletOptions.getSparxResourceLocators(), ",",
                false);
        List locators = new ArrayList();
        for (int i = 0; i < webAppLocations.length; i++) {
            String webAppRelativePath = webAppLocations[i];
            File webAppPhysicalDir = new File(servletContext.getRealPath(webAppRelativePath));
            if (webAppPhysicalDir.exists() && webAppPhysicalDir.isDirectory())
                locators.add(new UriAddressableInheritableFileResource(
                        request.getContextPath() + webAppRelativePath, webAppPhysicalDir, isCacheComponents()));
        }

        // this will only match the SDE development environment
        FileFind.FileFindResults ffResults = FileFind.findInClasspath("Sparx/resources",
                FileFind.FINDINPATHFLAG_DEFAULT);
        if (ffResults.isFileFound() && ffResults.getFoundFile().isDirectory())
            locators.add(new UriAddressableInheritableFileResource(request.getContextPath() + "/sparx",
                    ffResults.getFoundFile(), isCacheComponents()));

        if (log.isDebugEnabled()) {
            for (int i = 0; i < locators.size(); i++)
                log.debug("Registered web resources locator " + locators.get(i));
        }

        if (locators.size() == 0)
            System.err.println("Unable to register any web resource locators ("
                    + TextUtils.getInstance().join(webAppLocations, ", ")
                    + " were not found). Please use the SparxResourcesServlet for serving Sparx resources.");

        // this will allow serving up files directly from the JAR (assuming the SparxResourcesServlet is available for serving those files)
        final File jarFile = new File(servletContext.getRealPath("WEB-INF/lib/netspective-sparx.jar"));
        if (jarFile.exists())
            locators.add(new UriAddressableSparxJarResourceLocator(request.getContextPath() + "/sparx",
                    new ZipFile(jarFile)));

        resourceLocator = new MultipleUriAddressableFileLocators(
                (UriAddressableFileLocator[]) locators.toArray(new UriAddressableFileLocator[locators.size()]),
                isCacheComponents());
        return resourceLocator;
    } catch (IOException e) {
        log.error("error initializing resource locator", e);
        throw new ServletException(e);
    }
}

From source file:org.opentaps.common.util.UtilCommon.java

/**
 * Gets the absolute path to the given file according to the servlet context.
 * Files are in /runtime/output/ and we get there from the servlet context path.
 * @param servletContext a <code>ServletContext</code> value
 * @param filename a <code>String</code> value
 * @return the absolute path/*from www .  ja  v  a  2 s  .c  o  m*/
 */
public static String getAbsoluteFilePath(ServletContext servletContext, final String filename) {
    String rootPath;

    // JBoss is a special case as the directory structure is a bit different than with the embedded tomcat server
    if (servletContext.getServerInfo().toLowerCase().contains("jboss")) {
        rootPath = servletContext.getRealPath("../");
    } else {
        rootPath = servletContext.getRealPath("../../../../");
    }

    String filePath = "/runtime/output/";
    return rootPath + filePath + filename;
}

From source file:org.apache.struts2.views.velocity.VelocityManager.java

/**
 * once we've loaded up the user defined configurations, we will want to apply Struts specification configurations.
 * <ul>/*from  w  w w.j a  va2  s  .  co m*/
 * <li>if Velocity.RESOURCE_LOADER has not been defined, then we will use the defaults which is a joined file,
 * class loader for unpackaed wars and a straight class loader otherwise</li>
 * <li>we need to define the various Struts custom user directives such as #param, #tag, and #bodytag</li>
 * </ul>
 *
 * @param context
 * @param p
 */
private void applyDefaultConfiguration(ServletContext context, Properties p) {
    // ensure that caching isn't overly aggressive

    /**
     * Load a default resource loader definition if there isn't one present.
     * Ben Hall (22/08/2003)
     */
    if (p.getProperty(Velocity.RESOURCE_LOADER) == null) {
        p.setProperty(Velocity.RESOURCE_LOADER, "strutsfile, strutsclass");
    }

    /**
     * If there's a "real" path add it for the strutsfile resource loader.
     * If there's no real path and they haven't configured a loader then we change
     * resource loader property to just use the strutsclass loader
     * Ben Hall (22/08/2003)
     */
    if (context.getRealPath("") != null) {
        p.setProperty("strutsfile.resource.loader.description", "Velocity File Resource Loader");
        p.setProperty("strutsfile.resource.loader.class",
                "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
        p.setProperty("strutsfile.resource.loader.path", context.getRealPath(""));
        p.setProperty("strutsfile.resource.loader.modificationCheckInterval", "2");
        p.setProperty("strutsfile.resource.loader.cache", "true");
    } else {
        // remove strutsfile from resource loader property
        String prop = p.getProperty(Velocity.RESOURCE_LOADER);
        if (prop.indexOf("strutsfile,") != -1) {
            prop = replace(prop, "strutsfile,", "");
        } else if (prop.indexOf(", strutsfile") != -1) {
            prop = replace(prop, ", strutsfile", "");
        } else if (prop.indexOf("strutsfile") != -1) {
            prop = replace(prop, "strutsfile", "");
        }

        p.setProperty(Velocity.RESOURCE_LOADER, prop);
    }

    /**
     * Refactored the Velocity templates for the Struts taglib into the classpath from the web path.  This will
     * enable Struts projects to have access to the templates by simply including the Struts jar file.
     * Unfortunately, there does not appear to be a macro for the class loader keywords
     * Matt Ho - Mon Mar 17 00:21:46 PST 2003
     */
    p.setProperty("strutsclass.resource.loader.description", "Velocity Classpath Resource Loader");
    p.setProperty("strutsclass.resource.loader.class",
            "org.apache.struts2.views.velocity.StrutsResourceLoader");
    p.setProperty("strutsclass.resource.loader.modificationCheckInterval", "2");
    p.setProperty("strutsclass.resource.loader.cache", "true");

    // components
    StringBuilder sb = new StringBuilder();

    for (TagLibrary tagLibrary : tagLibraries) {
        List<Class> directives = tagLibrary.getVelocityDirectiveClasses();
        for (Class directive : directives) {
            addDirective(sb, directive);
        }
    }

    String directives = sb.toString();

    String userdirective = p.getProperty("userdirective");
    if ((userdirective == null) || userdirective.trim().equals("")) {
        userdirective = directives;
    } else {
        userdirective = userdirective.trim() + "," + directives;
    }

    p.setProperty("userdirective", userdirective);
}

From source file:com.dominion.salud.nomenclator.configuration.NOMENCLATORInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
    ctx.scan("com.dominion.salud.nomenclator.configuration");
    ctx.setServletContext(servletContext);
    ctx.refresh();/*from w ww .  j  a  v a 2s . com*/

    logger.info("     Registrando servlets de configuracion");
    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(ctx));
    dispatcher.setInitParameter("contextClass", ctx.getClass().getName());
    dispatcher.setLoadOnStartup(1);
    logger.info("          Agregando mapping: /");
    dispatcher.addMapping("/");
    logger.info("          Agregando mapping: /controller/*");
    dispatcher.addMapping("/controller/*");
    logger.info("          Agregando mapping: /services/*");
    dispatcher.addMapping("/services/*");
    servletContext.addListener(new ContextLoaderListener(ctx));
    logger.info("     Servlets de configuracion registrados correctamente");

    // Configuracion general
    logger.info("     Iniciando la configuracion del modulo");
    NOMENCLATORConstantes._HOME = StringUtils.endsWith(servletContext.getRealPath("/"), File.separator)
            ? servletContext.getRealPath("/")
            : servletContext.getRealPath("/") + File.separator;
    NOMENCLATORConstantes._TEMP = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "temp"
            + File.separator;
    NOMENCLATORConstantes._VERSION = ResourceBundle.getBundle("version").getString("version");
    NOMENCLATORConstantes._LOGS = NOMENCLATORConstantes._HOME + "WEB-INF" + File.separator + "classes"
            + File.separator + "logs";
    NOMENCLATORConstantes._CONTEXT_NAME = servletContext.getServletContextName();
    NOMENCLATORConstantes._CONTEXT_PATH = servletContext.getContextPath();
    NOMENCLATORConstantes._CONTEXT_SERVER = servletContext.getServerInfo();
    NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION = StringUtils.isNotBlank(
            ResourceBundle.getBundle("application").getString("nomenclator.enable.technical.information"))
                    ? Boolean.parseBoolean(ResourceBundle.getBundle("application")
                            .getString("nomenclator.enable.technical.information"))
                    : false;
    PropertyConfigurator.configureAndWatch("log4j");

    logger.info("          Configuracion general del sistema");
    logger.info("               nomenclator.home: " + NOMENCLATORConstantes._HOME);
    logger.info("               nomenclator.temp: " + NOMENCLATORConstantes._TEMP);
    logger.info("               nomenclator.version: " + NOMENCLATORConstantes._VERSION);
    logger.info("               nomenclator.logs: " + NOMENCLATORConstantes._LOGS);
    logger.info("               nomenclator.context.name: " + NOMENCLATORConstantes._CONTEXT_NAME);
    logger.info("               nomenclator.context.path: " + NOMENCLATORConstantes._CONTEXT_PATH);
    logger.info("               nomenclator.context.server: " + NOMENCLATORConstantes._CONTEXT_SERVER);
    logger.info("          Parametrizacion del sistema");
    logger.info("               nomenclator.enable.technical.information: "
            + NOMENCLATORConstantes._ENABLE_TECHNICAL_INFORMATION);
    logger.info("     Modulo configurado correctamente");
    logger.info("MODULO INICIADO CORRECTAMENTE");
}

From source file:com.tohours.imo.module.AttractModule.java

private String getRealPath(String path) {
    ServletContext sc = Mvcs.getServletContext();
    return sc.getRealPath(path);
}

From source file:org.apache.axis.transport.http.AxisServlet.java

/**
 * Process GET requests. This includes handoff of pseudo-SOAP requests
 *
 * @param request request in/*from w ww .  java2  s  .  co m*/
 * @param response request out
 * @throws ServletException
 * @throws IOException
 */
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    if (isDebug) {
        log.debug("Enter: doGet()");

    }
    PrintWriter writer = new FilterPrintWriter(response);

    try {
        AxisEngine engine = getEngine();
        ServletContext servletContext = getServletConfig().getServletContext();

        String pathInfo = request.getPathInfo();
        String realpath = servletContext.getRealPath(request.getServletPath());
        if (realpath == null) {
            realpath = request.getServletPath();
        }

        //JWS pages are special; they are the servlet path and there
        //is no pathinfo...we map the pathinfo to the servlet path to keep
        //it happy
        boolean isJWSPage = request.getRequestURI().endsWith(".jws");
        if (isJWSPage) {
            pathInfo = request.getServletPath();
        }

        // Try to execute a query string plugin and return upon success.

        if (processQuery(request, response, writer) == true) {
            return;
        }

        boolean hasNoPath = (pathInfo == null || pathInfo.equals(""));
        if (!disableServicesList) {
            if (hasNoPath) {
                // If the user requested the servlet (i.e. /axis/servlet/AxisServlet)
                // with no service name, present the user with a list of deployed
                // services to be helpful
                // Don't do this if has been turned off
                reportAvailableServices(response, writer, request);
            } else if (realpath != null) {
                // We have a pathname, so now we perform WSDL or list operations

                // get message context w/ various properties set
                MessageContext msgContext = createMessageContext(engine, request, response);

                // NOTE:  HttpUtils.getRequestURL has been deprecated.
                // This line SHOULD be:
                //    String url = req.getRequestURL().toString()
                // HOWEVER!!!!  DON'T REPLACE IT!  There's a bug in
                // req.getRequestURL that is not in HttpUtils.getRequestURL
                // req.getRequestURL returns "localhost" in the remote
                // scenario rather than the actual host name.
                //
                // But more importantly, getRequestURL() is a servlet 2.3
                // API and to support servlet 2.2 (aka WebSphere 4)
                // we need to leave this in for a while longer. tomj 10/14/2004
                //
                String url = HttpUtils.getRequestURL(request).toString();

                msgContext.setProperty(MessageContext.TRANS_URL, url);

                // See if we can locate the desired service.  If we
                // can't, return a 404 Not Found.  Otherwise, just
                // print the placeholder message.

                String serviceName;
                if (pathInfo.startsWith("/")) {
                    serviceName = pathInfo.substring(1);
                } else {
                    serviceName = pathInfo;
                }

                SOAPService s = engine.getService(serviceName);
                if (s == null) {
                    //no service: report it
                    if (isJWSPage) {
                        reportCantGetJWSService(request, response, writer);
                    } else {
                        reportCantGetAxisService(request, response, writer);
                    }

                } else {
                    //print a snippet of service info.
                    reportServiceInfo(response, writer, s, serviceName);
                }
            }
        } else {
            // We didn't have a real path in the request, so just
            // print a message informing the user that they reached
            // the servlet.

            response.setContentType("text/html; charset=utf-8");
            writer.println("<html><h1>Axis HTTP Servlet</h1>");
            writer.println(Messages.getMessage("reachedServlet00"));

            writer.println("<p>" + Messages.getMessage("transportName00", "<b>" + transportName + "</b>"));
            writer.println("</html>");
        }
    } catch (AxisFault fault) {
        reportTroubleInGet(fault, response, writer);
    } catch (Exception e) {
        reportTroubleInGet(e, response, writer);
    } finally {
        writer.close();
        if (isDebug) {
            log.debug("Exit: doGet()");
        }
    }
}