my dog learned polymorphism
The moose likes Tomcat and the fly likes Error loading file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Error loading file" Watch "Error loading file" New topic

Error loading file

Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904

I'd like to load a file from my Servlet and read it's contens, but
I get an "Error loading file" when the code is run.

Where should I place the file ?

My servlet class file lies in: Tomcat/webapps/examples/WEB-INF/classes/
where the file also lies. I contact the Servlet via the following URL:

Thanks in advance,

/Svend Rost
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Look up ServletContext.getResource or ServletContext.getResourceAsStream.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13035
Your use of /servlet/ in the URL indicates you may be getting tangled up in the "invoker" servlet conventions. Read this FAQ on the invoker here at the ranch.
I agree. Here's the link:
subject: Error loading file
It's not a secret anymore!