You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Bojan Smojver <bo...@binarix.com> on 2001/03/15 04:18:20 UTC

req in Velocity

As far as I can tell, the $req points to HttpServletRequest and $res to
HttpServletResponse in VTL when using standard context in a servlet. If
I use those as is, everything is fine (BTW: $request *DOESN'T* work as
shown in the docs).

But when methods are referenced (e.g. $req.getRequestURI()), the
resulting HTML shows them literally (ie. Velocity doesn't find the
methods within $req).

Config:

Velocity 0.75 (snapshot 13/03/2001)
Tomcat 3.2.1
Apache 1.3.19 + mod_jk
JDK 1.3.0 (blackdown.org)
RedHat Linux 7.0

I've seen a few workarounds on the list but it would be interesting to
know if this has been resolved properly.

Bojan

Re: req in Velocity

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Bojan Smojver wrote:
> 
> As far as I can tell, the $req points to HttpServletRequest and $res to
> HttpServletResponse in VTL when using standard context in a servlet. If
> I use those as is, everything is fine (BTW: $request *DOESN'T* work as
> shown in the docs).

Thanks, and sorry. I'll fix that.

 
> But when methods are referenced (e.g. $req.getRequestURI()), the
> resulting HTML shows them literally (ie. Velocity doesn't find the
> methods within $req).

The problem is that, I assume you are using tomcat, that
HttpServletRequest is a public interface to a default access class, and
for reasons I can't quite fathom from the spec, introspection fails.

The current workaround is to simply wrap the HttpServletRequest in a
little wrapper class, or peel that stuff out and dump into the context
as is.

Sorry about that.  

geir

 
> Config:
> 
> Velocity 0.75 (snapshot 13/03/2001)
> Tomcat 3.2.1
> Apache 1.3.19 + mod_jk
> JDK 1.3.0 (blackdown.org)
> RedHat Linux 7.0
> 
> I've seen a few workarounds on the list but it would be interesting to
> know if this has been resolved properly.
> 
> Bojan

-- 
Geir Magnusson Jr.                               geirm@optonline.net
Developing for the web?  See http://jakarta.apache.org/velocity/