No, i mean that the file is in that path, but i cannot find that path in my server!You may not have access to the directory.
There is no folder called usr in order to get access to its contents.Or you may not have access to the directory.
I think that this path is the one that the servlet is running inSo it exists but tyou may not have access
but what i want to do is to create a file in a directory that i can have access to it.So see the API I referred you to. What you want to do is get the real path of a file called "/hishamww.html", which is a path within your webapp: maybe you want to add some directories within your webapp on top of that; then get the real path of that web-app-relative path via the API I mentioned; then proceed.
String name = context.getRealPath("/hishamww.html");So that is the real file system name of the resource whose partial URL is /hishamww.html within your application context.
The output was: file path: /home2/ziadbu/public_html/hishamww.htmlSo that's where the file is on the disk.
then i tried to enter www.mySite.com/home2/ziadbu/public_html/hishamww.html but i got 404 error which is page not found.Because it makes zero sense. You have addded the real path of the file to a hostname, and you are now expecting that to magically behave as a URL. It isn't a URL. It is just nonsense. The correct URL for that resource is http://www.mySite.com/myApplicationName/hishamww.html, whatever your application context name actually is.
What do you mean by "myApplicationName", do you mean that it is the name of the servlet that i am running?What on earth do you think I mean? Is it ambiguous? Isn't it blindingly obvious?
or tomcat?Tomcat doesn't have a name. So it can't be that, can it? Not much left, is there?
because i tried to write the name of the servlet that i am running but i got 404 error.Sigh. OK. Tell us:
EJP wrote:Hmm, don't you mean this:
In fact I will tell you anyway. It is http://hostname:port/application/hishamww.html. Where you have to make the appropriate substitutions as above.