[xwiki-users] set variables on request
Hello, I know that i can get value from a request like this: "#set($name= $request.getParameter('name'))" Now, shouldn't i be able to put variables on request so i can use in the html page? something like this: "#set($var = $request.setAttribute($name))" and in the html page to use $request.getAttribute($name) ? :blush: Thank you -- View this message in context: http://n2.nabble.com/set-variables-on-request-tp4174575p4174575.html Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Bubulina, On 12/16/2009 11:40 AM, Bubulina wrote:
Hello,
I know that i can get value from a request like this: "#set($name= $request.getParameter('name'))"
Now, shouldn't i be able to put variables on request so i can use in the html page? something like this: "#set($var = $request.setAttribute($name))"
yes, normally yes, but you also have to pass a value, the setAttribute() function gets 2 params: $request.setAttribute($name, $value)
and in the html page to use $request.getAttribute($name) ?
I confess I don't really understand which HTML page this is about, but yes, it should work. However, keep in mind that parameters and attributes are not really the same thing (see the spec here http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.h... ). Happy hacking, Anca
:blush: Thank you
Bubulina wrote:
Hello,
I know that i can get value from a request like this: "#set($name= $request.getParameter('name'))"
Now, shouldn't i be able to put variables on request so i can use in the html page? something like this: "#set($var = $request.setAttribute($name))"
and in the html page to use $request.getAttribute($name) ?
Have you read http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletRequest.html#setA... It clearly states "Attributes are reset between requests". Also, please note that attributes and parameters have a different meaning when you talk about servlet requests. Isn't an input hidden (HTML element) what you are looking for? Or maybe http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html#se... Hope this helps, Marius
:blush: Thank you
just setting the var on request and reading it afterwards. it worked. thank you lucaa wrote:
Hi Bubulina,
On 12/16/2009 11:40 AM, Bubulina wrote:
Hello,
I know that i can get value from a request like this: "#set($name= $request.getParameter('name'))"
Now, shouldn't i be able to put variables on request so i can use in the html page? something like this: "#set($var = $request.setAttribute($name))"
yes, normally yes, but you also have to pass a value, the setAttribute() function gets 2 params:
$request.setAttribute($name, $value)
and in the html page to use $request.getAttribute($name) ?
I confess I don't really understand which HTML page this is about, but yes, it should work. However, keep in mind that parameters and attributes are not really the same thing (see the spec here http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.h... ).
Happy hacking, Anca
:blush: Thank you
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://n2.nabble.com/set-variables-on-request-tp4174575p4174967.html Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (3)
-
Anca Luca -
Bubulina -
Marius Dumitru Florea