views:

18

answers:

2

Is there a tool to automate the task of finding out where a given JSP is used, by URL?

Ultimately, the question I need to answer is, What URL(s) do I need to call, to see the output of this JSP in my browser?

Finding out involves searching for the JSP name, then searching for any JSPs that include it (possibly through several levels), ending up with one or more servlets - then trawling through web.xml to get the mapping of URL to servlet.

Having spent this morning doing exactly that, looking for examples of deprecated tags in our project, it seems to me that a computer would be quicker, if not better, at this than I am. For my purposes, I can live with not getting every URL; I really need to see only one use of the file in question.

So, is there a tool to do this? My IDE is Eclipse, so if Eclipse or some plug-in can do this that would be my preferred option. The application is running on Tomcat 6.

Thanks,

+2  A: 

Check the contents of web.xml; it contains this mapping.

[EDIT] If you want to remove a JSP, here is what you need to do:

  1. Check for an entry in web.xml
  2. Search for <jsp:include and <%@include in all *.jsp files

That's all the places where your JSP can be used. You don't have to check for redirects and such since for a redirect to work, the JSP must be listed in web.xml.

Aaron Digulla
web.xml contains the first/last stage of the process, mapping the URL to a servlet.But that servlet calls JSPs which include JSPs which include JSPs... one of which is what I need to see on screen. I need to know the URL to call to see the output of *that JSP.*
Ed Daniel
Included JSPs aren't called by URL, they are singleton objects in the web server and they simply call the methods defined in `HttpJspPage` on each other.
Aaron Digulla
That is unless the compiler doesn't simply recursively generates the code as it processes the jsp:include tags.
Aaron Digulla
I didn't know that's how it owrked internally, so thanks for the insight.I'm not sure how it helps, though. In our case, URLs are mapped on to servlets which then forward to JSPs. Those then include other JSPs, and so on. Right at the bottom, I have a JSP I want to remove; all I know is where that JSP is. I need to know how to see it, in my browser - i.e., what URL will bring up the page with it in. So I have to work my way back up. web.xml only helps in the last stage of the process - finding out which URL will hit the servlet.
Ed Daniel
See my edits for how to do that.
Aaron Digulla
A: 

Why do you require any eclipse plugin? How about a simple text search in eclipse, where you can do a file search, that is search a text in all required file patterns - as below

alt text

ring bearer
It's not just one search, though, is it? It's lots.I can search to find out what JSPs include this little JSP - but then I need to know what includes *those*, and what includes *those* (repeat as necessary), then what servlets call *those*, and finally what URL calls the servlet. I'm trying to avoid doing six or ten searches for every tiny deprecated tag/JSP I have to retire.If you have a single search that will take "dead.jsp" and spit out "/appName/section/thing", that would do the job. Otherwise, the standard Eclipse search is not going to help here.
Ed Daniel