You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Shahed Ali <sh...@enoor.com> on 2001/01/25 22:38:44 UTC

JSP generated .java Naming Convention

Hi,

I need to get the name of the current jsp page in a scriptlet.

The jsp page could be serverd up by a link or by a jsp:forward or a
redirect.

If I do

<%=this.getClass()%>, I get the following for a jsp page tmp/ST003.jsp

tmp._0002ftmp_0002fST_00030_00030_00033_0002ejspST003_jsp_1

Is there some standard way of extracting the jsp page name form this ?
Or is this naming convention subject to change ?

Or is there any other way ?

Thanks
Shahed.




Re: JSP generated .java Naming Convention

Posted by David Brown <br...@bea.com>.
$0.02,

If you want to get the name of the current JSP
page, in the sense of the file part of a URL in
a browser, then request.getRequestURI() will
give you that as a String, which you can parse
as needed.

If you're trying to get the synthentically-generated
classname of the JSP servlet, and then do something
meaningful with it, that is dubious.  It is
considered to be a bad programming model for servlets
to get direct references to each other (this is
why the method ServletContext.getServlet(String name)
call has been deprecated).  Having such references
makes it impossible for a servlet container to
manage servlet lifecylcles correctly.  For one
servlet to invoke another, include & forward are
to be used.  As you can see, the generated classnames
are non-intuitive at best, implementation-dependent,
and subject to change between releases.  If there
is some kind of functionality that a.jsp needs to
call in b.jsp (other than the service() method), you
should probably consider breaking that functionality
out into a public helper class, such as a bean.

Hope that helps,

-dave brown

Shahed Ali wrote:
> 
> Hi,
> 
> I need to get the name of the current jsp page in a scriptlet.
> 
> The jsp page could be serverd up by a link or by a jsp:forward or a
> redirect.
> 
> If I do
> 
> <%=this.getClass()%>, I get the following for a jsp page tmp/ST003.jsp
> 
> tmp._0002ftmp_0002fST_00030_00030_00033_0002ejspST003_jsp_1
> 
> Is there some standard way of extracting the jsp page name form this ?
> Or is this naming convention subject to change ?
> 
> Or is there any other way ?
> 
> Thanks
> Shahed.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, email: tomcat-dev-help@jakarta.apache.org