I cleaned up some methods of HTTPRequest that I've been using internally for
quite a while and checked them into Webware CVS.  Chuck, if this looks like
deja-vu it's probably because I saw these methods first in some of your code
:-)

originalURLPath() - Returns the URL path of the original servlet before any
forwarding. 

siteRoot() - Returns the URL path components necessary to get back home from
the current location. 

        Examples: 
                '' 
                '../' 
                '../../' 

You can use this as a prefix to a URL that you know is based off the home
location. Any time you are in a servlet that may have been forwarded to from
another servlet at a different level, you should prefix your URL's with
this. That is, if servlet "Foo/Bar" forwards to "Qux", then the qux servlet
should use siteRoot() to construct all links to avoid broken links. This
works properly because this method computes the path based on the original
servlet, not the location of the servlet that you have forwarded to. 

siteRootFromCurrentServlet() - Similar to siteRoot() but instead, it returns
the site root relative to the current servlet, not the original servlet. 

servletPathFromSiteRoot() - Returns the "servlet path" of this servlet
relative to the siteRoot. In other words, everything after the name of the
context (if present). If you append this to the result of self.siteRoot()
you get back to the current servlet. This is useful for saving the path to
the current servlet in a database, for example. 

If these descriptions don't make sense, let me know and I'll try to
elaborate.


- Geoff

_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to