You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Marcel de Koster <ma...@gmail.com> on 2005/11/17 08:41:26 UTC

Situation jsp versus vm

Hi,
I want to use velocity, but I'm faced with a problem I don't know thie
answer for:
 JSP:
<%
String a = request.getAttribute("a").toString();
String x = a + "b";
String y = request.getAttribute(x).toString();
%>
 Velocity:
#set ($x = $a + "b") --> doesn't work
#set ($y = ???) --> how do I get a variable from the context if you do not
yet know the name, since it depends on another variable value.

--
Met Vriendelijke Groet,

Marcel de Koster

Re: Situation jsp versus vm

Posted by Oliver Kohll <ol...@gtwebmarque.com>.
Hi,

See examples in the page below - does this help? I haven't used the  
RenderTool myself but it seems to me like it might do.

http://jakarta.apache.org/velocity/tools/generic/RenderTool.html

Cheers

Oliver Kohll

On 17 Nov 2005, at 07:41, Marcel de Koster wrote:

> Hi,
> I want to use velocity, but I'm faced with a problem I don't know thie
> answer for:
>  JSP:
> <%
> String a = request.getAttribute("a").toString();
> String x = a + "b";
> String y = request.getAttribute(x).toString();
> %>
>  Velocity:
> #set ($x = $a + "b") --> doesn't work
> #set ($y = ???) --> how do I get a variable from the context if you  
> do not
> yet know the name, since it depends on another variable value.
>
> --
> Met Vriendelijke Groet,
>
> Marcel de Koster

oliver@gtwebmarque.com / 0845 456 1810 / 07814 828608
Furze Bank, 34 Hanover Street, SWANSEA UK, SA1 6BA


NOTE
No contracts may be concluded on behalf of GT webMarque by means of e- 
mail
communications. The contents of this e-mail are confidential to the
intended recipient at the e-mail address to which it has been addressed;
it may not be disclosed to or used by anyone other than this addressee,
nor may it be copied in any way. If received in error please return to
sender via e-mail.

DISCLAIMER
Please note that neither GT webMarque Ltd nor the sender accept any
responsibility for viruses transmitted via e-mail. It is your
responsibility to scan attachments (if any).



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


Re: Situation jsp versus vm

Posted by Mike Kienenberger <mk...@gmail.com>.
Have you tried:

#set ( $a = $request.getAttribute("a") )
#set ( $x = "${a}b" )
#set ( $y = $request.getAttribute($x) );

Or just

#set ( $y = $request.getAttribute("${request.getAttribute("a")}b") );

On 11/17/05, Marcel de Koster <ma...@gmail.com> wrote:
> Hi,
> I want to use velocity, but I'm faced with a problem I don't know thie
> answer for:
>  JSP:
> <%
> String a = request.getAttribute("a").toString();
> String x = a + "b";
> String y = request.getAttribute(x).toString();
> %>
>  Velocity:
> #set ($x = $a + "b") --> doesn't work
> #set ($y = ???) --> how do I get a variable from the context if you do not
> yet know the name, since it depends on another variable value.
>
> --
> Met Vriendelijke Groet,
>
> Marcel de Koster
>
>

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