Where are compiled JSP Java (*__jsp.java) files?

此生再无相见时 提交于 2019-11-26 05:56:08

问题


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.


回答1:


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.




回答2:


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).




回答3:


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.




回答4:


In my case, compiled jsps were under

 /var    
   |--cache    
       |-- tomcat8    
            |--Catalina
                   |--localhost
                          |--projectname
                                 |-- (etc...)



回答5:


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:




回答6:


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




回答7:


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.



来源:https://stackoverflow.com/questions/6833711/where-are-compiled-jsp-java-jsp-java-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!