tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: REPOST : extracting jsp filename from generated class
Date Thu, 01 Feb 2001 01:00:31 GMT
Shahed Ali wrote:

> Hi all,
> Sorry for this repost.
> >From within a jsp page, I need to know the name of the jsp page.

What do you mean by the "name" of the page?  JSP pages have URIs used to
access them (which you can get via request.getRequestURI()), but they do not
really have a notion of a "name" other than that.

> If I do a <%=this.getClass()%>, I get a string which represents the class
> name
> of the generated servlet.
> Is there some standard way in which I can extract the jsp page from that
> name ?

No ... servlet containers are free to name the generated classes in any way
that they see fit.  Even if you duplicated the rules of a particular version
of a particular servlet container, your app would not be portable to any
other server.

You should also be aware that the class name will be different each time you
modify the page (so that the code gets regenerated) in many containers.

> Another Qs :- How does Tomcat know that a certain jsp page maps to
> a certain class ?.

Because it created that mapping in the first place -- within the JSP servlet
(Jasper) there is a "name mangler" that performs this transformation.  You
could look inside the Jasper source code for the specific implementation
being used in Tomcat.

> If I can access that data, then I can possibly lookup the pagename.
> Any clues ?
> Thanks
> Shahed.

Craig McClanahan

View raw message