Re: Tomcat

Discussion in 'Java' started by Andy Flowers, Jul 9, 2003.

  1. Andy Flowers

    Andy Flowers Guest

    How are you attempting to load the file ? Can you post a snippet of code ?

    Also what errors are you receiving ?

    Also where is the servlet that you are using ?

    "Victoria" <> wrote in message
    news:...
    > Hi,
    >
    > I've installed tomcat in my server, and I have written a servlet
    > programme. In my programme, I will load a background file ( a svg
    > file),
    > but I don't know where I should place the file so that it can be
    > loaded.
    >
    > I have created a folder called test(in the path C:\Program
    > Files\Apache Group\Tomcat 4.1\webapps )and inside the test, I've
    > created a folder call
    > images and then place all the svg file in there, but I discover that
    > they
    > can't be loaded in my servlet.
    >
    > Can anyone tell me how can I fix this problem?
    >
    > Thanks a lot!
    > Victoria
    Andy Flowers, Jul 9, 2003
    #1
    1. Advertising

  2. Andy Flowers

    Victoria Guest

    I am able to run the servlet. However, the servlet has to read a file
    during the process, but I don't know what is the path should I place
    the file for the servlet to read. I can do it by using absolute path,
    but I think it is better to use relative path if I give the servlet
    for others to deploy.

    Maybe I give provide more detail......
    I just want the servlet to read a file called "test.txt", but I don't
    know what is the current directory,
    ie, where should I place the file in order to let the servlet to find
    the file without giving it the absolute path.

    Thanks!
    Tsz Yan

    "Andy Flowers" <> wrote in message news:<luXOa.7352$>...
    > How are you attempting to load the file ? Can you post a snippet of code ?
    >
    > Also what errors are you receiving ?
    >
    > Also where is the servlet that you are using ?
    >
    > "Victoria" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I've installed tomcat in my server, and I have written a servlet
    > > programme. In my programme, I will load a background file ( a svg
    > > file),
    > > but I don't know where I should place the file so that it can be
    > > loaded.
    > >
    > > I have created a folder called test(in the path C:\Program
    > > Files\Apache Group\Tomcat 4.1\webapps )and inside the test, I've
    > > created a folder call
    > > images and then place all the svg file in there, but I discover that
    > > they
    > > can't be loaded in my servlet.
    > >
    > > Can anyone tell me how can I fix this problem?
    > >
    > > Thanks a lot!
    > > Victoria
    Victoria, Jul 10, 2003
    #2
    1. Advertising

  3. Andy Flowers

    Andy Flowers Guest

    Use the API.

    The ServletContext class is what you want.

    i.e. A call to xxx.getRealPath("WEB-INF"); in your servlet will return the
    full operating system path to the WEB-INF directory in a J2EE application.

    There are also other useful methods in this calls, such as getResource(...),
    that you may want to investigate as well.

    So you can store the file somewhere under the web app and get the OS path in
    a machie independent way.

    For example, a new textfiles directory under web-inf can be accessed via
    xxx.getRealPath("WEB-INF/textfiles") or really do take a look at
    getResource(..) and it's usage patterns.

    "Victoria" <> wrote in message
    news:...
    > I am able to run the servlet. However, the servlet has to read a file
    > during the process, but I don't know what is the path should I place
    > the file for the servlet to read. I can do it by using absolute path,
    > but I think it is better to use relative path if I give the servlet
    > for others to deploy.
    >
    > Maybe I give provide more detail......
    > I just want the servlet to read a file called "test.txt", but I don't
    > know what is the current directory,
    > ie, where should I place the file in order to let the servlet to find
    > the file without giving it the absolute path.
    >
    > Thanks!
    > Tsz Yan
    >
    > "Andy Flowers" <> wrote in message

    news:<luXOa.7352$>...
    > > How are you attempting to load the file ? Can you post a snippet of code

    ?
    > >
    > > Also what errors are you receiving ?
    > >
    > > Also where is the servlet that you are using ?
    > >
    > > "Victoria" <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > I've installed tomcat in my server, and I have written a servlet
    > > > programme. In my programme, I will load a background file ( a svg
    > > > file),
    > > > but I don't know where I should place the file so that it can be
    > > > loaded.
    > > >
    > > > I have created a folder called test(in the path C:\Program
    > > > Files\Apache Group\Tomcat 4.1\webapps )and inside the test, I've
    > > > created a folder call
    > > > images and then place all the svg file in there, but I discover that
    > > > they
    > > > can't be loaded in my servlet.
    > > >
    > > > Can anyone tell me how can I fix this problem?
    > > >
    > > > Thanks a lot!
    > > > Victoria
    Andy Flowers, Jul 10, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. %=zerointeractive.it%

    [TOMCAT] Tomcat crashes

    %=zerointeractive.it%, Jan 22, 2004, in forum: Java
    Replies:
    1
    Views:
    403
    Erwin Moller
    Jan 22, 2004
  2. Christos Gravvanis
    Replies:
    0
    Views:
    2,031
    Christos Gravvanis
    Jul 7, 2004
  3. Joe
    Replies:
    0
    Views:
    1,663
  4. Martin Eberle
    Replies:
    2
    Views:
    812
  5. Katerina McLean
    Replies:
    1
    Views:
    3,063
    Juha Laiho
    Dec 10, 2004
Loading...

Share This Page