What do you want to do with this information? Maybe you can
solve the underlying problem leading to this question
differently.
Regards, Lothar
> I am using FileUploadWidget to upload a file.
> After uploading file I am adding the uploaded filename in a ListBox to
> display the uploaded filename to the user.
>>From server side I am returning the complete path of the file where I
> created uploaded file on the server. Code is given below :-
If you are in control of what is returned, why don't you simply
replace the system.specific file-separator by '/'. So in your
servlet you simply do a
return localPath.replace(File.separatorChar, '/');
That way you don't have to cope with the separator at all.
java.io.File takes all kinds of separators, i.e. if you create
an instance of File with "\Users\User\Documents\whatever.txt"
this will happily work independent if that happens on a Windows
or Linux or AS/400-system. The same is valid for the use of
slashes ('/') on Windows-systems.
If you want to show the path using the separators used by the
client, you might check out the User-Agent-Header on the servlet-
side to find out what operating system the client is using. On
the other side, who cares if there are backslashes or slashes?
Regards, Lothar