Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Passing a URL parameter to the PL/SQL cartridge
On Thu, 15 Jul 1999 14:57:56 GMT, lofftjm_at_itec.suny.edu wrote:
>I have a PL/SQL procedure that I am using to produce dynamic web
>pages that I want to pass a URL to as a parameter in order to do
>a meta-tag refresh.
>
>Example:
>
>http://appserver.doamin.com/dad/plsql/myproc?myurl=http://www.param_url.
>com
>
>When I try this, I receive the following error from the webserver:
>
> "The request did not specify a valid virtual host."
correct response from the webserver.
The webserver is reading the /'s as directory separators. You need to escape them if you want to pass them in a URL. Just like if you want a space in a URL you use a + and if you want a plus in the URL then you need to escape that or else the webserver will interpret it as a space. So you can use the following routine to escape the special characters of a URL...
function urlencode( p_str in varchar2 ) return varchar2 as
l_tmp varchar2(6000); l_len number default length(p_str); l_hex varchar2(16) default '0123456789ABCDEF'; l_num number; l_bad varchar2(100) default ' >%}\~];?@&<#{|^[`/:=$+''"'; l_char char(1);
for i in 1 .. length(p_str) loop
l_char := substr(p_str,i,1);
if ( instr( l_bad, l_char ) > 0 )
then
l_num := ascii( l_char ); l_tmp := l_tmp || '%' || substr(l_hex, mod(trunc(l_num/16),16)+1, 1 ) || substr(l_hex, mod(l_num, 16)+1, 1 ); else l_tmp := l_tmp || l_char;
return l_tmp;
end urlencode;
using this will change
http://www.param_url.com
into
http%3A%2F%2Fwww.param_url.com
and then everything should work just fine.
hope this helps.
chris.
>
>I have tried passing the parameter with both single and double quotes
>arround the URL. I receive the same results.
>
>If I leave of the "http://" portion of the URL parameter the parameter
>will be accepted, however this doesn't solve my problem as then the
>refresh ends up trying to refresh to:
>http://appserver.domain.com/dad/plsql/www.param_url.com
>
>For obvious reasons this is the wrong URL to refresh to. I have
>temporarily solved this problem by hard-coding the "http://"
>portion of the URL into my PL/SQL code and then appending it to
>the URL parameter. This will not work in the case of "ftp://"
>or "news:" URL's.
>
>What doesn't the webserver allow me to pass the string "http://"
>as part of a parameter?
>
>Joe Lofft
>State University of New York
>lofftjm_at_itec.suny.edu
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
--
Christopher Beck
Oracle Corporation
clbeck_at_us.oracle.com
Reston, VA.
![]() |
![]() |