Roedy said:
Really? You want to peek the return address of your caller and you're
asking me why that's a bad idea? Seriously?
I want to track hit counts. I need something analogous to the HTML
file name to track them by.
You know there's almost correspondence between your caller and the URL
that the user typed in, right? All that stuff is set in the deployment
descriptor. URLs are mapped to scriptlets (and JSPs are scriptlets) and
the name of the script doesn't really come into play there.
Sniffing URL's is fine, I support that. The URL is passed as a
parameter with the Request object. Looking at parameters is fine, I
support that. Sniffing your caller's stack frame, not so much.
I want to display the URL of the page on the footer so that if anyone
prints a snapshot of the page, they know where the original came from.
I do have to criticize you for using very loose terminology. The name
of a scriptlet has nothing to do with the URL, other than what the
deployment descriptor says it does. If you wanted the URL you should
have said.
I have a rule based scheme for generating random quotations, that uses
the filename/directory name to weight what sorts of quotations show
up. Ditto PSA ads.
This sounds like a Java class to me, so you can isolate the rest of the
application from these implementation details.
I also need it to generate terse relative links to other pages. I
This sounds like you might want to consider manipulating the deployment
descriptor. Send terse links to other pages/scriptlets with the
deployment descriptor.
specify some links in markup as webroot relative, and convert them to
relative. This way I can insert boilerplate containing links anywhere
in the tree and all works. There may be another way of handling that
with TagLibs.
I don't know what the difference between "webroot relative" and
"relative" is, so no opinion here. You might want to consider making a
very small, SSCCE style sample app, with one implementation of each
use-case that you think you need, posting it up somewhere (Google apps?
Your own site?) and letting folks comment on it.