You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pratt <th...@gmail.com> on 2009/06/09 23:00:05 UTC

Accessing the Session from the Freemarker Theme templates

I need to access a session variable from one of the FreeMarker Theme
templates, and I can't seem to find the proper syntax.  One site said to use
${Session.formToken}, but that seems to give me a lovely red on yellow error
box across my display.  I've also tried ${#session.formToken} thinking OGNL
would take over, but that gives me:

freemarker.core.ParseException: Token manager error:
freemarker.core.TokenMgrError: Lexical error at line 1, column 50.
Encountered: "#" (35), after : ""

Is it possible to access the session attributes?
  (*Chris*)

Re: Accessing the Session from the Freemarker Theme templates

Posted by Chris Pratt <th...@gmail.com>.
Yup, didn't work either, but I found the workaround, thanks.
  (*Chris*)

On Tue, Jun 9, 2009 at 3:56 PM, Musachy Barroso <mu...@gmail.com> wrote:

> did you try "${session.formToken}" (case sensitive)
>
> On Tue, Jun 9, 2009 at 2:08 PM, Chris Pratt<th...@gmail.com>
> wrote:
> > ${Session.formToken}
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Accessing the Session from the Freemarker Theme templates

Posted by Musachy Barroso <mu...@gmail.com>.
did you try "${session.formToken}" (case sensitive)

On Tue, Jun 9, 2009 at 2:08 PM, Chris Pratt<th...@gmail.com> wrote:
> ${Session.formToken}



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Accessing the Session from the Freemarker Theme templates

Posted by Chris Pratt <th...@gmail.com>.
As usually happens after three hours of searching the web, finally breaking
down and asking the question, I ran across the answer and was able to find a
solution.  So for anyone else out there that runs into this problem, this
won't work:

  <input type="hidden" name="formToken" value="${Session.formToken}" />


but this will:

  <input type="hidden" name="formToken" value="<@s.property
value='%{#session.formToken}'/>" />


Thanks.
  (*Chris*)

On Tue, Jun 9, 2009 at 2:00 PM, Chris Pratt <th...@gmail.com> wrote:

> I need to access a session variable from one of the FreeMarker Theme
> templates, and I can't seem to find the proper syntax.  One site said to use
> ${Session.formToken}, but that seems to give me a lovely red on yellow error
> box across my display.  I've also tried ${#session.formToken} thinking OGNL
> would take over, but that gives me:
>
> freemarker.core.ParseException: Token manager error:
> freemarker.core.TokenMgrError: Lexical error at line 1, column 50.
> Encountered: "#" (35), after : ""
>
> Is it possible to access the session attributes?
>   (*Chris*)
>

RE: Accessing the Session from the Freemarker Theme templates

Posted by Martin Gainty <mg...@hotmail.com>.
in your ftl try 

<html>
    <head><title>This page has no title</title></head>
<body>
  <br/>the secret password is: <@s.property value="#session.fubar"/>
</body>
</html>

?
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Tue, 9 Jun 2009 14:00:05 -0700
> Subject: Accessing the Session from the Freemarker Theme templates
> From: thechrispratt@gmail.com
> To: user@struts.apache.org
> 
> I need to access a session variable from one of the FreeMarker Theme
> templates, and I can't seem to find the proper syntax.  One site said to use
> ${Session.formToken}, but that seems to give me a lovely red on yellow error
> box across my display.  I've also tried ${#session.formToken} thinking OGNL
> would take over, but that gives me:
> 
> freemarker.core.ParseException: Token manager error:
> freemarker.core.TokenMgrError: Lexical error at line 1, column 50.
> Encountered: "#" (35), after : ""
> 
> Is it possible to access the session attributes?
>   (*Chris*)

_________________________________________________________________
Insert movie times and more without leaving Hotmail®. 
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009