Getting Absolute Path of Class orJSP
I want to know the absolute path of JSP page and any java class in web project.
file.getAbsolutePath() Not work as only provide the tomcat path.
Any help!
Check this out:
[http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)|http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)]
Similar Messages
-
How to get absolute path of current directory?
Hi, everyone!
I want to get the absolute path of current directory.
Are there some APIs that I can use?
Thanks in advance,
GeorgeHi, dheeraj_tak buddie!
What do you mean in your reply?
"in File class u have all this methods for getting absolute path "regards,
George -
How to get absolute path of a form within the Forms
Aslam o Alikum (Hi)
How to get absolute path of a form within the Forms 6i or 9i
For example
i am running a from "abc.fmx" from C:\myfolder directory
can i get the form path 'C:\myfolder' by calling any any function from "abc.fmb"There is no direct call that will always work. What you need to do is call get_application_property(current_form). This may have the full path in it, depending on if that path was defined when the form was launched. If there is no path, then you need to use TOOL_ENV.GETVAR to read the Forms<nn>PATH and the ORACLEPATH, parse those out into individual directories and then check for the FMX in each.
I already have some code to do all this for you see:
http://www.groundside.com/blog/content/DuncanMills/Oracle+Forms/?permalink=4A389E73AE26506826E9BED9155D2097.txt -
Getting absolute path of a file running in remote machine
Hi,
I want to get the absolute path of a file that will be created in the remote server. Inside a directory XYZ in remote machine, the file will be created and the remote machine's address is xxx.xx.x.x. I have used the following snippet
File f=new File(Filename);
f.getAbsolutePath();
Now, in the output am getting the absolute path of the file as d:/XYZ/Filename. Is there any way to get the output as xxx.xx.x.x/XYZ/FileName ? Can someone please suggest why the server details are not fetched and instead the directory name is fetched.
I am running the program to get absolute path of a file in my remote machine. and for accessing that remote file from my machine, I use xxx.xx.x.x/XYZ/FileName.
Thanks in advance.I'm going to take it a step further and guess at what the OP is going to say next.
On host w.x.y.z there's a file /a/b/share/some_dir/file.txt.
Host w.x.y.z is sharing the /a/b/share/ directory as SHARE.
Client mounts \\w.x.y.z\SHARE as D:, so that he sees D:/some_dir/file.txt.
OP now wants to know not just that D:/some_dir/file.txt is \\w.x.y.z\SHARE/some_dir/file.txt, but also wants to know that on w.x.y.z, SHARE corresponds to /a/b/share.
@OP: If that's what you want, forget it. Part of the premise of file common drive/directory sharing protocols is that the client does not know or care and does not need to know or care what the absolute path is on the serving host. It's none of his business. -
Probelm in getting absolute path of the application folder?
I have problem in getting the absolute path of the application folder.
I wriiten the following line in my action class:
String absPath = getServlet().getServletContext().getRealPath("/");
when i run my application 'DTH' in Tomcat server, I am getting correct path :
C:\Tomcat\jakarta-tomcat-5.0.25\webapps\DTH
But when i run this application in weblogic server, I am getting null value for the above line.
Can any one help me in this?public java.lang.String getRealPath(java.lang.String path)
This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).
so, getRealPath() might not be a very good approach because of its different behavior when used from a war or exploded application.
What you could do is:
1. pass the path as a parameter inside web.xml (config files, log files etc)
2. For dynamic lookup of files you could make use of ClassLoader.getResource().
Hope it helps. -
FileReference / Getting Absolute Path of Upload File
Hi all,
I am relatively new to Flex and I am using Flex SDK 3.4.
I am trying to upload a file to my DB using FileReference.
However, I am unable to get the absolute path of my chosen file, to be displayed in my textbox.
Requesting your help on this issue.
Regards,
Arvind RajI use the following to find the directory src in the WEB-INF/classes directory final URL root = getClass().getResource("/src");
final File rootFile = new File(root.getFile()); -
Getting absolute path of webapps directory
Hi,
Using a Tomcat server, i would like to get the absolute path of the Tomcat/webapps/ directory in one of my JSP pages, without using functions related to Servlet context...is it possible?
In fact my real problem is that i want to open an existing text file in my JSP page. To do so i need the absolute path of it. This file must also be stored in Tomcat/webapps.
Can anybody help me? i've search the forum and found some others topics like this one but didn't find my answers.
ThanksHi,
Using a Tomcat server, i would like to get the
absolute path of the Tomcat/webapps/ directory in one
of my JSP pages, without using functions related to
Servlet context...is it possible?
Any specific reason for not using ServletContext's getRealPath() method ?
In fact my real problem is that i want to open an
existing text file in my JSP page. To do so i need
the absolute path of it. This file must also be
stored in Tomcat/webapps.Hmm,, file i/o is evil. You could use the methods of Class and ClassLoader to read in the file as a stream. The only requirement is that they be in the classpath.
More info here - http://www.javaworld.com/javaqa/2003-08/01-qa-0808-property_p.html
cheers,
ram. -
Getting absolute path of a file in a webapp without using servlet/JSP
Hi all,
I need a small clarification. Is it possible to reterive the absolute path of a file present in a tomcat web application without using Servlet/JSP. I have a normal java class which uses this file to read the configuration parameters. I like to know whether I need to create a seperate servlet which will read the parameters from web.xml.Hi all,
I need a small clarification. Is it possible to
reterive the absolute path of a file present in a
tomcat web application without using Servlet/JSP. What if the file is in a WAR? What do you do then?
I
have a normal java class which uses this file to
read the configuration parameters. There are other, better ways to do this.
I like to know
whether I need to create a seperate servlet which
will read the parameters from web.xml.What do you really want it for? You shouldn't need an absolute path. Use the class loader to get an InputStream.
% -
when I write to a file in the actuel directory,
e.g fw = new FileWriter("file.txt");
how I can get the absolute path of this file? (e.g. C:\dir\file.txt)
thanks stnCaptain Obvious says ..... File.getAbsolutePath();
Thank you, Captain Obvious. -
Get absolute path of a servlet/jsp
<p>
I have deployed an application on JBoss. I need to get the absolute path of a servlet. I used following statement to do that.
getServletContext().getRealPath("");
but from this i get the following
C:\jboss-4.0.2\server\default\.\deploy\sdb.ear\sdb.war\employer
i don't know why there is a dot in between the path which is not correct.
My application.xml is as follow
<module>
<ejb>sdb.jar</ejb>
</module>
<module>
<web>
<web-uri>sdb.war</web-uri>
<context-root>/</context-root>
</web>
</module>
Pls help me with thiskaviratne wrote:
but from this i get the following
C:\jboss-4.0.2\server\default\.\deploy\sdb.ear\sdb.war\employer
i don't know why there is a dot in between the path which is not correct.Me neither, but that dot shouldn't harm. It just means "current directory". Effectively that path is exactly the same as:
C:\jboss-4.0.2\server\default\deploy\sdb.ear\sdb.war\employerWhich problems are you occurring with this? It might be worth an issuereport at the JBoss site though. -
Getting absolute path of a JAR from its classfiles?
I am creating a class witch is going into a jar-file. With this jar-file I will also have another file (config/data-file). That file will allways be in the same directory as the jar-file.
What I am wondering is: How can i programatically get the path of the "current" JAR file the "current" class is contained within, so that I can open/read the config/data file?
Today I use a method which i hope I can replace with a better method:
private static String jarfile="progconf.jar";
private static String projectname="ProgramConfig";
public static String getJarPath() throws Exception{
try{
String jvc = System.getProperty("java.class.path")+";";
if(jvc.indexOf("\\"+jarfile+";")>0){
jvc = jvc.substring(0,jvc.indexOf("\\"+jarfile+";"))+"\\";
jvc = jvc.substring(jvc.lastIndexOf(":")-1); //Filsti
}else if(jvc.indexOf("\\"+projectname+";")>0){
jvc = jvc.substring(0,jvc.indexOf("\\"+projectname+";"))+"\\";
jvc = jvc.substring(jvc.lastIndexOf(":")-1); //Filsti
}else{
throw new Exception("Klarte ikke finne JarPath!");
return jvc;
}catch(Exception ex){
throw new Exception("getJarPath-" + ex.getMessage());
}-Wolfladcheck out my replies at the link shown below:
http://forum.java.sun.com/thread.jsp?forum=57&thread=494736
;o)
V.V. -
how to manipulate or to change the folowing absoulute path
to worrk in web browser
String p = C:\Program Files\Tomcat\webapps\myApp\tempData\regardsThis sounds more like a web application problem than a Java problem. In general, most if not all web servers will ONLY serve files that exist in a relative path below the root directory of the web service. This is for security reasons so that outsiders can't just wander around on the server's hard disk at will.
HOWEVER, some do allow access to absolute paths IFF the access rights to those paths are set properly for the user the web server runs as.
I would suggest you post your question on a forum oriented toward the web server you are using, or contact your web host's support department (not usually fruitful for these types of problems). -
How can I get the server absolute path of virtual directory?
Problem context:
absolute path of my application at JRUN server is
c:\testing
nd url is
http://kaspak/test
( kaspak is a machine local to server i-e client nd server r at same machine )
I m uploading a file nd saving it at server.
PROBLEM:
server save my uploaded file at
C:\Program Files\Allaire\JRun\servers\default
[ a path where server is installed ]
while I want to save it at directory
c:\testing\uploadfiles
How can I achieve this???
waiting for quick reply..
KasPakhere is a function for which u said,
protected void readAndSaveFile(MultipartInputStreamHandler in,
String boundary,
String filename,
String contentType) throws IOException
A utility method that reads a single part of the multipart request that represents a file, and saves the file to the given directory. A subclass can override this method for a better optimized or differently behaved implementation.
again saving a file, or uploading a file is no problem,
but saving a file at our desired location,
nd this can only be done if we know reall/absolute path of our application at server,
i-e we need an API which can tells the absolute path of our application.
e.g
our application url is http://kaspak/testcode
we need its absolute mapping to directory on server
e.g it it is at c:\testcode
if we get the absolute path then we can pass it in above function or in File class constructor.
isn't it??
I think in this way i can save file at other location.
But how i can get absolute path?????
thanks for ur reply,
nd waiting for ur reply again.
wbw
kaspak -
How to get the absolute path of logicalhost server domain on Windows Sun
i am reading a file from Xsql Folder, that is located in the logicalhost Sun\AppServer\domains\domain1\applications\j2ee-apps.(IN Sun Application Server)
I am pretty sure that using the absolute path will solve this issue, so my first question is: How to get the absolute path of logicalhost server domain on Windows?
i tried with System.getProperty("com.sun.aas.instanceRoot").
but i am able to retrive Sun\AppServer\domains\domain1 upto this .i am unable to retrive Sun\AppServer\domains\domain1\applications\j2ee-apps.
please suggest me how u can get absolute path in sun application serverTake a look here
-
Getting absolute file name using af:inputFile
Hi all,
Can you help me how to get absolute file name (e.g., C:\Documents\file.txt) using <af:inputFile> component or using any another JSF component.
Thanks in advance :)))we can't get absolute path using inputFile, we can get only the file name. as per my knowledge we don't have any other component also.
i have one of my requirement i need to read file from specified folder, so i have hard coded my folder name in my managed bean.
Maybe you are looking for
-
Report Painter Library: troubles with new field in the additional structure
Hi, ALL! I'm creating a new field in the Report Painter table GLFUNCT. Do do it I created my field in the additional structure GLDBZ for GLFUNCT and create an row in the T804C table for new field. Who has expirience in customizing using T804* tabl
-
Save as Draft Problem using library computer
This afternoon I tried to save-as-draft a LONG & INVOLVED communication in .MAC e-mail at a public computer in the library. When I went to my draft folder to ensure it got saved, it was not there. Can someone give me direction on this? I suppose it g
-
HT4437 air play only audio not video way
trying to play a movie i rented from my phone on the apple tv but i only get audio no pic y
-
Question re optimize/cleanup/compress in Standard
Hello, I have Acrobat 9 pro on one computer, and Acrobat 9 standard on another. When scanning, some combination of settings (I can't figure out why) is causing automatic compression. In pro, I just go into cleanup and make sure the entire document
-
Can't connect to the ICloud server since upgrading my IPhone 5S to iOS 8.1.
**** please! Since upgrading to iOS 8.1 yesterday I have been unable to connect to the iCloud server. Keep getting a message that need to read the new terms and conditions, which I click the button to view but then get an error message that can't con