You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Sheldon Ross <ro...@hotmail.com> on 2009/02/04 18:30:41 UTC
Link redirect Question
Another question I have:
Is there an easier way to redirect to secure server.
I've figured out a way to do it.
Basically on a screen I'll have something like:
<a href="$link.setPage('mydir,mytemplate').toString().replaceAll("http:","https:")"> Secure Link</a>
Which works fine in some occasions.
Is there a way to tell turbine to do this in the setTemplate(data,"template") function ?
I would like to be able to automatically redirect to the secure side.
Any advice would be appreciated.
Thanks,
Sheldon
_________________________________________________________________
Windows Live™: E-mail. Chat. Share. Get more ways to connect.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Faster_022009
RE: Link redirect Question
Posted by Sheldon Ross <ro...@hotmail.com>.
Thanks,
That works out well.
So at the beginning of my Default.vm I have:
#if($secure && !$data.Request.Secure)
#set($redirect = $link.setPage($data.getTemplateInfo().getScreenTemplate()).setAction($data.getAction()).setSecure().toString())
$data.setRedirectURI($redirect)
$data.setStatusCode(302)
#end
And in any page I want to make secure I just put
#set($secure = true)
at the beginning.
Works like charm!
> Date: Sun, 8 Feb 2009 15:40:28 +0100
> From: tv@apache.org
> To: user@turbine.apache.org
> Subject: Re: Link redirect Question
>
> Sheldon Ross wrote:
> > Another question I have:
> > Is there an easier way to redirect to secure server.
> >
> > I've figured out a way to do it.
> > Basically on a screen I'll have something like:
> >
> > <a href="$link.setPage('mydir,mytemplate').toString().replaceAll("http:","https:")"> Secure Link</a>
>
> I'd suggest to extend the TemplateLink pull-tool to allow to call
> setSecure() on the underlying TemplateLink object. This would allow
> something in the line of
>
> #if(!$data.Secure)
> $data.Response.setRedirectURI("$link.setPage('mydir,mytemplate').setSecure(true).getAbsoluteLink()");
> $data.setStatusCode(302)
> #end
>
>
> Bye, Thomas.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
>
_________________________________________________________________
See how Windows connects the people, information, and fun that are part of your life.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/
Re: Link redirect Question
Posted by Thomas Vandahl <tv...@apache.org>.
Sheldon Ross wrote:
> Another question I have:
> Is there an easier way to redirect to secure server.
>
> I've figured out a way to do it.
> Basically on a screen I'll have something like:
>
> <a href="$link.setPage('mydir,mytemplate').toString().replaceAll("http:","https:")"> Secure Link</a>
I'd suggest to extend the TemplateLink pull-tool to allow to call
setSecure() on the underlying TemplateLink object. This would allow
something in the line of
#if(!$data.Secure)
$data.Response.setRedirectURI("$link.setPage('mydir,mytemplate').setSecure(true).getAbsoluteLink()");
$data.setStatusCode(302)
#end
Bye, Thomas.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org
RE: Link redirect Question
Posted by Sheldon Ross <ro...@hotmail.com>.
I would be curious as to how you accomplished the flipping.
I can see that the request object has isSecure(), but I'm still not clear on how I would force a redirect.
Sheldon
> Subject: RE: Link redirect Question
> Date: Wed, 4 Feb 2009 11:47:05 -0600
> From: TonyO@prepare-enrich.com
> To: user@turbine.apache.org
>
>
> I while back I had wanted the target web page to determine if it should
> be secure or not. It is a real pain to have to track down links within
> your scripts (on the calling side).
>
> What I did was create 2 new classes, SecureForm and RegularForm. They
> both extend VelocitySecureScreen.
>
> If the user accesses a form that extends SecureForm, it automatically
> "flips" to a secure session, regardless of whether the original link was
> http or https.
>
> Forms extended from RegularForm work in the same fashion, but instead
> force http.
>
> There may be a newer, more fancy way of doing this, but if you wish I
> will post the code. It has been in production for the last 4 years so
> it is stable.
>
>
>
>
> FYI the following works fine (I use it in my own code). There was a
> glitch early on if the tag was not all upper case. Also I am not sure
> if you can access setAttribute directly on the data object from within
> the context of a velocity script. In my case I create a container
> session object that gets put into the session data and then I put the
> necessary application specific data within the container so that there
> is no chance of having the tag names collide. I can then access (or
> update... yikes) the container object from within my classes, scripts,
> etc.
>
> data.getSession().setAttribute("MYCONTAINER", containerObj);
> data.getSession().getAttribute("MYCONTAINER");
>
>
> Tony
>
> -----Original Message-----
> From: Sheldon Ross [mailto:ross_sheldon@hotmail.com]
> Sent: Wednesday, February 04, 2009 11:31 AM
> To: turbine-user@jakarta.apache.org
> Subject: Link redirect Question
>
>
> Another question I have:
> Is there an easier way to redirect to secure server.
>
> I've figured out a way to do it.
> Basically on a screen I'll have something like:
>
> <a
> href="$link.setPage('mydir,mytemplate').toString().replaceAll("http:","h
> ttps:")"> Secure Link</a>
>
> Which works fine in some occasions.
>
> Is there a way to tell turbine to do this in the
> setTemplate(data,"template") function ?
> I would like to be able to automatically redirect to the secure side.
>
> Any advice would be appreciated.
>
> Thanks,
> Sheldon
>
> _________________________________________________________________
> Windows Live(tm): E-mail. Chat. Share. Get more ways to connect.
> http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Faster_022
> 009
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
>
_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t1_allup_howitworks_022009
RE: Link redirect Question
Posted by Tony Oslund <To...@prepare-enrich.com>.
I while back I had wanted the target web page to determine if it should
be secure or not. It is a real pain to have to track down links within
your scripts (on the calling side).
What I did was create 2 new classes, SecureForm and RegularForm. They
both extend VelocitySecureScreen.
If the user accesses a form that extends SecureForm, it automatically
"flips" to a secure session, regardless of whether the original link was
http or https.
Forms extended from RegularForm work in the same fashion, but instead
force http.
There may be a newer, more fancy way of doing this, but if you wish I
will post the code. It has been in production for the last 4 years so
it is stable.
FYI the following works fine (I use it in my own code). There was a
glitch early on if the tag was not all upper case. Also I am not sure
if you can access setAttribute directly on the data object from within
the context of a velocity script. In my case I create a container
session object that gets put into the session data and then I put the
necessary application specific data within the container so that there
is no chance of having the tag names collide. I can then access (or
update... yikes) the container object from within my classes, scripts,
etc.
data.getSession().setAttribute("MYCONTAINER", containerObj);
data.getSession().getAttribute("MYCONTAINER");
Tony
-----Original Message-----
From: Sheldon Ross [mailto:ross_sheldon@hotmail.com]
Sent: Wednesday, February 04, 2009 11:31 AM
To: turbine-user@jakarta.apache.org
Subject: Link redirect Question
Another question I have:
Is there an easier way to redirect to secure server.
I've figured out a way to do it.
Basically on a screen I'll have something like:
<a
href="$link.setPage('mydir,mytemplate').toString().replaceAll("http:","h
ttps:")"> Secure Link</a>
Which works fine in some occasions.
Is there a way to tell turbine to do this in the
setTemplate(data,"template") function ?
I would like to be able to automatically redirect to the secure side.
Any advice would be appreciated.
Thanks,
Sheldon
_________________________________________________________________
Windows Live(tm): E-mail. Chat. Share. Get more ways to connect.
http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Faster_022
009
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org