Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Servlets
How to load the resources outside WEB-INF?
subbukumararaja chandrasekaran
Greenhorn
Posts: 17
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I have a situation where i need to read a directory which is sitting outside the WEB-INF directory.
How can read that directory as a resource using getResource()?
I guess, we can load only the resources that resides in WEB-INF, using getResponse.
If so, how shall i meet my requirement?
directory structure:
drwxr-xr-x 4 myself myself 304 2011-09-13 17:07 WEB-INF
drwxr-xr-x 2 myself myself 336 2011-09-13 17:07 calendar
drwxr-xr-x 2 myself myself 160 2011-09-13 17:07 css
drwxr-xr-x 2 myself myself 80 2011-09-13 17:07 html
drwxr-xr-x 2 myself myself 1992 2011-09-13 17:07 images
I like to load the images directory as a resource.
URL fileUrl = getServletContext().getResource("html/");
this not returning the actual directory path.
Its returning "jndi:/localhost/application_dir/html"
i am expecting the URL as /opt/tomcat/severs/servername/App/application_dir/html
How to get that value?
Environment: Eclipse + Tomcat6.0
thanks in advance.
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You need to specify a file, not a folder. What are you going to do with a folder?
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
subbukumararaja chandrasekaran
Greenhorn
Posts: 17
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am going to get all the files under the directory "html".
In fact, in web sphere i am able to get that value.
But in
tomcat
the same code is not working.
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Assuming that you are not running out of an unexploded war, you can use getRealPath() and then use normal
Java
file I/O.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
dileep keely
Ranch Hand
Posts: 112
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
,
subbukumararaja chandrasekaran
Greenhorn
Posts: 17
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I was not able to get the file as a resource, but when i try to get the
servlet
real path, i was able to reach the same directory hierarchy level.
From there i picked up the file using the relative path.
thanks a lot to those who has helped.
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Tomcat is not finding my class
404 error
hibernate.properties not being found? Harnessing Hibernate Chapter 2
Questions to Eclipse J2EE IDE
Changing run levels in Linux
More...