Solved

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

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven project error 5 54
java stored proc example 9 29
servlet example 17 28
hibernate example using maven 12 41
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

813 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

11 Experts available now in Live!

Get 1:1 Help Now