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 this

kaviratne 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.

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,
    George

    Hi, 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.

  • 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.
    %

  • 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.
    Thanks

    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?
    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.

  • 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.

  • 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)]

  • Get real path in non servlet class

    Hi,
    I've created a ServletContextListener class that loads a thread at application startup and kills it and application shutdown.
    The thread periodically monitors a specific file. I need to pass a real file path to the thread, but because the thread class is not a servlet, I cannot use the getServletContext().getRealPath("").
    What are my options?

    The ServletContextListener has access to both the ServletContext as well as the Thread.
    So the solution can be to get the path in the listener and pass it as a parameter to the constructor or a setter method of the thread.

  • Get absolut path of a file

    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 stn

    Captain Obvious says ..... File.getAbsolutePath();
    Thank you, Captain Obvious.

  • 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 Raj

    I 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 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());
    }-Wolflad

    check out my replies at the link shown below:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=494736
    ;o)
    V.V.

  • Getting Absolute path

    how to manipulate or to change the folowing absoulute path
    to worrk in web browser
    String p = C:\Program Files\Tomcat\webapps\myApp\tempData\regards

    This 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).

  • To get the absolute path of a file in JSP

    Hi,
    I want to include a HTML page in a jsp.The path of the jsp should not be hot coded.So that i can get the path from the jsp file i am running and then concat the correspondinghtml file name to the absolute path of the jsp file i am running.What can i do to get the absolute path of the jsp file.

    I dont know if there is a way to get the path of the current jsp - but you sure can get the path to your web application using the ServletContext's getRealPath() method and then if you have stored the html (say x.html) in a folder (called, say 'static') immediately under your application root,
    String contextPath = application.getRealPath("/"); //path to your application ctxt
    String htmlFilePath = contextPath.append("/static/x.html");ram.

  • 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..
    KasPak

    here 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

Maybe you are looking for

  • Exporting pdf leads to errors in Acrobat...

    Hi, everyone. I'm hoping someone here might be able to help me. I posted this same issue in the Mac Acrobat forum last week, but I still have not received an answer, so I'm hoping I'll have better luck here. Maybe this is an issue with the Indesign C

  • Change default monitor linux uses BEFORE X is loaded

    i can't seem to find the answer for this. eveything talks about monitors in x --  i need to get linux to boot up on the VGA  while the TV plugged in via HDMI --  if tv is plugged in it boots up on the tv if i boot with only my VGA plugged in it's fin

  • Reg. Control indicators for controlling area NCCP do not exist

    Dear Experts I want to create purchase requisition (ME51N) then the following error occured. Pls help me. Control indicators for controlling area NCCP do not exist Message no. KI102 Diagnosis No control indicators exist in fiscal year 2008 for contro

  • Getting rid of white space when importing Flash

    When I import a Flash file onto Dreamweaver, I am getting the white space (canvas) that I don't want. I previously used Flash and Dreamweaver 8, and I added this to the html to get round it (highlighted by *'s): <div id="quick"> <object classid="clsi

  • ITunes 5 Computer Authorization issue?

    I deactivated all 5 computers associated with my iTunes account. I try to authorize a new one and it still says I have 5 authorized. I check my account and it says I have only 1 authorized, and still cannot authorize the second computer. Any ideas?