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 ?

[906 byte] By [intelchipa] at [2007-9-23]
# 1

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 !

intelchipa at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 2
> out.println(file); // to get the absolute path i did> this ...but its not working !How is it not working?
jverda at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 3
what i mean , if i choose to browse C:/mycopy/abc.txt then the nextpage.jsp should show me c:/mycopy/abc.txt...how to do it ?something with path problem...i cant figure out
intelchipa at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 4
>How is it not working?it is showing c:\sun\webserver6.1\config\ijk.txt........the whole webserver path.but i want the exact real path.
intelchipa at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 5

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.

jverda at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 6
> >How is it not working?> > it is showing> c:\sun\webserver6.1\config\ijk.txt........the whole> e webserver path.> > but i want the exact real path.That is the "exact real path."
jverda at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 7

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.

intelchipa at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 8

> 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.

jverda at 2007-7-11 > top of java,Java Essentials,Java Programming...
# 9
problem resolved. it was weired problem in firefox . but in IE its ok. question closed.thank you very much.
intelchipa at 2007-7-11 > top of java,Java Essentials,Java Programming...