tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kitching Simon <>
Subject RE: Pb with session
Date Tue, 24 Oct 2000 12:31:43 GMT
> -----Original Message-----
> From:	Steve Weiss []
> Sent:	Friday, October 20, 2000 4:04 AM
> To:
> Subject:	Re: Pb with session
> Kitching Simon wrote:
> > 
> >         [Kitching Simon]
> >         Hmm, yes I see.
> > 
> >         If a browser requests a URL, and gets back a page containing
> >         relative paths in it (eg to jsp files, or anchors/links), then
> the
> >         browser is going to resolve those relative paths into absolute
> >         paths before issuing a request to the web server; the browser
> >         will use the *original* URL to resolve these relative paths
> with,
> >         because it doesn't know that the original URL actually did an
> >         internal forward operation.
> > 
> >         This is not too bad if a jsp is called via only one controlling
> >         servlet, because all urls in the jsp can be set to be relative
> >         to the calling servlet. But if a jsp can be called from multiple
> >         controlling servlets, it has a problem.
> > 
> >         Is there a method that returns the original URL that the
> >         calling browser requested, even if the request has been
> >         forwarded? If so, then everywhere you output a path in
> >         a jsp, you could call a function which converts from
> >         relative-to-jsp into relative-to-original-url. However, this
> >         really isn't a nice solution.
> > 
> >         This kind of thing is going to occur all the time when using the
> >         MVC approach for designing websites. I wonder how STRUTS
> >         solves this problem?
> I'm not quite sure that I follow the problem being described, but I'm
> using the MVC pattern without problems. If you want to display a link in
> a JSP which is displayed as a result of a forward from a controller
> servlet, you can use something like this:
> <%= request.getContextPath() + "/servlet/myServlet" %> or
> <%= request.getContextPath() + "/jsp/foo.jsp" %>
	[Kitching Simon]  
	Yes, but you're always using absolute URLs. 

	Suppose you want, for example, to have an 
	"images" directory as a *subdirectory* of the jsp 

	You could always write your URLs for <image>
	tags as "/jsp/images/xyz.jpg", in which case you don't 
	have the problem listed above. However, you *do* have 
	the problem that if you rename your jsp directory to 
	"myfiles" or somesuch, you have to change *every*
	string "/jsp/images/..." to "/myfiles/images/...". 

	Using relative paths to images would not require any 
	URL changes when you change directory names, 
	eg "./images/xyz.jpg" (note leading dot) is still correct 
	after renaming directory "jsp" to "myfiles". But you 
	run smack into the problem described above....

> -- 
> Steve Weiss      Association of American Medical Colleges
> (202)828-0428

View raw message