• 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

is there any method for finding

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi javaranchers,
Is there any method for finding absolute path of Webapplication in servltes.
if our webapplication folder name is mywebapp .
It is available in webapps folder. May i know the absolute path of mywebapp folder.

if you give me answer i will be very thankfull in advance.
thanking you
regards
[ November 14, 2006: Message edited by: Bear Bibeault ]
 
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 you're app has been deployed as an exploded file structure, ServletContext.getRealPath("/") will return the path.

If you're app was deployed as a packed war archive then, there really is no path and getRealPath will return null.

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)
[ November 14, 2006: Message edited by: Ben Souther ]
 
ramesh kothakonda
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for giving response,
Actually my requirement is to upload a file in specific directory.
Suppose I am having directory structure like
webapps
application
WEB-INF
IMAGES
some static resources
I want to upload a file into images folder.
In what way i can get the real path of our webapplication .I am doing this one in struts.

Thanking you
 
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
Please read Ben's response again. He has answered your question.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simple way to do this is,

1. Add your real path where you want to upload files to application.properties file.

2. Read URL from the property file from your JSP or Servlet.

In furture if you want to change URL, you just need to change in property file.

HTH,
reply
    Bookmark Topic Watch Topic
  • New Topic