Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

How to get absolute path of tomcat in java

How to get absolute path of tomcat in java

 
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans
View previous topic :: View next topic  
Author Message
juniormember



Joined: 28 Jun 2008
Posts: 154

PostPosted: Mon Sep 22, 2008 12:15 pm    Post subject: How to get absolute path of tomcat in java Reply with quote

Hi,

I want to get absolute path of tomcat where tomcat is installed. I want to check files is found or not. This files are image files and want to check for profile whether photo available or not. so i have more than one servers and all are on different platform and path. so i have to get path of that folder than search in that folder image files. This is done in java bean and bean is used in jsp
Can we do with this of file java.io.File
getAbsoluteFile()

Give me example of this
Back to top
View user's profile Send private message
seniormember
Site Admin


Joined: 20 Jul 2008
Posts: 77

PostPosted: Mon Sep 22, 2008 12:26 pm    Post subject: Reply with quote

Absolute path can be get through File of IO in java. For linux and windows on both it works.

I have an example of this getting absolute path through java bean

Code:
try{
  File f = new File("temp.txt");
  String path=f.getAbsoluteFile().getParent().replaceFirst("bin","")+"webapps"+f.separator+"myApp";
 
  System.out.println("absolutepath :"+path);
}
catch(Exception e)
{
 e.printStackTrace();
}
Back to top
View user's profile Send private message
juniormember



Joined: 28 Jun 2008
Posts: 154

PostPosted: Fri Oct 03, 2008 4:46 pm    Post subject: Reply with quote

Hi,

This absolute path still not working. It gives me /root something in linux. It is only working fine in windows. I have running this from tomcat/webapps/myApp folder and i am login as root in linux box.
When i do System.out.print it is returning path of
Quote:
/root/webapps/myApp


what i have to do to get /tomcat/webapp/myApp path in linux and windows on both same
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Java,Struts framework, Velocity, JSF, Hibernate, Servlet, JSP, javaBeans All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack