struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leon Rosenberg" <rosenberg.l...@googlemail.com>
Subject Re: Struts forwarding to jsp Problem, Losing path to image/css/scripts resources
Date Sun, 09 Jul 2006 19:09:38 GMT
On 7/9/06, Mississippi John Hurt <johnhurt@gmail.com> wrote:
> Thanks, that seems to work. I also found that putting a <html:base/> in the
> jsp will root the path to the actual jsp being rendered and also fixes it
> (from some old list posting).  I think I'll use the <html:base/> as this
> will always work, while the other way might give different results if you're
> coming from a action.do request vs a regular file.jsp request.

a "regular file.jsp request" ?

You should never link directly to a jsp if you are in the struts world
:-) Real bad Karma.

However, html:base will work to. The best way though is to control the
path via property, like:

<img src="<bean:message key="image.path" arg0="foo.gif"/>"...> and in
your application properties:
image.path=images/{0}

Regards
Leon


>
> On 7/9/06, Leon Rosenberg <rosenberg.leon@googlemail.com> wrote:
> >
> > If the browser requests http://server/appname/login, than
> > ../images/foo.gif will point to http://server/images/foo.gif instead
> > of your desired  http://server/appname/images/foo.gif.
> > To solve this simply change the link to the image from
> > ../images/foo.gif into images/foo.gif
> >
> > regards
> > leon
> >
> > On 7/9/06, Mississippi John Hurt <johnhurt@gmail.com> wrote:
> > > Can someone help?  When I access my /appname/jsp/login.jsp directly in
> > > browser its able to find my images and stylesheets (I use relative ie
> > > "../images/file.ext" paths) and everything renders fine. But once I
> > click
> > > login, and it goes to my Action then forwards it back to a jsp (for
> > instance
> > > "failure" ie /jsp/login.jsp) then it seems as if the browser can't find
> > my
> > > images and stylesheets as the html render is messed up, as if it can't
> > find
> > > the path to those resources. Why is it that when I directly put in the
> > > /jsp/login.jsp into browser it shows up fine, but when Struts "forwards"
> > to
> > > that "failure"="/jsp/login.jsp" its able to find the login.jsp page
> > itself,
> > > but can't find the resources like (<img src="../images/image.jpg)?? Help
> > me
> > > please!
> > >
> > > My app is structured like:
> > >
> > > /appname/jsp/login.jsp
> > > /appname/images/*.jpg
> > > /appname/styles/*.css
> > >
> > > <action path="/login"  type="com.abc.action.LoginAction"
> > name="loginForm"
> > > scope="request" input="/pages/login.jsp">
> > >    <forward name="failure" path="/jsp/login.jsp"/>
> > >    <forward name="success" path="/mainMenu.do"/>
> > > </action>
> > >
> > > Anyone knows how to fix this? Thanks.
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message