You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Bailey <ch...@wego.com> on 2001/04/24 01:17:57 UTC

How do I map www.blah.com to a servlet?

I'm using Linux, Apache 1.3.19, Tomcat 3.2.1, mod_jk.  I want to map a
URL such as "http://www.foo.com" to a servlet.  Right now I do this by
just mapping the default page (e.g. index.html) to a servlet.  But, then
index.html shows up in the URL on many further uses.  Is there a
different way to do it, or a way to make sure that "index.html" doesn't
show up in the URL?

-- 
Chris Bailey            chrisb@wego.com
Wego Systems            http://www.wego.com


Re: How do I map www.blah.com to a servlet?

Posted by David Crooke <da...@convio.com>.
Assuming you just want to "hide" the servlet, mod_rewrite may be what you're
looking for, but it could require a bit of work to maintain the facade in the
JSP.

A popular but inelegant option is to make index.html a static HTML file which
throws up a frame, thus obfuscating the URL from the browser's prompt.

Dave

P.S. Give my regards to Ghu






Re: How do I map www.blah.com to a servlet?

Posted by Joel Parramore <pa...@homes.com>.
Chris:

Is there a reason you can't redirect any www.foo.com/index.html requests to
your servlet with an Apache redirect directive instead (besides adding
another trip back-and-forth for the user, that is)?

Regards,
Joel

----- Original Message -----
From: "Chris Bailey" <ch...@wego.com>
To: <to...@jakarta.apache.org>
Sent: Monday, April 23, 2001 7:45 PM
Subject: RE: How do I map www.blah.com to a servlet?


> This is what I'm already doing (see the email below) - I map my servlet
> to index.html in web.xml.
>
> On 23 Apr 2001 16:26:04 -0700, mail@filip.net wrote:
> > can't you map the name index.html to your servlet in the web.xml file?
> > or you can change the index file name to point to your servlet.
> > Filip
> >
> > ~
> > Namaste - I bow to the divine in you
> > ~
> > Filip Hanik
> > Software Architect
> > filip@filip.net
> > www.filip.net
> >
> > > -----Original Message-----
> > > From: Chris Bailey [mailto:chrisb@wego.com]
> > > Sent: Monday, April 23, 2001 4:18 PM
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: How do I map www.blah.com to a servlet?
> > >
> > >
> > > I'm using Linux, Apache 1.3.19, Tomcat 3.2.1, mod_jk.  I want to map a
> > > URL such as "http://www.foo.com" to a servlet.  Right now I do this by
> > > just mapping the default page (e.g. index.html) to a servlet.  But,
then
> > > index.html shows up in the URL on many further uses.  Is there a
> > > different way to do it, or a way to make sure that "index.html"
doesn't
> > > show up in the URL?
> > >
> > > --
> > > Chris Bailey            chrisb@wego.com
> > > Wego Systems            http://www.wego.com
> > >
> > >
> >
>
> --
> Chris Bailey            chrisb@wego.com
> Wego Systems            http://www.wego.com


RE: How do I map www.blah.com to a servlet?

Posted by Milt Epstein <me...@uiuc.edu>.
On 24 Apr 2001, Chris Bailey wrote:

> On 24 Apr 2001 10:25:42 -0500, mepstein@uiuc.edu wrote:
> > On 23 Apr 2001, Chris Bailey wrote:
> >
> > > This is what I'm already doing (see the email below) - I map my
> > > servlet to index.html in web.xml.
> >
> > Here's something you can try.  I haven't tried it exactly myself,
> > although I have tried something similar (i.e. having
> > http://www.foo.com/bar/ go directly to a servlet).  The steps below
> > are analogous to what I have done.
> >
> > First, add a directive to your tomcat/apache conf file that directs
> > *all* requests to tomcat's default context.  This might be something
> > like:
> >
> >   JkMount /* /ROOT
> >
> > (I'm using mod_jserv, not mod_jk, which is an additional reason I'm
> > not 100% sure of what exactly you need to do this part of it.)
> >
> > Second, add a servlet-mapping for the URL "/" to the servlet you wish
> > the requests to go to (I believe you'll have to have defined that
> > servlet, i.e. set up a servlet-name for it).  This should go in
> > tomcat's root context's web.xml file.
> >
> > That's it.
>
> This is orignally how I had it set up, but the problem was that by using
> "JkMount /* /whatever", which as you said, directs _all_ requests to
> Tomcat, it directs EVERY request to that domain to the servlet.  So, if
> for example, I put "http://www.blah.com/test/whatever.html" in, that
> still matches "http://www.blah.com/*" (the /* being the JkMount part),
> so it goes to the servlet as well.  This is undesireable (probably in
> most cases), becuase then if the browser requests say a stylesheet, or a
> static HTML file or whatever, it's all going to get mapped to the
> servlet.

Oh, I meant to mention that this is the downside of doing what I
suggested -- *everything* goes to the servlet :-).  This may or may
not be a problem, depending on your specifics (it's not a problem for
mine).

You may have mentioned it previously, but it's lost now -- what
version of Tomcat are you using?  3.X?  What you (and I) really want
is to allow the "welcome-file" to be a servlet.  From what I learned
when I inquired about this some time back, in 3.X, there is no way to
do this, but there is/will be in 4.X.

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


RE: How do I map www.blah.com to a servlet?

Posted by Chris Bailey <ch...@wego.com>.
On 24 Apr 2001 10:25:42 -0500, mepstein@uiuc.edu wrote:
> On 23 Apr 2001, Chris Bailey wrote:
> 
> > This is what I'm already doing (see the email below) - I map my
> > servlet to index.html in web.xml.
> 
> Here's something you can try.  I haven't tried it exactly myself,
> although I have tried something similar (i.e. having
> http://www.foo.com/bar/ go directly to a servlet).  The steps below
> are analogous to what I have done.
> 
> First, add a directive to your tomcat/apache conf file that directs
> *all* requests to tomcat's default context.  This might be something
> like:
> 
>   JkMount /* /ROOT
> 
> (I'm using mod_jserv, not mod_jk, which is an additional reason I'm
> not 100% sure of what exactly you need to do this part of it.)
> 
> Second, add a servlet-mapping for the URL "/" to the servlet you wish
> the requests to go to (I believe you'll have to have defined that
> servlet, i.e. set up a servlet-name for it).  This should go in
> tomcat's root context's web.xml file.
> 
> That's it.

This is orignally how I had it set up, but the problem was that by using
"JkMount /* /whatever", which as you said, directs _all_ requests to
Tomcat, it directs EVERY request to that domain to the servlet.  So, if
for example, I put "http://www.blah.com/test/whatever.html" in, that
still matches "http://www.blah.com/*" (the /* being the JkMount part),
so it goes to the servlet as well.  This is undesireable (probably in
most cases), becuase then if the browser requests say a stylesheet, or a
static HTML file or whatever, it's all going to get mapped to the
servlet.

-- 
Chris Bailey            chrisb@wego.com
Wego Systems            http://www.wego.com


RE: How do I map www.blah.com to a servlet?

Posted by Milt Epstein <me...@uiuc.edu>.
On 23 Apr 2001, Chris Bailey wrote:

> This is what I'm already doing (see the email below) - I map my
> servlet to index.html in web.xml.

Here's something you can try.  I haven't tried it exactly myself,
although I have tried something similar (i.e. having
http://www.foo.com/bar/ go directly to a servlet).  The steps below
are analogous to what I have done.

First, add a directive to your tomcat/apache conf file that directs
*all* requests to tomcat's default context.  This might be something
like:

  JkMount /* /ROOT

(I'm using mod_jserv, not mod_jk, which is an additional reason I'm
not 100% sure of what exactly you need to do this part of it.)

Second, add a servlet-mapping for the URL "/" to the servlet you wish
the requests to go to (I believe you'll have to have defined that
servlet, i.e. set up a servlet-name for it).  This should go in
tomcat's root context's web.xml file.

That's it.


> On 23 Apr 2001 16:26:04 -0700, mail@filip.net wrote:
> > can't you map the name index.html to your servlet in the web.xml file?
> > or you can change the index file name to point to your servlet.
> > Filip
> >
> > ~
> > Namaste - I bow to the divine in you
> > ~
> > Filip Hanik
> > Software Architect
> > filip@filip.net
> > www.filip.net
> >
> > > -----Original Message-----
> > > From: Chris Bailey [mailto:chrisb@wego.com]
> > > Sent: Monday, April 23, 2001 4:18 PM
> > > To: tomcat-user@jakarta.apache.org
> > > Subject: How do I map www.blah.com to a servlet?
> > >
> > >
> > > I'm using Linux, Apache 1.3.19, Tomcat 3.2.1, mod_jk.  I want to map a
> > > URL such as "http://www.foo.com" to a servlet.  Right now I do this by
> > > just mapping the default page (e.g. index.html) to a servlet.  But, then
> > > index.html shows up in the URL on many further uses.  Is there a
> > > different way to do it, or a way to make sure that "index.html" doesn't
> > > show up in the URL?
> > >
> > > --
> > > Chris Bailey            chrisb@wego.com
> > > Wego Systems            http://www.wego.com
> > >
> > >
> >
>
> --
> Chris Bailey            chrisb@wego.com
> Wego Systems            http://www.wego.com
>

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
mepstein@uiuc.edu


RE: How do I map www.blah.com to a servlet?

Posted by Chris Bailey <ch...@wego.com>.
This is what I'm already doing (see the email below) - I map my servlet
to index.html in web.xml.

On 23 Apr 2001 16:26:04 -0700, mail@filip.net wrote:
> can't you map the name index.html to your servlet in the web.xml file?
> or you can change the index file name to point to your servlet.
> Filip
> 
> ~
> Namaste - I bow to the divine in you
> ~
> Filip Hanik
> Software Architect
> filip@filip.net
> www.filip.net 
> 
> > -----Original Message-----
> > From: Chris Bailey [mailto:chrisb@wego.com]
> > Sent: Monday, April 23, 2001 4:18 PM
> > To: tomcat-user@jakarta.apache.org
> > Subject: How do I map www.blah.com to a servlet?
> > 
> > 
> > I'm using Linux, Apache 1.3.19, Tomcat 3.2.1, mod_jk.  I want to map a
> > URL such as "http://www.foo.com" to a servlet.  Right now I do this by
> > just mapping the default page (e.g. index.html) to a servlet.  But, then
> > index.html shows up in the URL on many further uses.  Is there a
> > different way to do it, or a way to make sure that "index.html" doesn't
> > show up in the URL?
> > 
> > -- 
> > Chris Bailey            chrisb@wego.com
> > Wego Systems            http://www.wego.com
> > 
> > 
> 

-- 
Chris Bailey            chrisb@wego.com
Wego Systems            http://www.wego.com


RE: How do I map www.blah.com to a servlet?

Posted by Filip Hanik <ma...@filip.net>.
can't you map the name index.html to your servlet in the web.xml file?
or you can change the index file name to point to your servlet.
Filip

~
Namaste - I bow to the divine in you
~
Filip Hanik
Software Architect
filip@filip.net
www.filip.net 

> -----Original Message-----
> From: Chris Bailey [mailto:chrisb@wego.com]
> Sent: Monday, April 23, 2001 4:18 PM
> To: tomcat-user@jakarta.apache.org
> Subject: How do I map www.blah.com to a servlet?
> 
> 
> I'm using Linux, Apache 1.3.19, Tomcat 3.2.1, mod_jk.  I want to map a
> URL such as "http://www.foo.com" to a servlet.  Right now I do this by
> just mapping the default page (e.g. index.html) to a servlet.  But, then
> index.html shows up in the URL on many further uses.  Is there a
> different way to do it, or a way to make sure that "index.html" doesn't
> show up in the URL?
> 
> -- 
> Chris Bailey            chrisb@wego.com
> Wego Systems            http://www.wego.com
> 
>