You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sushma R Onkar <su...@rediffmail.com> on 2003/07/15 05:16:53 UTC

Velocity Template & Servlets

Hi,

I am having a problem with velocity.
I am using:
1. Tomcat version 4.1.18
2. velocity-dep-1.3.jar
3. Java1.4.0( build 1.4.0-b92)
4. Windows 2000.

I am using velocity template with servlets.

Problem Description:
1.Whenever one of the parameters for  a method is HTTPRequest 
object in the velocity template the link does not get 
translated.
2.If the method has only HTTPRequest object as the parameter it 
works.
3.But HTTPRequest in combination with other parameters does not 
seem to work.

For Example:
Following DO NOT WORK:
<h2> <a href="$link.getBrowseURL($request, "A", 1, 15)">REQ + 
String + Int = NOT WORKING</a></h2>
<h2> <a href="$link.getBrowseURL( "A", 1, 15,$request)">String + 
Int + REQ = NOT WORKING</a></h2>
<h2> <a href="$link.getBrowseURL( $request,1, 15)">REQ + Integer = 
NOT
WORKING</a> </h2>

Following WORK:
<h2> <a href="$link.getBrowseURL("A", 1, 15)">String + Int = 
Working</a> </h2>
<h2> <a href="$link.getBrowseURL( 1, 15)">Only Integer = WORKING 
</a> </h2>
<h2> <a href="$link.getBrowseURL( $request)">Only REQ = 
WORKING</a> </h2>


Can you please help me with this.

THANK YOU
Sushma



___________________________________________________
Click below to experience Sooraj R Barjatya's latest offering
'Main Prem Ki Diwani Hoon' starring Hrithik, Abhishek
  & Kareena http://www.mpkdh.com


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


Re: Velocity Template & Servlets

Posted by Ch...@dlr.de.
Hi Sushma,

we cannot infer the class of your $link context object from your text.
Please check it yourself, for example by temporarily putting a
   $link.class.name
in yor template and then observing what it wrote to the output.

Then check the source or the API of that class to find out what the
valid parameters are for the method "getBroseURL".

Please note that your example shows parameters of type
"java.lang.String", "int" and "HttpRequest" in different count
and order. Velocity magically can use the primitive type of a number
(e.g. "java.lang.Integer" to "int" and "java.lang.Double" to "double")
but cannot cast from "int" to "float".

Hope this helped,
Christoph

Sushma R Onkar wrote:
> Hi,
> 
> I am having a problem with velocity.
> I am using:
> 1. Tomcat version 4.1.18
> 2. velocity-dep-1.3.jar
> 3. Java1.4.0( build 1.4.0-b92)
> 4. Windows 2000.
> 
> I am using velocity template with servlets.
> 
> Problem Description:
> 1.Whenever one of the parameters for  a method is HTTPRequest object in 
> the velocity template the link does not get translated.
> 2.If the method has only HTTPRequest object as the parameter it works.
> 3.But HTTPRequest in combination with other parameters does not seem to 
> work.
> 
> For Example:
> Following DO NOT WORK:
> <h2> <a href="$link.getBrowseURL($request, "A", 1, 15)">REQ + String + 
> Int = NOT WORKING</a></h2>
> <h2> <a href="$link.getBrowseURL( "A", 1, 15,$request)">String + Int + 
> REQ = NOT WORKING</a></h2>
> <h2> <a href="$link.getBrowseURL( $request,1, 15)">REQ + Integer = NOT
> WORKING</a> </h2>
> 
> Following WORK:
> <h2> <a href="$link.getBrowseURL("A", 1, 15)">String + Int = Working</a> 
> </h2>
> <h2> <a href="$link.getBrowseURL( 1, 15)">Only Integer = WORKING </a> </h2>
> <h2> <a href="$link.getBrowseURL( $request)">Only REQ = WORKING</a> </h2>
> 
> 
> Can you please help me with this.
> 
> THANK YOU
> Sushma
> 
> 
> 
> ___________________________________________________
> Click below to experience Sooraj R Barjatya's latest offering
> 'Main Prem Ki Diwani Hoon' starring Hrithik, Abhishek
>  & Kareena http://www.mpkdh.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 

-- 
:) Christoph Reck


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


Re: Velocity Template & Servlets

Posted by Anthony Eden <ae...@signaturedomains.com>.
Sorry about that - that was not supposed to go to the Velocity mailing list.

-Anthony

Anthony Eden wrote:

> After looking over the output it appears that there is a problem with 
> the text field output.  I am going to look and see if I can get that 
> whole text field placed in quotes somehow.
>
> -Anthony
>
> Simon Christian wrote:
>
>> Hi Sushma,
>>
>> I'd hate to just be stating the obvious here, but is the key for the 
>> HttpServletRequest object in the Context definitely 'request' and not 
>> 'req' as in $link.getBrowseURL($req, "A", 1, 15)?
>>
>> - simon
>>
>>
>> Sushma R Onkar wrote:
>>
>>> Hi,
>>>
>>> I am having a problem with velocity.
>>> I am using:
>>> 1. Tomcat version 4.1.18
>>> 2. velocity-dep-1.3.jar
>>> 3. Java1.4.0( build 1.4.0-b92)
>>> 4. Windows 2000.
>>>
>>> I am using velocity template with servlets.
>>>
>>> Problem Description:
>>> 1.Whenever one of the parameters for  a method is HTTPRequest object 
>>> in the velocity template the link does not get translated.
>>> 2.If the method has only HTTPRequest object as the parameter it works.
>>> 3.But HTTPRequest in combination with other parameters does not seem 
>>> to work.
>>>
>>> For Example:
>>> Following DO NOT WORK:
>>> <h2> <a href="$link.getBrowseURL($request, "A", 1, 15)">REQ + String 
>>> + Int = NOT WORKING</a></h2>
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org



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


Re: Velocity Template & Servlets

Posted by Anthony Eden <ae...@signaturedomains.com>.
After looking over the output it appears that there is a problem with 
the text field output.  I am going to look and see if I can get that 
whole text field placed in quotes somehow.

-Anthony

Simon Christian wrote:

> Hi Sushma,
>
> I'd hate to just be stating the obvious here, but is the key for the 
> HttpServletRequest object in the Context definitely 'request' and not 
> 'req' as in $link.getBrowseURL($req, "A", 1, 15)?
>
> - simon
>
>
> Sushma R Onkar wrote:
>
>> Hi,
>>
>> I am having a problem with velocity.
>> I am using:
>> 1. Tomcat version 4.1.18
>> 2. velocity-dep-1.3.jar
>> 3. Java1.4.0( build 1.4.0-b92)
>> 4. Windows 2000.
>>
>> I am using velocity template with servlets.
>>
>> Problem Description:
>> 1.Whenever one of the parameters for  a method is HTTPRequest object 
>> in the velocity template the link does not get translated.
>> 2.If the method has only HTTPRequest object as the parameter it works.
>> 3.But HTTPRequest in combination with other parameters does not seem 
>> to work.
>>
>> For Example:
>> Following DO NOT WORK:
>> <h2> <a href="$link.getBrowseURL($request, "A", 1, 15)">REQ + String 
>> + Int = NOT WORKING</a></h2>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org



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


Re: Velocity Template & Servlets

Posted by Simon Christian <si...@stoutstick.com>.
Hi Sushma,

I'd hate to just be stating the obvious here, but is the key for the 
HttpServletRequest object in the Context definitely 'request' and not 
'req' as in $link.getBrowseURL($req, "A", 1, 15)?

- simon


Sushma R Onkar wrote:
> Hi,
> 
> I am having a problem with velocity.
> I am using:
> 1. Tomcat version 4.1.18
> 2. velocity-dep-1.3.jar
> 3. Java1.4.0( build 1.4.0-b92)
> 4. Windows 2000.
> 
> I am using velocity template with servlets.
> 
> Problem Description:
> 1.Whenever one of the parameters for  a method is HTTPRequest object in 
> the velocity template the link does not get translated.
> 2.If the method has only HTTPRequest object as the parameter it works.
> 3.But HTTPRequest in combination with other parameters does not seem to 
> work.
> 
> For Example:
> Following DO NOT WORK:
> <h2> <a href="$link.getBrowseURL($request, "A", 1, 15)">REQ + String + 
> Int = NOT WORKING</a></h2>



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