You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Geir Magnusson Jr." <ge...@optonline.net> on 2001/08/08 12:28:44 UTC

Re: How do I access a session using HttpSession in a Velocitytemplate?

Attila Szegedi wrote:
> 
> This is again the problem of trying to access an instance of a non-public
> class through a public interface. I've posted a patch named "dynamic cast"
> recently that fixes this issue to velocity-dev, however it has not reached
> CVS yet.

Not yet.  Sorry.  Gunning for later today.  I had a huge commit (it
would be easier to name the source files that weren't touched than the
ones that were) to do the runtime instance separation, and didn't want
to keep having to patch in two places - it was driving me nuts...

geir

> 
> Attila.
> 
> > on 8/7/01 11:35 AM, "John Hebert" <jo...@vedalabs.com> wrote:
> >
> > > A colleague and I are learning Velocity and trying to port some servlets
> > > and JSPs to work with Velocity. Are there any code examples to show how
> > > to access a session using HttpSession in a Velocity template?
> > >
> > > He asked me:
> > >
> > > I am trying to use the HttpSession in a velocity template
> > >
> > > In the servlet:
> > > HttpSession session = req.getSession(true);
> > > session.setAttribute("name", sName);
> > >
> > > In the Template
> > > #set( $session = $req.getSession(true) )
> > > #set( $name = $session.getAttribute("name") )
> > > $name
> > >
> > > Error:
> > > ASTMethod.execute() : exception invoiking 'getAttribute' in
> > > class org.apache.tomcat.session.StandardSession :
> > > java.lang.IllegalAccessException
> > >
> > > I have read the archives and seen this problem discussed, but
> > > I have yet to see a solution on using the HttpSession
> > >
> > > Thanks for any help
> > >
> > > Kerr Wall
> >

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
Well done is better than well said - New England Proverb

Thanks for the responses Re: How do I access a session using HttpSession in a Velocitytemplate?

Posted by John Hebert <jo...@vedalabs.com>.
Attila Szegedi wrote:

> OK, I didn't intend to urge you, just wanted to let Nick know the issue is
> addressed and help is underway :-).
> ----- Original Message -----
> From: "Geir Magnusson Jr." <ge...@optonline.net>
>>Not yet.  Sorry.  Gunning for later today.  I had a huge commit (it
>>would be easier to name the source files that weren't touched than the
>>ones that were) to do the runtime instance separation, and didn't want
>>to keep having to patch in two places - it was driving me nuts...

Thanks for all the responses. Was off-line until now. This answers our 
question, so we'll sit tight and wait for it to show up in CVS.

-- 
John Alex Hebert
john@vedalabs.com
System Engineer

Re: How do I access a session using HttpSession in a Velocitytemplate?

Posted by Attila Szegedi <sz...@freemail.hu>.
OK, I didn't intend to urge you, just wanted to let Nick know the issue is
addressed and help is underway :-).

Attila.

----- Original Message -----
From: "Geir Magnusson Jr." <ge...@optonline.net>
To: <ve...@jakarta.apache.org>
Sent: 2001. augusztus 8. 3:28
Subject: Re: How do I access a session using HttpSession in a
Velocitytemplate?


> Attila Szegedi wrote:
> >
> > This is again the problem of trying to access an instance of a
non-public
> > class through a public interface. I've posted a patch named "dynamic
cast"
> > recently that fixes this issue to velocity-dev, however it has not
reached
> > CVS yet.
>
> Not yet.  Sorry.  Gunning for later today.  I had a huge commit (it
> would be easier to name the source files that weren't touched than the
> ones that were) to do the runtime instance separation, and didn't want
> to keep having to patch in two places - it was driving me nuts...
>
> geir
>
> >
> > Attila.
> >
> > > on 8/7/01 11:35 AM, "John Hebert" <jo...@vedalabs.com> wrote:
> > >
> > > > A colleague and I are learning Velocity and trying to port some
servlets
> > > > and JSPs to work with Velocity. Are there any code examples to show
how
> > > > to access a session using HttpSession in a Velocity template?
> > > >
> > > > He asked me:
> > > >
> > > > I am trying to use the HttpSession in a velocity template
> > > >
> > > > In the servlet:
> > > > HttpSession session = req.getSession(true);
> > > > session.setAttribute("name", sName);
> > > >
> > > > In the Template
> > > > #set( $session = $req.getSession(true) )
> > > > #set( $name = $session.getAttribute("name") )
> > > > $name
> > > >
> > > > Error:
> > > > ASTMethod.execute() : exception invoiking 'getAttribute' in
> > > > class org.apache.tomcat.session.StandardSession :
> > > > java.lang.IllegalAccessException
> > > >
> > > > I have read the archives and seen this problem discussed, but
> > > > I have yet to see a solution on using the HttpSession
> > > >
> > > > Thanks for any help
> > > >
> > > > Kerr Wall
> > >
>
> --
> Geir Magnusson Jr.                           geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> Well done is better than well said - New England Proverb
>