exact path
browsefile.jsp
==============
........
<td colspan="5" nowrap><font size="2" face="Comic Sans MS">
<input type="file" name="filepath">
</font></td>
.............
submit button
nextpage.jsp
============
......................
String fileName=request.getParameter("filepath");
out.println(fileName);
..............................
Suppose, i choose to browse the file in browse.jsp , c:\myfolder\ijk.txt
but in nextpage.jsp it prints
c:\sun\webserver6.1\myserver\config\ijk.txt by out.println(fileName);
How can i get exact path"c:\myfolder\ijk.txt" in nextpage.jsp ?
sorry
nextpage.jsp
==========
String fileName=request.getParameter("filepath");
//out.println(fileName);
java.io.File file= new java.io.File(fileName);
file = file.getAbsoluteFile();
out.println(file); // to get the absolute path i did this ...but its not working !
I still don't understand what the problem is.
However, in general, in a web context don't concern yourself with absolute paths on the server's file system. Things are based in the webapp's context root.
I doubt that the API methods are misbehaving here. More likely you're misunderstanding something about how the whole thing works. From what you've said, though, I'm not able to figure out what your misunderstanding is.
Ok...let me tell what i exactly i want .
browsefile.jsp
==============
..............
<td colspan="5" nowrap><font size="2" face="Comic Sans MS">
<input type="file" name="filepath">
</font></td>
...................
// so here you can browse a file to choose. right ?
// now say, you chose c:\myfolder\ijk.txt with the file browser.
i want to get a print in the next page "c:\myfolder\ijk.txt" ....how can i get it ?
n.B reason i am saying i want to make a InputStreamwith this filepath.
> i want to get a print in the next page
> "c:\myfolder\ijk.txt" ....how can i get it ?
I don't believe you can. Okay, maybe you can, but you can't generally do anything with it.
If I understand correctly, you're picking a file on the client, then submitting that file to the server. In your case, the client and server appear to be the same machine, but in general they're not. The path on the server will naturally be different than the path on the client. The server doesn't know that they're the same machine. You might be able to pass the "real" client-side path along in a separate parameter, but then the server can't do anything with it anyway--it can't access the client's file system. Doesn't matter if they're the same machine.
I might be totally missing the point here, so if I am, sorry.
Or maybe is myfolder a shortcut to the other path? If so, I think you're out of luck that way to. I don't think Java recognizes shortcuts.