OK, I found few minutes before my head hit the keyboard...
I am not coy, I am overworked... And lengthy explanations take time to type...

On Thu, 1 Mar 2001, Milt Epstein wrote:

> On Thu, 1 Mar 2001, Jan Labanowski wrote:
> 
> > You may want to read about servlet URLs ramapping in my
> >    http://www.ccl.net/cca/software/UNIX/apache/tomcatfaq.shtml
> > Howver, I am not sure it will gonna work...
> > You can have it remapped to http://localhost:8080/demo/demo
> > but what you want is to have null path in the context to correspond
> > to your servlet... You probably still do not know what you want {:-)}.
> > But it will come with a sacrifice of reading stuff on Tomcat, the 
> > Servlet 2.1 spec and JSP 1.1 spec on the JavaSun. It is all in there...
> > 
> [ ... ]
> > 
> > and see if this will work for  
> >    http://localhost:8080/demo
> > But again... You only think you want it... But in fact you do not want it.
> 
> OK, stop being coy, tell us why he doesn't want it :-).  (Because I
> want it too ... at least, I think I do :-).

Because if you assign a null path to your chosen servlet you will not be
able to serve anything else from this context from Tomcat.
I did not actually try it, but I assume that if you do
 <servlet-mapping>
    <servlet-name>someServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
i.e., when you map a servlet to / then each and every URL mapped to this
context and served by Tomcat will result in serving the someServlet.
Out goes packages, hierachy, JSPs and subdirs...
Of course, it has its uses (e.g., with MVC paradigm, when each URL goes
to a servlet, and then servlets forwards it to other stuff using forward call
within the container), but I suspect this was not a goal here, was it?
That is why I said what I said...

So the way to do it is to use mod_rewrite. In your httpd.conf you would put
something like:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/demo$ /demo/servlet/someServlet [R]
RewriteRule ^/demo/$ /demo/servlet/someServlet [R]
</IfModule>

And this will rewrite the URL 
    http://whatever.com/demo
    http://whatever.com/demo/
to
    http://whatever.com/demo/servlet/someServlet

while it leaves other stuff alone... This way you do not remap all your
context to a single servlet, but you just remap the single URL.

Jan
[EMAIL PROTECTED]

> 
> 
> > On Thu, 1 Mar 2001, Jason Novotny wrote:
> > 
> > > 
> > > I would like to be able to access a servlet with the URL
> > > http://localhost:8080/demo
> > > 
> > > However, it only works if I go to
> > > http://localhost:8080/demo/servlet/demo
> > > 
> > >     I have the following in server.xml and web.xml respectively:
> > > 
> > > <Context path="/demo"
> > >                  docBase="webapps/demo"
> > >                  crossContext="true"
> > >                  debug="0"
> > >                  reloadable="true"
> > >                  trusted="false" >
> > >         </Context>
> > > 
> > > BTW, should I comment out or use the following in some way?
> > > <RequestInterceptor
> > >             className="org.apache.tomcat.request.InvokerInterceptor"
> > >             debug="0" prefix="/servlet/" />
> > > 
> > > 
> > > My web.xml in webapps/demo/WEB_INF/web.xml has the following:
> > > 
> > > <servlet>
> > >       <servlet-name>demo</servlet-name>
> > >       <servlet-class>org.demo.DemoServlet</servlet-class>
> > >     </servlet>
> > > 
> > > <servlet-mapping>
> > >       <servlet-name>demo</servlet-name>
> > >       <url-pattern>/demo</url-pattern>
> > >     </servlet-mapping>
> > > 
> > > So I would like to be able to use <form action="/demo">  and have the
> > > servlet invoked.
> > 
> 
> Milt Epstein
> Research Programmer
> Software/Systems Development Group
> Computing and Communications Services Office (CCSO)
> University of Illinois at Urbana-Champaign (UIUC)
> [EMAIL PROTECTED]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
> 

Jan K. Labanowski            |    phone: 614-292-9279,  FAX: 614-292-7168
Ohio Supercomputer Center    |    Internet: [EMAIL PROTECTED] 
1224 Kinnear Rd,             |    http://www.ccl.net/chemistry.html
Columbus, OH 43212-1163      |    http://www.osc.edu/


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to