[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 491
  • Last Modified:

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

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
pacchureddy
Asked:
pacchureddy
1 Solution
 
objectsCommented:
FileReader fr   = new FileReader(application.getRealPath("/EAR/xyzApp/version.txt"));
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now