> Hello,
>
[quoted text clipped - 6 lines]
> server.xml to add <Context path="/foo" docBase="C:\bar" debug="0"
> privileged="true"> How can I accomplish this with Jetty?
Hello...
Under Jetty, all configuration is performed by creating XML tags that
actually correspond to Jetty API calls. For general information, you will
probably find
http://mortbay.org/jetty/tut/XmlConfiguration.html
useful...
Now, go to http://jetty.mortbay.org/javadoc/ and click on the Index - you
want to look at the addContext method of HttpServer, that's what you'll need
to use. For example,
public HttpContext addContext(java.lang.String virtualHost,
java.lang.String contextPathSpec)
allows you to set up a context under a specific virtualhost. The XML config
that corresponds to this method would be
<Call name="addContext">
<Arg>www.example.com</Arg> <!-- java.lang.String virtualHost -->
<Arg>/ourContext/</arg> <!-- java.lang.String contextPathSpec -->
</Call>
See? When setting up a J2EE web container, I tried Tomcat and had trouble
with it, and found the config syntax daunting. Jetty is just so much simpler.
I do want to point out that there are several addContext methods with
various arguments, and that you DO NOT have to use the one I used here. The
example above is meant primarily as an illustration of how to author
jetty.xml (or WEB-INF/jetty-web.xml for webapp-specific configurations).
If you have specific questions about configuring Jetty a certain way, I'd
recommend subscribing the mailing list. There are a lot of knowledgeable
people on it, including the Jetty developers. It is a great resource.

Signature
Steve Sobol, Professional Geek 888-480-4638 PGP: 0xE3AE35ED
Company website: http://JustThe.net/
Personal blog, resume, portfolio: http://SteveSobol.com/
E: sjsobol@JustThe.net Snail: 22674 Motnocab Road, Apple Valley, CA 92307
mivanov@gmail.com - 03 Aug 2005 20:03 GMT
Thank you very much for your response. You've put me on the right
track. However, I'm having trouble configuring HttpServer using
WEB-INF/jetty-web.xml in my webapp. The Jetty FAQ says it's
essentially the same as jetty.xml, "except that it is applied to a
HttpContext instance rather than a HttpServer instance" So in this
case, how do I add a context instead of overwriting the members of my
webapp context?
Michael
Steve Sobol - 03 Aug 2005 22:44 GMT
> Thank you very much for your response. You've put me on the right
> track. However, I'm having trouble configuring HttpServer using
[quoted text clipped - 3 lines]
> case, how do I add a context instead of overwriting the members of my
> webapp context?
Easy. The <configure> tag takes a class name as its sole attribute. In the
global jetty.xml, that'll be org.mortbay.jetty.Server or
org.mortbay.jetty.plus.Server, or a derivative thereof. In jetty-web.xml,
you configure a WebApplicationContext. Here's a real example from a live
website:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure 1.2//EN"
"http://jetty.mortbay.org/configure_1_2.dtd">
<Configure class="org.mortbay.jetty.servlet.WebApplicationContext">
<Set name="virtualHosts">
<Array type="java.lang.String">
<Item>sobol.com</Item>
<Item>www.sobol.com</Item>
</Array>
</Set>
<Call name="getServletHandler">
<Call name="getServletHolder"><Arg>jsp</Arg>
<Call name="setInitParameter">
<Arg>scratchdir</Arg>
<Arg>/var/www/work/new.sobol.com</Arg>
</Call>
<Call name="setInitParameter">
<Arg>keepgenerated</Arg>
<Arg>true</Arg>
</Call>
</Call>
</Call>
</Configure>

Signature
Steve Sobol, Professional Geek 888-480-4638 PGP: 0xE3AE35ED
Company website: http://JustThe.net/
Personal blog, resume, portfolio: http://SteveSobol.com/
E: sjsobol@JustThe.net Snail: 22674 Motnocab Road, Apple Valley, CA 92307
mivanov@gmail.com - 04 Aug 2005 00:15 GMT
Thanks for the hints. I'm still not having any luck, though. Perhaps
something is different when my webapp is deployed in Geronimo? Here is
what my WEB-INF/jetty-web.xml looks like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC
"-//Mort Bay Consulting//DTD Configure 1.2//EN"
"http://jetty.mortbay.org/configure_1_2.dtd">
<Configure class="org.mortbay.jetty.servlet.WebApplicationContext">
<Call name="getHttpServer">
<Call name="addContext">
<Arg>/data/*</Arg>
<Call name="setResourceBase">
<Arg>C:/data</Arg>
</Call>
</Call>
</Call>
</Configure>
Is my thinking off here? I am trying to get the Server instance and do
addContext on that. I've tried various different things for the
"C:/data" argument such as "C:\data" but no dice. The strange thing is
I'm getting no indication that it's picking up jetty-web.xml at all.
If I mess up the markup to make the xml invalid, I do not see any
complaints. Any thoughts?
Michael
> > Thank you very much for your response. You've put me on the right
> > track. However, I'm having trouble configuring HttpServer using
[quoted text clipped - 42 lines]
> Personal blog, resume, portfolio: http://SteveSobol.com/
> E: sjsobol@JustThe.net Snail: 22674 Motnocab Road, Apple Valley, CA 92307