score:52

Accepted answer

You will find it in

projectworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0

This is the default place where Eclipse 3.4 publishes the project. However, this can be changed by changing the settings in your 'Server' view.

score:-1

I assume it would be the same location relative to your workspace.

score:0

If you're using the Tomcat Maven Plugin in Eclipse, then your Tomcat related files would be in <project folder>/target/tomcat instead, including the tomcat work folder at <project folder>/target/tomcat/work, and you can descend from there to find your jsp .java files, etc.

(I know this may not apply to everyone, but since Tomcat Maven Plugin is a popular way to develop with tomcat and using maven to manage dependencies and help with the build process, I hope this info may be helpful for some people).

score:1

You can change it by setting scratchDir parameter in web.xml configuration of your server (in Servers project, not in your application web.xml!).

score:3

  1. On Windows, the easiest way to go to your Eclipse's Tomcat deployment location is to just right-click on the Tomcat instance in the Servers view and click "Browse Deployment Location..."

    You should see Eclipse neatly opening a Windows explorer taking you to the exact location. In my case it takes me to:

    C:\eclipse4.3.2-jee-kepler-SR2-win32\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps

    From there, you can easily browse to the "work" directory as shown below.

    If you follow this, you never have to remember the location!

    Eclipse Servers View:

    enter image description here

    Windows Explorer Opens:

    enter image description here

    Windows Explorer (click on address bar to reveal full path):

    enter image description here

  2. On Amazon EC2 Linux (this has nothing to do with Eclipse however), the Tomcat work directory is at /var/cache/tomcat7/work

    [ec2-user@ip-172-31-xx-xx ~]$ uname -a
    Linux ip-172-31-xx-xx 4.1.10-17.31.amzn1.x86_64 #1 SMP Sat Oct 24 01:31:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    
    [root@ip-172-31-xx-xx] /usr/share/tomcat7 $ ls -l
    total 4
    drwxr-xr-x 2 root root   4096 Jan  5 15:18 bin
    lrwxrwxrwx 1 root tomcat   12 Jan  5 15:18 conf -> /etc/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 lib -> /usr/share/java/tomcat7
    lrwxrwxrwx 1 root tomcat   16 Jan  5 15:18 logs -> /var/log/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 temp -> /var/cache/tomcat7/temp
    lrwxrwxrwx 1 root tomcat   24 Jan  5 15:18 webapps -> /var/lib/tomcat7/webapps
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 work -> /var/cache/tomcat7/work
    
    [root@ip-172-31-xx-xx] /var/cache/tomcat7/work/Catalina/localhost/init/org/apache/jsp $ ls -la
    total 180
    drwxr-xr-x 2 tomcat tomcat  4096 Jan  6 06:37 .
    drwxr-xr-x 3 tomcat tomcat  4096 Jan  6 06:37 ..
    -rw-r--r-- 1 tomcat tomcat 54172 Aug 17  2012 index_jsp.class
    -rw-r--r-- 1 tomcat tomcat  2106 Jan  6 06:37 index_jsp$FileComp.class
    -rw-r--r-- 1 tomcat tomcat  1034 Jan  6 06:37 index_jsp$FileInfo.class
    -rw-r--r-- 1 tomcat tomcat  6460 Jan  6 06:37 index_jsp$HttpMultiPartParser.class
    -rw-r--r-- 1 tomcat tomcat 89445 Aug 17  2012 index_jsp.java
    -rw-r--r-- 1 tomcat tomcat  2210 Jan  6 06:37 index_jsp$UplInfo.class
    -rw-r--r-- 1 tomcat tomcat  1208 Jan  6 06:37 index_jsp$UploadMonitor.class
    -rw-r--r-- 1 tomcat tomcat  1184 Jan  6 06:37 index_jsp$Writer2Stream.class
    

score:15

The easiest way is most likely to ask a compiled JSP page about the source of the byte code.

From http://www.exampledepot.com/egs/java.lang/ClassOrigin.html:

// Get the location of this class
Class cls = this.getClass();
ProtectionDomain pDomain = cls.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
URL loc = cSource.getLocation();  // file:/c:/almanac14/examples/

Hopefully this helps. What is it you want to do?

score:19

Go to "Servers" window -> double click on your tomcat instance -> clik "Open launch configuration" -> go to "Arguments" tab.

Look for variable definition like this:

-Dcatalina.base="/Users/dirtyaffairs/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0"

Related Query

More Query from same tag