You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Brian Parker <bp...@windchill.com> on 2001/10/10 17:10:55 UTC
creating query string -> parse error
Hi,
TIA for any help figuring out how to avoid this error!
Here is what is in my template (I'm using VelocityServlet.) :
<a
href="${res.encodeURL(${req.getRequestURI()}?view=showAddSubtree&server=${ldapServer.Key})}">Help!</a>
Here is what I get in "velocity.log":
at
org.apache.velocity.runtime.parser.Parser.generateParseException(Parser.java:3164)
at
org.apache.velocity.runtime.parser.Parser.jj_consume_token(Parser.java:3048)
at org.apache.velocity.runtime.parser.Parser.Method(Parser.java:982)
at
org.apache.velocity.runtime.parser.Parser.Reference(Parser.java:1036)
at org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:287)
at
org.apache.velocity.runtime.parser.Parser.IfStatement(Parser.java:1180)
at org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:280)
at org.apache.velocity.runtime.parser.Parser.Directive(Parser.java:652)
at org.apache.velocity.runtime.parser.Parser.Statement(Parser.java:304)
at org.apache.velocity.runtime.parser.Parser.process(Parser.java:245)
at org.apache.velocity.runtime.parser.Parser.parse(Parser.java:105)
at org.apache.velocity.runtime.Runtime.parse(Runtime.java:619)
at org.apache.velocity.Template.process(Template.java:164)
at
org.apache.velocity.runtime.resource.ResourceManager.getResource(ResourceManager.java:388)
at org.apache.velocity.runtime.Runtime.getTemplate(Runtime.java:686)
at org.apache.velocity.runtime.Runtime.getTemplate(Runtime.java:668)
at
org.apache.velocity.servlet.VelocityServlet.getTemplate(VelocityServlet.java:501)
at
com.ptc.tools.ldapentrytool.ControllerServlet.handleRequest(ControllerServlet.java:153)
at
org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:333)
at
org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:294)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
Wed Oct 10 09:46:46 CDT 2001 [error] ResourceManager.getResource()
parse exception: org.apache.velocity.exception.ParseErrorException:
Encountered "?view=showAddSubtree&server=" at line 28, column 64.
Was expecting one of:
"," ...
")" ...
<WHITESPACE> ...
<DOT> ...
The reference "$ldapServer.Key" is good. It is something like
"host.domain.com:389".
Thanks very much,
Brian
Re: creating query string -> parse error
Posted by Christoph Reck <Ch...@dlr.de>.
Brian Parker wrote:
>
> Hi,
>
> TIA for any help figuring out how to avoid this error!
>
> Here is what is in my template (I'm using VelocityServlet.) :
>
> <a href="${res.encodeURL(${req.getRequestURI()}?view=showAddSubtree&server=${ldapServer.Key})}">Help!</a>
Do this in two steps:
#set( $url = "$req.getRequestURI()?view=showAddSubtree&server=$ldapServer.Key" )
<a href="$res.encodeURL($url)">Help!</a>
Your problem is that the VTL parser will not allow string interpolation for
a method parameter.
You might also succeed without the two steps by adding Quotes to the
parameter (since the outer "" are schmoo to the parser):
<a href="${res.encodeURL("${req.getRequestURI()}?view=showAddSubtree&server=${ldapServer.Key}")}">Help!</a>
This way the inner string gets interpolated with the contained calls.
:) Christoph