37

I am getting a javax.servlet.jsp.JspException in one of the jsp files that my website is trying to render (survey.jsp). However, the stack trace does not give me the the specific line in jsp where it fails but rather the line number where it fails in (survey_jsp.java:787), which seems to be the compiled JSP file. Where do I find such files, so that I know what line is throwing this exception?

Thanks

EDIT: These files live in the /work directory if you are using tomcat as Will suggested in the comment below.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Sam
  • 2,398
  • 4
  • 25
  • 37

7 Answers7

77

The compiled JSP files are by default available in the /work folder of the Tomcat environment. There should be a subfolder Catalina which in turn has a subfolder representing the domain name which defaults to localhost. There in turn should be the project folder which in turn contains package hierarchy org.apache.jsp with therein the compiled JSP files.

Tomcat
 |-- backup
 |-- bin
 |-- conf
 |-- lib
 |-- logs
 |-- temp
 |-- webapps
 `-- work
      `-- Catalina
           `-- localhost
                `-- projectname
                     `-- org
                          `-- apache
                               `-- jsp
                                    |-- survey_jsp.class
                                    `-- survey_jsp.java    <--- here

Unrelated to the concrete problem, there should be a root cause part in the stacktrace of the JspException which usually contains more detail about the real root cause of the problem. Read a bit further in the stacktrace. By the way, do you know that putting raw Java code in JSP files is considered a bad practice? It makes problems harder to debug as you encounter now.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I am using struts to enforce the MVC structure, so no raw java is being used inside the jsp. The error arises because it " Cannot find bean: "blah" in any scope" – Sam Jul 26 '11 at 17:47
  • Then figuring the generated Java source code offers no additional benefit. It would only be all abracadabra for you. The real work should be done on understanding the *real* error message (which you finally figured down in the stacktrace) and then fixing the view/model/configuration accordingly. I.e. make sure that the bean "blah" is in the scope. – BalusC Jul 26 '11 at 18:06
  • I've never ever seen JSP files without raw Java code, tbh. – low_rents Jul 28 '17 at 10:21
  • In my case my tomcats work folder is an empty folder. How to update this folder – Ram Thota Nov 03 '17 at 09:59
  • @BalusC I am seeing WEB-002dINF folder in the path mentioned in the answer. e.g. "opt/tomcat/work/Catalina/localhost/_/org/apache/jsp/WEB_002dINF/jsp/app/error/error_jsp.class" Any idea what is the logic of WEB-002dINF naming convention? I want to mark some paths as whitelisted for Path Traversal. – Bhushan Karmarkar Sep 19 '22 at 10:30
10

I am using Intellij to learn JavaEE and in order to view some features when jsp translating into servlet, I also have to find the file.

I didn't find it below <tomcat_home>/work/*. I finally find that the file is under the ~/.IntelliJIdea15/system/tomcat/ folder( tree structure showing from ~/.IntelliJIdea15/system/tomcat/)!

Name related to project name
 |-- conf
 |-- logs
 `-- work
      `-- Catalina
           `-- localhost
                `-- projectname and type
                     `-- org
                          `-- apache
                               `-- jsp
                                    |-- survey_jsp.class
                                    `-- survey_jsp.java    <--- here

If you still can't find it under Intellij's home folder, you may have to try using

find . | grep 'nameOfYourJsp_jsp.java'

in suitable parent folder.

Tony
  • 5,972
  • 2
  • 39
  • 58
  • This is only the case if the IDE is configured to take over deployment control from server. This is not true in normal/production environments. – BalusC Dec 29 '15 at 11:23
  • I didn't make any configuration for it. So it is the default behavior of intellij? – Tony Dec 29 '15 at 11:57
5

If the page did not compile you should find it somewhere below <tomcat>/work/*. The full path depends on you environment. If you can't find it there you should start your Tomcat in debug mode, it definitly keeps .java files failed to compile (Tomcat 7).

home
  • 12,468
  • 5
  • 46
  • 54
2

adding one more scenario: with eclipse and tomcat to run Spring MVC: you should find the _jsp.java files in your workspace folder:

\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost[project Name]\org\apache\jsp\

also this is really based on your setting in tomcat: enter image description here

mate00
  • 2,727
  • 5
  • 26
  • 34
carter Liu
  • 21
  • 1
1

In my case, compiled jsps were under

 /var    
   |--cache    
       |-- tomcat8    
            |--Catalina
                   |--localhost
                          |--projectname
                                 |-- (etc...)
pkaramol
  • 16,451
  • 43
  • 149
  • 324
0

from the oracle document

javax.servlet.jsp.JspException :: A generic exception known to the JSP engine; uncaught JspExceptions will result in an invocation of the errorpage machinery.

i even used to get this whenever i used scriplets in my code

my advice : don't use scripltes even it might seems to develop code easy but with all due respects, its a big head - ache to maintain a scriplets code. TRUST ME

Mateen
  • 1,631
  • 1
  • 23
  • 27
-4

C:\Users\ADMIN\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\JspDemo\org\apache\jsp

change link according to you project name.