Solved

classpath  to access /read the text file from EAR onto the jsp.

Posted on 2006-11-03
3
483 Views
Last Modified: 2012-05-05
I have a text file version.txt and it is present in the following location: EAR/xyzApp and this xyzApp has the version.txt file along with other jars.

I want to access/read the contents of this version.txt file into the jsp . I want to know what woud I access(the path) this text file  onto my jsp which is present in a webapp inside a directory called WAR. WAR and EAR are in the same levels of hierarchy.

Here is the jsp scriplet  I wrote:


<%@ page import=" java.io.*" %>
<%

try
        {

               FileReader fr   = new FileReader("/EAR/xyzApp/version.txt");
               BufferedReader br = new BufferedReader(fr);
               String buildVersion;
             

                 while ((buildVersion = br.readLine()) != null)
                 {                
                  out.println("The buildVersion is --->"+ buildVersion);
                 
                 }
            }
           
           catch (IOException e)
            {
                               out.println("Uh oh, got an  IOException error!");
                e.printStackTrace();
            }
           
            %>
           
0
Comment
Question by:pacchureddy
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17870481
FileReader fr   = new FileReader(application.getRealPath("/EAR/xyzApp/version.txt"));
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Core java. Create the class with method that do logic for all elements of collection. 1 69
simple java question 3 44
servlet example issue 6 31
arguments to jar 5 15
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now