Solved

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

Posted on 2006-11-03
3
487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

695 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