• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

context.xml + Help Needed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the requirement to access the directory outside the build path of the web-application. So i created
a context.xml file and put this file in my webapplication web-inf folder. The context file contains the docbase that point
the absolute path of directory structure

Please let me know to access the resources outside the build path (like images , htmls files) what all steps i will be need

Regards,
Maneesh Chauhan
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you want to place your files images etc.. outside the webapps directory?
 
Maneesh Chauahn
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i want to place the html files and images outside web directory
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you saying that you want your web application to exist outside of the container hierarchy or do you want to access files that are outside of your web application's directory structure.

Creating a context.xml file has nothing to do with the latter.
Please explain, in detail, what it is that you're trying to do.
 
Maneesh Chauahn
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have some html files and images that are present in the build path of the web application. These files increased the size of the war file , but i want to put these files outside the build path (to other location).

So how can i access these html files and images which are outside the build path. I knew that i used file stream to access the same but is there any way to access the same means by using the context.xml file

Regards,
Maneesh
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No,

If you want to serve up static files from outside your web application, you'll need to write a servlet that streams them.

If your servlet container is being run in conjunction with a web server like Apache HTTPD, there are ways to route only JSP/Servlet requests to the container and allow the web server to serve up the static resources.
This is a lot of work to set up and maintain, just to reduce the size of a war file though.
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

These files increased the size of the war file



So? Why is this a concern?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes Ben Souther reply is correct. but you can do that in easy way. you don't need to write new servlet. you can have static resources in another webapplication.

below steps may help you to understand better
1) Have all your jsp's in one web application,lets say 'webapp1'
2) Have your all static source(like images and css files) in another webapplication, lets say 'webapp2'
have directory structure of images and css files in webapp2 like this

webapp2 -> web-inf |->config.xml
|->css ->css files
|->images -> image files

3) deploy both into appserver or web server
4) you can access webapp2 resources in webapp1 like this

/webapp2/images/*.jpg or /webapp2/images/*.css
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

We're pleased to have you here with us in the Servlets forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, you can use initials for your first and middle names but not for your last name (surname)

You can change it here


Thank you,
-Ben
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic