[EMAIL PROTECTED] wrote:
> [EMAIL PROTECTED] wrote:
>
> >
> > I was using Tomcat-3.1 and Struts-0.5 and had the same difficulty with
> > "Cannot find file ..../*.do".
> >
> > So I upgraded to Tomcat-3.2-b7 and that was fixed.
> >
> > Now, however, I also get the problem where Struts composes a link URL like
> > so:
> >
> > http://localhost/myapp/nextpage.jsp;jsessionid=dsfdsf3
> >
> > and that page is not found.
> >
> > I tried using last night's build of Struts to no avail.
> >
> > A little help?
> >
> > --
> > Lee "Lefty" Burgess <<!>> Manipulate eternity. Power is a symphony:
> > Web Application Developer <<!>> elaborate, enormous, essential.
> > PiperStudiosInc <<!>> Dream the moment with a fiddle in summer
> > [EMAIL PROTECTED] <<!>> and a knife in winter.
> >
> >
> >
>
> I use tomcat3.2b7, and the struts build from 15112000, and mod_jk to
> "connect" apache and tomcat. It works fine.
>
> But I've noticed that if I have a link
> <a href="/login.jsp">login</a>, then the file is not found.
> I have to use <a href="login.jsp">login</a> (No /)
>
> I'm still investigating to try to find the reason for this.
>
The reason for this is one of the few really frustrating aspects of servlet
programming -- the browser doesn't know anything about context paths.
When you send a relative URL like
<a href="login.jsp">Login</a>
the browser resolves this against the absolute URL of the page containing it
(unless you also use the appropriate HTML metatag to establish what the base
directory is). Normally, this works fine, but think for a moment what URL that
is from the browser's perspective -- if the last submit was to
"saveCustomer.do", that is what the relative URL will be resolved against! If
everything is on one level and you are using extension mapping, this is quite
easy -- otherwise it becomes more interesting.
When you specify an absolute URL like
<a href="/login.jsp">Login</a>
the browser resolves this against the *server* root, not the *context* root --
so it goes the wrong place unless your webapp happens to be in the root webapp.
You cannot normally count on this, so if you want to use absolute URLs you need
to do something like this (a tag to do it would probably be useful, wouldn't it?
:-):
<a href='<%= request.getContextPath() + "/login.jsp" %>'>Login</a>
I will look at making the <link> tag smarter about this kind of thing.
>
> I'm not sure if it will solve your problem, since your are probably
> testing struts-example and not one of your own apps.
>
> If you use mod_jserv, you have to add the AddHandler directives as described
> in README / INSTALL.
> If you use mod_jk, you have to add the JkMount's as described
> by mike.labudde
>
> Alf Hogemark
Craig McClanahan