Let me prvoide some info on % from Servlets point of
view. As Witold mentioned, % has special meaning in
Servlets environment. It represents a space character
in the URL request. 

For instance, if a request is submitted with
parameters to a servlet via a browser, the space in
the request is converted to % by the browser itself.
But the original value is not altered when you receive
in servlet. To receive %, as it is, it should be
preceded by another %. 

for example,  http://somehost/SomeServlet?vals=123 567
890 will be converted to
http://somehost/SomeServlet?vals=123%567%890 by the
browser. In servlet, the value of vals remains '123
567 890'. If you want value something like
'123%567%890', the request needs to be
http://somehost/SomeServlet?vals=123%%567%%890.

Hope this helps.

Raja




--- "Mike S." <[EMAIL PROTECTED]> wrote:
> Hi, Ronald and Witold.
> 
> You're right, URLEncoder\URLDecoder from java.net
> package are very usefull in
> the case when you need to proceed through URI some
> special characters. But...
> How can Witold use this functionality when he is
> submitting form with method
> _get_? If Witold can use javascript, Isuppose to
> write such function:
> 
> <script>
> 
> function encodeChars(formObj)
> 
> {
> 
> formObj.elemnts['elementName1'].value =
> escape(formObj.elemnts['elementName1'].value);
> 
> ...
> 
> formObj.elemnts['elementNameN'].value =
> escape(formObj.elemnts['elementNameN'].value);
> 
> 
> }
> 
> </script>
> 
> , and in form tag write onSubmit="encodeChars(this)"
> 
> You wrote Wednesday, May 29, 2002, 15:51:10:
> 
> 
> RJR> If you use "method=post" I don't think you'll
> have a problem.  If you need
> RJR> to pass the "%" in the URL, i.e. "method=get"
> then perhaps
> RJR> URLEncoder.encode() and URLDecoder.decode()
> will do what you need.
> 
> RJR> Hi all
> 
> RJR> In my servlet application I need to allow users
> to use wildcards in
> RJR> queries. The Oracle wildcard character is the
> "%" so e.g. in the user
> RJR> could type street name as: "Uni%" instead of
> "University"
> RJR> But if I use the "%", the URL parameters get
> messed up. For example
> RJR> if I have on my page textboxes STREET_NO and
> STREET_NAME and
> RJR> fill:
> RJR> STREET_NO: 2%
> RJR> STREET_NAME: UNI%
> 
> RJR> in the request URL I don't see STRETE_NO and
> STREET_NAME
> RJR> appears as: 2 TREET_NAME with unprintable
> character.
> RJR> Sometimes the value is changed.
> 
> RJR> I believe the "%" has special use in servlet
> request/response. I guess I
> RJR> could change the wildcard to a "*" or something
> else. But wonder if
> RJR> there is a way to handle the % properly
> 
> RJR> Thanks
> 
> RJR> Witold
> 
> 
> 
> 
> -- 
> Regards,
>  Mike                          mailto:[EMAIL PROTECTED]
> 
> 
> To change your membership options, refer to:
> http://www.sys-con.com/java/list.cfm


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to