Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP file info  RSS feed

 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi-
Is there a way to get system info on a JSP? What I'm trying to do is - create a filter that execute each time a jsp is loaded (includes and forwards too), and will access a file on the system that is mapped to this jsp by it's location and file name. Basically, my question is - how to find the path & filename of a jsp file at runtime (it does not have to be absolute - relative from the root of the war is ok too)
I've looked in the API, and there doesnt seem to be anything in any of the context objects, etc...

Thanks!
[ November 22, 2006: Message edited by: Dudley Dawson ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out the API for the HttpServletRequest?
 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Have you checked out the API for the HttpServletRequest?


Well, yes - but that only provides information about the request, so a chain of included pages all share that same request, which seems to be driven by the resource URL (not necessarily the path on the file system). Let me explain in more detail what I'm trying to do. Say I have the following file structure:

I want to add a filter that will load each txt file when it's corresponding jsp is loaded. If page1.jsp were to include header.jsp and display_component2.jsp, they all share the same request, and will all think they are part of the top-most jsp or servlet that included them. If possible, I might want to move these text files to a completely different location, and use some type of mapping to access them.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dudley Dawson:

Well, yes - but that only provides information about the request


Check out what getRequestURL and getRequestURI return. If that's not what you need, perhaps the scoped variables that the container places on the request contain the info that you can trigger off of.
E.g. Those prefixed with "javax.servlet.include." and "javax.servlet.forward."
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!