You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Darren Gilroy <DG...@CONSONUS.com> on 2002/02/11 07:15:50 UTC

TemplateLink

Hi - 

I'm trying to place my turbine application behind an apache (1.3) proxy, and
I need some help.

I have /app proxied to anotherhost:8180/myapp/servlet/myapp via ProxyPass,
with ProxyPassReverse working too, but I need some help with the next step.

The $link object (org.apache.turbine.util.template.TemplateLink) and the
$content object both return fully-qualified urls.  I would like to adjust
those urls so they don't include the /myapp/servlet/mayapp part, or,
preferably, have those objects return relative URLs.

Ideas, suggestions, how-tos for this next step? 

Thanks!
-best-darr-


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TemplateLink

Posted by Peter Lynch <pe...@mindspring.com>.
Darren,

Hmm, I see John already replied, but since I just finished writing this
message, here it is anyway....

To change the /myapp/servlet/myapp of the url generated by TemplateLink,
simply:

1. Call $link.setScriptName("/app") when outputting the url. (Turbine calls
the /myapp/servlet/myapp part the ScriptName)

2. Or simply create a class similar to TemplateLink to return what you want
in the toString() method. TemplatLink is used as a pull tool. You can create
your own pull tool to generate URLs in your app, so that you can get the
output you want.

To get relative URLs, simply rewrite the toString of TemplateLink to look
like org.apache.turbine.util.RelativeDynamicURI's toString. If you are like
me you'll maybe end up writing your own link pull tool.

In your turbine properties, look for the word TemplateLink. Change that line
to point to the class you would like to use to generate your URLS and then
$link will use that class instead of turbine's TemplateLink class.

3. and Understand that the part of which you speak is a combination is
essentially HttpServletRequest.getContextPath() +
HttpServletRequest.getServletPath() so you could put something like this in
your web.xml file:

<servlet>
    <servlet-name>myapp</servlet-name>
    <servlet-class>org.apache.turbine.Turbine</servlet-class>
    <init-param>
        <param-name>properties</param-name>
        <param-value>/WEB-INF/conf/turbine/turbine.properties</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
</servlet>

and

<servlet-mapping>
        <servlet-name>app</servlet-name>
        <url-pattern>/app/*</url-pattern>
</servlet-mapping>


and in your server.xml you _may_ need

<Context path="/" docBase="@APP_ROOT@" debug="5" reloadable="false"/>

inside your <ContextManager> where @APP_ROOT@ is the full path to where you
application root is.

In this case you should now have $link returning /app in your templates
instead of /myapp/servlet/myapp.

All of this assumes Turbine 2.*

As John said, the simple approach is to write your own pull tool to do the
job.

-Peter


----- Original Message -----
From: "Darren Gilroy" <DG...@CONSONUS.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Sunday, February 10, 2002 10:15 PM
Subject: TemplateLink


> Hi -
>
> I'm trying to place my turbine application behind an apache (1.3) proxy,
and
> I need some help.
>
> I have /app proxied to anotherhost:8180/myapp/servlet/myapp via ProxyPass,
> with ProxyPassReverse working too, but I need some help with the next
step.
>
> The $link object (org.apache.turbine.util.template.TemplateLink) and the
> $content object both return fully-qualified urls.  I would like to adjust
> those urls so they don't include the /myapp/servlet/mayapp part, or,
> preferably, have those objects return relative URLs.
>
> Ideas, suggestions, how-tos for this next step?
>
> Thanks!
> -best-darr-
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: TemplateLink

Posted by John McNally <jm...@collab.net>.
Darren Gilroy wrote:
> 
I am not sure how a relative url within a turbine app can be defined
other than the possibilities of

1.  not including the host:port
2.  also not including the context/servlet

There is a RelativeTemplateLink class in turbine that implements (1). 
It's implementation is slightly different in t2 vs. t3.  In t3
DynamicURI can be set to include/exclude the host:port info and the
TemplateLink can work with this to generate absolute or type (1) urls. 
In t2 there are separate classes for the absolute and relative urls. 
t2's method does not allow the same link tool to be used in an template
for generating an email and also to generate relative url's in the
webapp.

I recommend subclassing DynamicURI and overriding its toString() method
to give you what you need.  And then write a link tool that wraps it. 
The current classes should be a pretty good guide.

john mcnally 

> Hi -
> 
> I'm trying to place my turbine application behind an apache (1.3) proxy, and
> I need some help.
> 
> I have /app proxied to anotherhost:8180/myapp/servlet/myapp via ProxyPass,
> with ProxyPassReverse working too, but I need some help with the next step.
> 
> The $link object (org.apache.turbine.util.template.TemplateLink) and the
> $content object both return fully-qualified urls.  I would like to adjust
> those urls so they don't include the /myapp/servlet/mayapp part, or,
> preferably, have those objects return relative URLs.
> 
> Ideas, suggestions, how-tos for this next step?
> 
> Thanks!
> -best-darr-
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>