• 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

Finding a directory? JSP

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question. Is there a way in JSP or JSLT to get the directory
in which the file resides?

thanks
 
Sheriff
Posts: 67746
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
Which file?
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your question doesn't have much meaning.

There are multiple directories maintained by the server, non of which I think you want. It also depends on the particular server. For example, some servers store the server's startup directory in a JVM system properties, although you'd never want an application writing to this folder.

Many java servers run JSP from inside compressed files such as WARs/EARs, so your question amounts to "What is the current running directory for a compressed file?" which again, doesn't have much meaning since you cannot write to it. If you want to read from it from a JSP, use the URL.

The answer to your question is really that you have to specify the directory yourself via some jvm argument or property file, or if possible, use a database.
[ December 22, 2005: Message edited by: Scott Selikoff ]
 
Michael Huber
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok let me be a little more specific if it helps

i'm using a cms which is written in JSP and i'm uploading a JSP file to it which is basically some JSLT to display some results. the specific jsp file lets call it explore.jsp that I am creating is based on some info entered by the user and it then creates a directory where explore.jsp resides and uses the info to dynamically create the page. When the user saves info to the cms it then generates a directory. Is there a way to grab that directory?

is this even possible?
 
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
If the app is being run as an exploded file system, you can use
request.getRealPath

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
[ December 22, 2005: Message edited by: Ben Souther ]
 
I am Arthur, King of the Britons. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic