tags:

views:

84

answers:

5

I have this Java code some other person wrote, specifically JSPs. I am trying to understand where everything is.

In my index.jsp (the main file which is loaded) it imports a certain namespace (I suppose tomcat does all the compiling, I don't know):

<%@ page import="org.sgrp.SearchResults"%>

This physical location doesn't exist in my CLASSPATH so I suppose it's referring to a namespace inside the .jar code structure (correct me if I'm wrong).

So how am I suppose to find the source code for this? Does Tomcat set a specific CLASSPATH location for each project?

EDIT

I'm trying to understand if Tomcat follows a certain structure so I can find where the source code for this stuff is.

+1  A: 

jars are compressed javabyte code. In order to get the sources you'll have to decompile them. There are a few utilities out there, but working with decompiled code is a bit of a nightmare if you ask me, I wouldn't recommend it, especially not if you didn't already know this. :D

The source code will generally be stored elsewhere.

As far as your specific questions on Tomcat, I don't know, having never working with Tomcat before.

OmnipotentEntity
A: 

class path is, in my experience, commonly set in the ant build file of each project

NimChimpsky
+1  A: 

You can look for the jars in two places:

  1. /web-inf/lib directory (it has all the custom jars in use by the app)
  2. The build file (mvn, ant etc)
zengr
where's the build file usually located in Tomcat?
Luca Matteis
if you are using ant, look for build.xml generally in the parent folder and if you are using maven, look for pom.xml (it lists all the jars used)
zengr
The ant/maven build file is used to build your web app for deployment into Tomcat - so it wont be within Tomcat but within the source code folder, which I believe the OP does not have access to?
JoseK
+1  A: 

Source code might not be there at all. So, first of all, you need to find which jar exactly has that imported class. Then just search the web to find the project/API website. There you can look for the source, if its an open source library. Otherwise, decomplilation is the only option left, and that might not be very helpful.

Adeel Ansari
+1  A: 

From the perspective of a web application, class or resource loading looks in the following repositories, in this order:

* Bootstrap classes of your JVM
* System class loader classes 
* /WEB-INF/classes of your web application
* /WEB-INF/lib/*.jar of your web application
* $CATALINA_HOME/lib
* $CATALINA_HOME/lib/*.jar

from the docs.

The most likely locations for classes specific to your application are the WEB-INF/lib/*.jar and WEB-INF/classes. However as others have mentioned, this will contain compiled class files and you wont be able to see the exact java source (even after decompiling)

JoseK