I faced a very strange problem. Got crazy with this Someone must have a look at this.
What i am doing ? O Read a file in a jsp page.
O Hit a servlet.
O Print the complete URL of the file.
Nothing else. Task is as simple as that.
What i wrote ?
JSP Code:(Inside form Tag)
Servlet Code: (Inside doPost)
What i got ?
Try #1: Browser: Internet Explorer 6.
Output : URL is C:\Documents and Settings\vignesh.d\Desktop\J2EETutorial.pdf
This is what i expected.
Try #2: Browser: Mozilla Firefox 3.x
Output : URL is J2EETutorial.pdf
you can notice that the file name alone is printed and not the complete path.
Try #3: Browser: Internet Explorer 6. (My friend's computer)
Output : URL is null
We both are using XP & he got a null value when i got the correct output in same XP, IE 6.
Don't know how you could get null if a file was actually uploaded, but besides that: different browsers return different things for file input elements: some return the entire local path (useless on the server side), some just return the file name.
Joined: Jan 21, 2009
David, thanks for replying.
David Newton wrote:Don't know how you could get null if a file was actually uploaded
Yeah, that's why i am
David Newton wrote:some return the entire local path (useless on the server side), some just return the file name.
Yeah, that's what happened here. I am just testing it on my local system. Not developing any enterprise application. So the "entire local path" will be good enough for me.
As i just want to input an XML file, A "file upload" functionality will solve this guess...
But i dont know how to upload file in a web application