This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is there any method for finding

 
ramesh kothakonda
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.

java.lang.String)" target="_blank" rel="nofollow">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
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read Ben's response again. He has answered your question.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • 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,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic