commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vernon <vern...@gatewaytech.com>
Subject Re: [FileUpload] The getName method yields inconsist value
Date Sat, 10 May 2003 15:39:39 GMT

1) The forward slashes in the path are generated either by a method like

request.getSession().getServletContext() 
.getRealPath(request.getServletPath());

or File.separator/System.getProperty("file.separator"). In other words, 
they are based on the system itself. Sure, I can have the following code to 
insert a forward slash in front of forward slash. But, I don't think it is 
favorable by any standard.

		int i=0;
		while((i = src.indexOf("\\", i)) >= 0) {
			src = src.substring(0, i) + "\\" + src.substring(i);
			i += 2;
		}


2) The exception is thrown AFTER a file is uploaded. That means the write 
method knows how to find the path and does it correctly. I don't see any 
reason the exception shall be thrown in the situation.

Vernon

On Sat, 10 May 2003 02:17:59 -0400, Rob Leland <rleland@apache.org> wrote:

> The \ is considered an escape for control characters,
> if you want '\' you need '\\'
>
> So for "E:\Tomcat\Tomcat 4.1\webapps\mm\client/photo\Tom\dog1.gif"
> have you tried: ;
> "E:\\Tomca\\Tomcat 4.1\\webapps\\mm\\client/photo\\Tom\\dog1.gif"
>
> -Rob
>
> Vernon wrote:
>
>> Hi, Martin,
>>
>> Thanks again for your detailed explanation.
>>
>> I shouldn't ask a question when I was very tired. The question is not 
>> right.
>>
>> In the follow-up procedure, I run into the following exception:
>>
>> java.lang.Exception: File name is invalid
>>
>> on the line of write method although the file is written in the desired 
>> directory. I have tried the both write(String) and write(File) methods 
>> and yields the same exception. The file path is "E:\Tomcat\Tomcat 
>> 4.1\webapps\mm\client/photo\Tom\dog1.gif" as the input parameter for 
>> write(String). Is the exception thrown due to the backward slash? If so, 
>> how I shall deal with path informaion stored in web.xml file? The 
>> portion, "client/photo", of the path is in the xml file.
>>
>> Vernon
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>



-- 
Vernon

Mime
View raw message