tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arieh Markel <Arieh.Mar...@Central.Sun.COM>
Subject Re: Starting HttpServer from Java app...
Date Wed, 19 Jan 2000 18:22:23 GMT
I am actually doing exactly what you are trying to do.

> Mailing-List: contact; run by ezmlm
> X-No-Archive: yes
> list-help: <>
> list-unsubscribe: <>
> list-post: <>
> Delivered-To: mailing list
> From: Dustin Callaway <>
> To: "''" <>
> Subject: Starting HttpServer from Java app...
> Has anyone figured out how to start the Tomcat HttpServer from within a Java
> application? Both the Tomcat binaries and source code include a sample file
> called that supposedly demonstrates how to do this.
> However, this program does not compile due to some API problems. The errant
> code looks like this:
> int port = 8080;
> InetAddress inet = null; // null uses all inets on the machine
> String hostname = null;
> HttpServer server = new HttpServer(port, inet, hostname);
> try {
>     URL url = resolveURL("webpages");
>     server.setDocumentBase(url);  <<<<<<<<<<<<<<<<<<<<
this method does not
> exist
>     System.out.println("Starting with docbase of: " + url);
>     server.start();
> }

However, instead of using the 'raw' HttpServer class, I am taking advantage
of the shell.Startup class.

I am invoking is as follows:

	Startup.configure (evaluateArgs());
where args is one of the valid switch/value combinations that are allowed:

below is a function that evaluates the deployment arguments for me:

    public static String[]  evaluateArgs ()
        ArrayList al = new ArrayList();

        al.add ("-config");
        al.add (getConfigFile());

        al.add ("-docbase");
        al.add (getDocumentBase());

        al.add ("-adminport");
        al.add ("0");

        String[] argv = (String[]) al.toArray (new String[al.size()]);

        return argv;


PS: alternatively, you could modify the shell.Startup class and make it do
    whatever you want. The principles there, of configuration of Contexts
    and ContextManagers are valuable.
 Arieh Markel		                Sun Microsystems Inc.
 Network Storage                        500 Eldorado Blvd. MS UBRM11-194
 e-mail: arieh.markel@sun.COM           Broomfield, CO 80021
 Let's go Panthers !!!!                 Phone: (303) 272-8547 x78547
 (e-mail me with subject SEND PUBLIC KEY to get public key)

View raw message