Solved

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

Posted on 2006-11-03
3
482 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

708 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

12 Experts available now in Live!

Get 1:1 Help Now