This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to get the JSP page name

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Does any one know how to get/print the current JSP page name? PHP has a $PHP_SELF that holds the file name. Is there an equivalent for $PHP_SELF in JSP?
Thank you in advance for your time and help.
Mike
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use the getRequestURI method of the request object.
i.e request.getRequestURI(), which returns a string (this includes the path information also).
 
Miguel Saenz
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request.getRequestURI() method doesn't work for the following scenario:
When including menu.jsp into my index.jsp page (<jsp:include page="menu.jsp" /> , the first line in menu.jsp is something like:

to show that I am including menu.jsp in my index.jsp page but it doesn't print menu.jsp, it prints index.jsp.
Does any one know how to get the "Begin include of menu.jsp" to be printed out in index.jsp instead of "Begin include of index.jsp"?
Thanks
 
Joshi Thomas
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing you can do is store "menu.jsp" in a variable in menu.jsp and use that variable in your index.jsp.
In menu.jsp
String pagename = "menu.jsp";
In index.jsp
<include menu.jsp>
Begining include of <%=pagename %>
 
Miguel Saenz
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
I found the answer to my question!
The answer is:

This represents the name of the jsp file.
Or the following will also work:

Hope this helps someone else.
Thank you
-Mike
 
Miguel Saenz
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the previous answer seemed too long, try this:

To be honest I don't know exactly what's the difference but it works.
Thanks
-Mike
 
There's a city wid manhunt for this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic