You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by h2ooo x <tj...@hotmail.com> on 2004/10/19 03:29:23 UTC

[HttpClient] Relative URI

>From the HTML, I grabbed the line src="member/login" and sent a request to 
it and, the response said "400 Bad Request".

The problem is solved by adding a prefix to the address like this, 
"/member/login":

   // uri = "member/login"
   if (uri.charAt(0) != '/')
      uri = "/" + uri;

   // uri = "/member/login"


Do we have to do this programmatically?
* I'm afraid if I have overlooked some useful HttpClient features to make 
the code better.

_________________________________________________________________
Are you in love? Find a date on MSN Personals http://match.msn.com.my/


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [HttpClient] Relative URI

Posted by Michael Becke <be...@u.washington.edu>.
Please have a look at the httpclient URI class.  Something like the 
following should work:

URI newURI = new URI(new URI("/test.html"), "member/login");

You can then query the newURI for the values you need.

Mike

On Oct 18, 2004, at 9:29 PM, h2ooo x wrote:

> From the HTML, I grabbed the line src="member/login" and sent a 
> request to it and, the response said "400 Bad Request".
>
> The problem is solved by adding a prefix to the address like this, 
> "/member/login":
>
>   // uri = "member/login"
>   if (uri.charAt(0) != '/')
>      uri = "/" + uri;
>
>   // uri = "/member/login"
>
>
> Do we have to do this programmatically?
> * I'm afraid if I have overlooked some useful HttpClient features to 
> make the code better.
>
> _________________________________________________________________
> Are you in love? Find a date on MSN Personals http://match.msn.com.my/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: Check file path really exists

Posted by Martin Cooper <mf...@gmail.com>.
On Mon, 18 Oct 2004 19:22:07 -0700 (PDT), Joe Smith <ap...@yahoo.com> wrote:
> 
> My upload.java uses apache commons upload. And I use the following to check if the path really exists. The program runs in UNIX, and when user selects a file from windows machine, it seems always not found the path. But if I test it in local machine, it is working, any ideas?? Please advise. Thanks!!
> 

You don't provide any information on where the value of 'fileNamePath'
came from, so it's a little difficult to tell...

However, if you are using the value of FileItem.getName() for this,
that is almost certainly your problem. The 'name' property is provided
by the client (usually a browser), and may be a base file name or a
full path to a file, depending on that client. If it's a full path,
then it will be OS dependent.

In general, it's a bad idea to try to use the name of the original
file as the name of the uploaded file. Apart from the path issues
mentioned above, there are also the obvious issues of multiple uploads
of the same file, possibly by different people, leading to all sorts
of potential conflicts.

--
Martin Cooper


> File files = new File(fileNamePath);
> 
> if (!files.exists())
> 
> { uploadFileExists = false;
> 
> break;
> 
> }
> 
> 
> ---------------------------------
> Do you Yahoo!?
> vote.yahoo.com - Register online to vote today!
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Check file path really exists

Posted by Joe Smith <ap...@yahoo.com>.
My upload.java uses apache commons upload. And I use the following to check if the path really exists. The program runs in UNIX, and when user selects a file from windows machine, it seems always not found the path. But if I test it in local machine, it is working, any ideas?? Please advise. Thanks!!

File files = new File(fileNamePath);

if (!files.exists()) 

{ uploadFileExists = false;

break;

}

 

 
 

		
---------------------------------
Do you Yahoo!?
vote.yahoo.com - Register online to vote today!