• 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

context root. accessing directory from browser

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Though this is not jsp, but jhtml the problem is somewhat similar.

Scenario:

1. jhtmls are inside this:

KDCATG/modules/b2b/htdocs/global/en/b2b/private/admin/esrvtool/

2. I access these jhtmls in this way:

<server>:<port>/dyn/dyn/global/en/b2b/private/admin/esrvtool/
<some>.jhtml

3. /dyn is the context root.

4. Now I'm creating text file under a directory:

KDCATG/modules/b2b/htdocs/global/numberfile/

5. I want to download these text files after redirection from a
servlet:

<server>:<port>/dyn/dyn/global/numberfile/<some>.txt

Problem:

If I try to create the file using the relative path like "/dyn/dyn/
global/numberfile/" it cannot find the path, which is normal, there is
no such path. So I had to give the whole path. Now how to create the
file without a path which is not dependent on my own directory
structure, but should be dependent only on the webapp directory
structure.

Similarly, if I want to access as in #5 step, its giving 404: resource
not found. But, atleast here, it should access the directory, but it's
not.

Or, if I just want to see the directory listing in the browser from
<server>:<port>/dyn/dyn/global/
it doesn't show the "numberfile" directory.

So, how I can do it with relative path? Do I need to configure
somewhere?

And ok, I printed the req.getContextPath() --> /dyn
and
req.getRealPath(req.getContextPath()) --> null
[ December 11, 2008: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If I try to create the file using the relative path like "/dyn/dyn/
global/numberfile/" it cannot find the path,



Relative paths don't start with a "/" which represents absolute path from the context root.
 
imran sujoy
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response. Now my question can be refreshed as, how can I create a directory under root, such as /data/file/ under which I'll create all my files, and I want to make them download from the browser, when a link is clicked?
 
Srikanth Nutigattu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, i can say only regarding jsp/servlet containers...
any thing you place in any subdirectory of context root apart from WEB-INF can be directly accessed....
 
reply
    Bookmark Topic Watch Topic
  • New Topic