Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Following scenario: I browse for unsafeMethodCall() in all my web pages. This method is only unsafe in case that there is a reference of doSomeCrazyAjaxStuff()

My web pages are using strong templating (i.e. it was built with JSF)

so a webpage consists out of something like this:

<ui:decorate template="/mypages/editing/someWebPagePart.xhtml">

this just copies the contents of the template into the current webpage.

So if I search for unsafeMethodCall() - the problem is I have to manually open someWebPagePart.xhtml to search for crazyAjaxStuff() - but someWebPagePart.xhtml might be using other templates. So from 1 hit of unsafeMethodCalls I can end up with A LOT of pages I have to open.

So I basically want to scan a file named "somefile.xhtml" for any occurrences of a template. If there is a template I want to search in that template as well, and I want to search in the template of the template etc. as well :-)

Is there a program or tool which could solve this problem?


So basically I have a file with this contents: (this is just an example)

<input value="enterusername"/>    
[...more random web page contents like above this line....]
<ui:decorate template="/mypages/editing/someWebPagePart.xhtml">
     <my:tag>  unsafeMethodCall()</my:tag> <!-- this is potentially dangerous with another function call  -->
[...more random web page contents like below this line....]
<a href="#Other-Options" accesskey="n" rel="next">Other Options</a>

When I now open d:/dev/workspace/WebContents/mypages/editing/someWebPagePart.xhtml I will be able to see what finally is actually displayed on the page - because the contents of someWebPagePart.xhtml will be automagically copied by the web server to the final web page. What I am looking for in the file someWebPagePart.xhtml is something like this:

<input value="enterusername"/>    
[...more random web page contents like above this line....]
<ui:decorate template="/mypages/editing/someotherPage.xhtml"> <!-- it could be in there as well -->
     <my:tag2>  crazyAjaxStuff()</my:tag2> <!-- searching this -->
[...more random web page contents like below this line....]
<a href="#Other-Options" accesskey="n" rel="next">Other Options</a>


 <my:tag2>  crazyAjaxStuff()</my:tag2>

will be copied to the same page where unsafeMethodCall is located, this can lead to a dangerous condition and I'd have to take a close look at the page.

Note: it very well can be possible that the 3rd page someotherPage.xhtml contains the dangerous crazyAjaxStuff()

share|improve this question
What do you mean with "there is a reference of"? Can you extend your example to at least include two or three files and actually contains the different calls that you sum up? – Tom Wijsman Aug 20 '12 at 16:02
Edited my answer - see Edit – Toskan Aug 20 '12 at 16:18
Since it looks like you're using JSP, you're probably familiar with Java in general. This sounds like something you'd probably be best off just writing a quick command line utility for. It seems pretty isolated of a use-case to be included as a feature in a released program. – corsiKa Aug 20 '12 at 16:37

I would use ack from the command line. It's fast, it will show you the line numbers in your code and the files where they are. It will do it recursively and the output will be a bit pretty with colors. You can get really fancy with the regex and you can pipe it to itself to search through the files you find with unsafeMethodCall for crazyAjaxStuff. Just read the documentation and get creative. If you need it for Windows see this

Install ack:

curl > ~/bin/ack && chmod 0755 !#:3

Run it, searching all file types, case insensitvely, recursively with literal pattern

ack -airQ "unsafeMethodCall"

Or use the -l switch to just get the file paths, and then pipe that through another ack command or another tool.

ack -larQ "unsafeMethodCall"

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .