Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: Tomcat

Reply
Thread Tools

Re: Tomcat

 
 
Andy Flowers
Guest
Posts: n/a
 
      07-09-2003
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: om...
> 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



 
Reply With Quote
 
 
 
 
Victoria
Guest
Posts: n/a
 
      07-10-2003
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: om...
> > 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

 
Reply With Quote
 
 
 
 
Andy Flowers
Guest
Posts: n/a
 
      07-10-2003
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: om...
> 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: om...
> > > 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Which JVM to use for Tomcat 5.0.28 and Tomcat 5.5.4? Katerina McLean Java 1 12-10-2004 10:55 PM
Tomcat 4.1.31 - huge count of webapps, Tomcat hangs up Martin Eberle Java 2 12-03-2004 07:10 PM
Tomcat Web application manager - Virtual host Tomcat 4.30 + Apache2 + JK2 connector with multi IPs Joe Java 0 07-12-2004 03:06 PM
Apache Tomcat 4.1.24: problem with Tomcat Administration link Christos Gravvanis Java 0 07-07-2004 05:21 PM
[TOMCAT] Tomcat crashes %=zerointeractive.it% Java 1 01-22-2004 12:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57