Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-jmeter Wiki" 
for change notification.

The following page has been changed by JMeterAdmin:
http://wiki.apache.org/jakarta-jmeter/EscapedURLs

The comment on the change is:
Initial

New page:
= Dealing with escaped URLs =

URLs that are present in HTML pages are usually encoded.
For example:

{{{href="/search.cgi?search1=abc&search2=xyx"}}}

If the URL is extracted using a Regular Expression Post-Processor and used 
directly in another HTTP Sampler, then the sample may well fail, as the server 
is expecting to see:

{{{/search.cgi?search1=abc&search2=xyx}}}

As of JMeter 2.3.1 there is no automatic way of handling this, however there 
are some work-rounds.
Assume that the URL is stored in the variable ESCAPED_URL.

Using [http://jakarta.apache.org/jmeter/usermanual/functions.html#__jexl Jexl]:

{{{
${__jexl(vars.get("ESCAPED_URL").replace("&"\,"&"))}
}}}

Using [http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell 
BeanShell]:


Set the JMeter property '''beanshell.function.init''' to point to a file; add 
the following definition to the file:

{{{
// Fix ampersands in a string
String fixAmps(s) {
  return s.replaceAll("&","&");
}
}}}

The function can then be called as follows:

{{{
${__BeanShell(fixAmps(vars.get("ESCAPED_URL"))}
or
${__BeanShell(fixAmps(vars.get("ESCAPED_URL"),PLAIN_URL)}
}}}

The latter function call will store the result in the variable PLAIN_URL
The work-rounds above can be extended to handle other transformations such as 
%20 -> space, %2F -> / and %3A -> :

N.B. the current release of JMeter already contains the fixAmps() function in 
the file !BeanShellFunction.bshrc.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to