views:

719

answers:

5

In Eclipse you can configure numerous servers to run inside the IDE, including Tomcat. Depending on your Tomcat configuration, at some point in the life cycle of a webapp your JSP files will get compiled into servlets. These new servlet .class files are stored in the %TOMCAT_HOME%/work directory along with the .java intermediate file created from the JSP. This .java file is very helpful when your JSPs throw exceptions and cite a line number corresponding to the .java and not the .jsp

Update: On my environment (Windows), it is located here:

C:/Documents and Settings/%USER%/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work

Perhaps to answer more completely somebody could post the location for *nix environments.

A: 

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

JW
+1  A: 

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

Peter Štibraný
A: 

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.

Parag
+3  A: 

The easiest way is most likely to ask a compiled JSP page about the source of the 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?

Thorbjørn Ravn Andersen
Great tip (if it works ;-))!
Peter Štibraný
I haven't tried it with JSP pages, but it works fine with plain classes in Tomcat. Also note that some JEE containers know how to work with unexploded web archives. The URL would then probably start with jar: - there is no guarantee that the URL is to a file resource.
Thorbjørn Ravn Andersen
A: 

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"
SourceRebels