Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Directory creation in the server

 
vikas malviya
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

i wanted to make a directory in the server(Apache),i had already tested locally where i was succesfull,but application is not working after i uploaded the file in the server,the details are as follows
1.
created a small application which create the directory of images.
the method uses for the getting the path is
.getServletContext().getRealPath("/")
now my question is does using this method can we get the path from the apache server and if not how can i found the path of mine file?

thanks in advanced.
 
Shashank Rudra
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.getServletContext().getRealPath("/") gives you just a way to get the absolute path of your context. i.e. the root of your application. But after this you will have to append to it the relative location of your file to get the complete path. For say you are using Tomcat - you have your application myApp deployed on Tomcat. You have tomat installation directory as C:\Tomcat. You will see a directory with name myApp inside tomcat/webapps directory. .getServletContext().getRealPath("/") - will give you C:\Tomcat\webapps\myApp. Relative path will be where inside this directory you have placed your file. And we will have to add this to the context path to get the absolute path.

 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!