Skip to Content
Former Member
Sep 09, 2008 at 02:44 PM

Determine current directory/folder of JSP file in a CR Web Project.


Afternoon all.

Very sorry if this is a stupid question or wrong forum but am at my wits end and finally thought I would ask help.

I am very new to Java and Eclipse and Crystal Reports but have been given task of creating Reports that

are accessible via the web. Ill try explain my situation but forgive me if I get terminology wrong and all that.

I have got my report working (well sort of, still learning lots), the one point I am stuck on is referring to a

text file which holds my database connection details (username, passwordu2026)

I do not want to use an absolute path for the location of this text file (Conn.txt). I want to refer to Conn.txt

depending on its location in relation to the directory which holds my webcontent. (C:\Tomcat\webapps\Grasslands)

I use a function to extract the contents of my file into an array.


It works fine. The problem is that I donu2019t know for certain that the Grasslands folder (which contains all the

jsp, rpt u2026 files) is going to be in the Tomcat\webapps folder.

Basically if I know for a fact that the Conn.txt file will always be in the same directory as the JSP file

which loads the report, how do I determine what directory the JSP file is located in.

I have tried using:

getContents(System.getProperty("user.dir") + "\\Conn.txt")

but that always points to the Tomcat bin folder.

I tried using a system variable - PATH but could not work out how best to go about this.

Also I am not confident this is the best way.

Surely there must be a way to determine which folder my JSP file is located in?

Again I apologise if this is a question already asked else where but Im getting desperate and google can

only help so much 😊

Thanks all.



Edited by: Darren Jackson on Sep 9, 2008 5:05 PM