1

Question: How can I get at runtime the filepath from where the server is loading the servlet class that was generated for a given JSP file? For instance, I have a JSP file research_form_manage.jsp that is accessible at a certain URL and I want to log the filepath for the generated __research_form_manage.java that is handling my request (it will be in a cache on the server probably).

Context: I have a web application deployed on WebLogic 12c (that I automatically deploy using JRebel from IntelliJ). Sometimes I get errors because the JSPs are loaded from some cache and are outdated. I manually cleared the cache locations I know (tmp\ and cache\ from under my_domain\server... and then restarted the server) but the file is still loaded from the cache.

I found this idea about how to locate where cached classes are loaded from and I would like to log the location of the jsp translated servlet using somthing like ...class.getProtectionDomain().getCodeSource().getLocation();

wi2ard
  • 1,471
  • 13
  • 24

1 Answers1

0

I found a way that seems to work, by adding in the JSP file this line: <%= getClass().getProtectionDomain().getCodeSource().getLocation() %>

The class is in the domain\servers...\tmp folder that I deleted, so I don't know where the old version of the jsp was coming from.

This code does what I needed but it's not that nice because it means I have to modify the JSP and then remember to clean it before pushing. I was thinking initially to put a breakpoint somewhere and add a watch with an expression that would give this filepath based on the jsp file name.

So if anybody has a better way, please share.

wi2ard
  • 1,471
  • 13
  • 24