You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "Kuhn, Harald" <HK...@airplus.com> on 2009/07/22 16:35:07 UTC
RE:[Trinidad] how to handle redirets for PPR requests on session
time out
Hi Samba,
Trinidads built-in ppr-Framework has the ability to send redirects initiated by the server.
The only steps you have to do are:
· check if it is a ppr-request
o on “normal” requests use response.sendRedirect
o on ppr-requests send ppr-Message containing <redirect>
Following code examples works on our site
final boolean isPartialRequest = "true".equals(req.getHeader("Tr-XHR-Message"));
if (isPartialRequest) {
final PrintWriter writer = resp.getWriter();
final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
rw.startDocument();
rw.write("<?Tr-XHR-Response-Type ?>\n");
rw.startElement("redirect", null);
rw.writeText(pageURL, null);
rw.endElement("redirect");
rw.endDocument();
rw.close();
}
else {
resp.sendRedirect(pageURL);
}
Kind regards
Harald
Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263 Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister: Amtsgericht Offenbach/Main, HRB 8119
From: Samba [mailto:saasira@gmail.com]
Sent: Wednesday, July 22, 2009 11:59 AM
To: MyFaces Trinidad Discussion
Subject: how to handle redirets for PPR requests on session time out
Hi,
We are facing trouble in redirecting the users to login page for PPR requests after session time out.
We are having a filter that redirects the users login ( jsp ) page if the user is not autheticated or the authentication timed out. But after redirecting,
I'm seeing the following error in firebug console:
["Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul 2009 09:52:49 GMT\nServer: Apache\n..."]Common1_2_7.js (line 10649)
["Error ", TypeError: a5 has no properties message=a5 has no properties, " delivering XML request status changed to ", function()]
1. I read on the internet that redirects on AJAX requests cannot be made server side and can only be made via javascript, is that true?
2. I tried adding a PPR hook to identify if the response is regarding related to session timeout and if yes, then would change the document location to login page
however, this is not working as expected; perhaps I'm doing something wrong.
Here is what I'm doing:
function register(){
TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
}
function callbackMethod(requestEvent)
{
if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
{
var response=+requestEvent.getResponseXML());
if(has info about session timeout)
documnet.location="/login.jsp";
}
}
register();
But I'm getting error saying requestEvent.getStatus() is not defined.
Can some one help me how to redirect users to login page on PPR requestts?
Thanks and Regards,
Samba
Re: [Trinidad] how to handle redirets for PPR requests on session
time out
Posted by Samba <sa...@gmail.com>.
Great news!
It would have meant much more to me if this were implemented by
now.
Anyway, this is certainly the best way to go for fixing this issue.
On Wed, Jul 22, 2009 at 8:29 PM, Matthias Wessendorf <ma...@apache.org>wrote:
> this would be good, to be implemented:
>
> https://issues.apache.org/jira/browse/TRINIDAD-943
>
> -M
>
> On Wed, Jul 22, 2009 at 4:35 PM, Kuhn, Harald<HK...@airplus.com> wrote:
> > Hi Samba,
> >
> >
> >
> > Trinidads built-in ppr-Framework has the ability to send redirects
> initiated
> > by the server.
> >
> > The only steps you have to do are:
> >
> > · check if it is a ppr-request
> >
> > o on “normal” requests use response.sendRedirect
> >
> > o on ppr-requests send ppr-Message containing <redirect>
> >
> >
> >
> > Following code examples works on our site
> >
> >
> >
> > final boolean isPartialRequest =
> > "true".equals(req.getHeader("Tr-XHR-Message"));
> >
> > if (isPartialRequest) {
> >
> > final PrintWriter writer = resp.getWriter();
> >
> > final XmlResponseWriter rw = new XmlResponseWriter(writer,
> "UTF-8");
> >
> > rw.startDocument();
> >
> > rw.write("<?Tr-XHR-Response-Type ?>\n");
> >
> > rw.startElement("redirect", null);
> >
> > rw.writeText(pageURL, null);
> >
> > rw.endElement("redirect");
> >
> > rw.endDocument();
> >
> > rw.close();
> >
> > }
> >
> > else {
> >
> > resp.sendRedirect(pageURL);
> >
> > }
> >
> >
> >
> > Kind regards
> >
> >
> >
> > Harald
> >
> >
> >
> >
> >
> > Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
> > Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz),
> Klaus
> > Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow ·
> Handelsregister:
> > Amtsgericht Offenbach/Main, HRB 8119
> >
> >
> >
> >
> >
> > From: Samba [mailto:saasira@gmail.com]
> > Sent: Wednesday, July 22, 2009 11:59 AM
> > To: MyFaces Trinidad Discussion
> > Subject: how to handle redirets for PPR requests on session time out
> >
> >
> >
> > Hi,
> >
> > We are facing trouble in redirecting the users to login page for PPR
> > requests after session time out.
> > We are having a filter that redirects the users login ( jsp ) page if
> the
> > user is not autheticated or the authentication timed out. But after
> > redirecting,
> > I'm seeing the following error in firebug console:
> >
> > ["Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul
> 2009
> > 09:52:49 GMT\nServer: Apache\n..."]Common1_2_7.js (line 10649)
> >
> > ["Error ", TypeError: a5 has no properties message=a5 has no properties,
> "
> > delivering XML request status changed to ", function()]
> >
> >
> > 1. I read on the internet that redirects on AJAX requests cannot
> be
> > made server side and can only be made via javascript, is that true?
> > 2. I tried adding a PPR hook to identify if the response is
> > regarding related to session timeout and if yes, then would change the
> > document location to login page
> > however, this is not working as expected; perhaps I'm doing
> > something wrong.
> >
> > Here is what I'm doing:
> >
> >
> > function register(){
> >
> >
> TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
> > }
> >
> >
> >
> > function callbackMethod(requestEvent)
> > {
> >
> >
> > if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
> > {
> >
> > var
> > response=+requestEvent.getResponseXML());
> > if(has info about session timeout)
> >
> documnet.location="/login.jsp";
> > }
> > }
> >
> >
> > register();
> >
> > But I'm getting error saying requestEvent.getStatus() is
> > not defined.
> >
> >
> >
> >
> >
> > Can some one help me how to redirect users to login page on
> > PPR requestts?
> >
> > Thanks and Regards,
> > Samba
>
>
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>
Re: [Trinidad] how to handle redirets for PPR requests on session
time out
Posted by Matthias Wessendorf <ma...@apache.org>.
this would be good, to be implemented:
https://issues.apache.org/jira/browse/TRINIDAD-943
-M
On Wed, Jul 22, 2009 at 4:35 PM, Kuhn, Harald<HK...@airplus.com> wrote:
> Hi Samba,
>
>
>
> Trinidads built-in ppr-Framework has the ability to send redirects initiated
> by the server.
>
> The only steps you have to do are:
>
> · check if it is a ppr-request
>
> o on “normal” requests use response.sendRedirect
>
> o on ppr-requests send ppr-Message containing <redirect>
>
>
>
> Following code examples works on our site
>
>
>
> final boolean isPartialRequest =
> "true".equals(req.getHeader("Tr-XHR-Message"));
>
> if (isPartialRequest) {
>
> final PrintWriter writer = resp.getWriter();
>
> final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
>
> rw.startDocument();
>
> rw.write("<?Tr-XHR-Response-Type ?>\n");
>
> rw.startElement("redirect", null);
>
> rw.writeText(pageURL, null);
>
> rw.endElement("redirect");
>
> rw.endDocument();
>
> rw.close();
>
> }
>
> else {
>
> resp.sendRedirect(pageURL);
>
> }
>
>
>
> Kind regards
>
>
>
> Harald
>
>
>
>
>
> Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
> Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus
> Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister:
> Amtsgericht Offenbach/Main, HRB 8119
>
>
>
>
>
> From: Samba [mailto:saasira@gmail.com]
> Sent: Wednesday, July 22, 2009 11:59 AM
> To: MyFaces Trinidad Discussion
> Subject: how to handle redirets for PPR requests on session time out
>
>
>
> Hi,
>
> We are facing trouble in redirecting the users to login page for PPR
> requests after session time out.
> We are having a filter that redirects the users login ( jsp ) page if the
> user is not autheticated or the authentication timed out. But after
> redirecting,
> I'm seeing the following error in firebug console:
>
> ["Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul 2009
> 09:52:49 GMT\nServer: Apache\n..."]Common1_2_7.js (line 10649)
>
> ["Error ", TypeError: a5 has no properties message=a5 has no properties, "
> delivering XML request status changed to ", function()]
>
>
> 1. I read on the internet that redirects on AJAX requests cannot be
> made server side and can only be made via javascript, is that true?
> 2. I tried adding a PPR hook to identify if the response is
> regarding related to session timeout and if yes, then would change the
> document location to login page
> however, this is not working as expected; perhaps I'm doing
> something wrong.
>
> Here is what I'm doing:
>
>
> function register(){
>
> TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
> }
>
>
>
> function callbackMethod(requestEvent)
> {
>
>
> if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
> {
>
> var
> response=+requestEvent.getResponseXML());
> if(has info about session timeout)
> documnet.location="/login.jsp";
> }
> }
>
>
> register();
>
> But I'm getting error saying requestEvent.getStatus() is
> not defined.
>
>
>
>
>
> Can some one help me how to redirect users to login page on
> PPR requestts?
>
> Thanks and Regards,
> Samba
--
Matthias Wessendorf
blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf
Re: [Trinidad] how to handle redirets for PPR requests on session
time out
Posted by Samba <sa...@gmail.com>.
Harald,
I tried that and it indeed worked with out any additional
changes!
Thanks for the help,
Regards,
Samba
On Thu, Jul 23, 2009 at 12:33 PM, Kuhn, Harald <HK...@airplus.com> wrote:
> Hi Samba,
>
>
>
> I’m not really sure if XmlResponseWriter would do more than your
> suggestion in this case.
>
> Maybe it writes some additional state or java script.
>
>
>
> I would suggest to first implement the solution using XmlResponseWriter und
> try to inspect the generated XML-Response (i.e. using Firebug) and probably
> the response headers.
>
> If there is no additional content in the response (or headers), your
> solution should work as well.
>
>
>
>
>
> Regards
>
>
>
> Harald
>
>
>
>
>
> Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
> Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus
> Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister:
> Amtsgericht Offenbach/Main, HRB 8119
>
>
>
>
>
> *From:* Samba [mailto:saasira@gmail.com]
> *Sent:* Wednesday, July 22, 2009 6:19 PM
> *To:* MyFaces Discussion
> *Subject:* Re: [Trinidad] how to handle redirets for PPR requests on
> session time out
>
>
>
> Harald, I just realized that the XmlResponseWriter you referrred to is
> from trinidad jars; We are actually having a centralized valve at tomcat
> level that does the redirection.
>
> We would want that piece of code to be independent of any dependencies on
> any of the UI frameworks.
>
> Is it possible to write some thing like:
>
> final boolean isPartialRequest =
> "true".equals(req.getHeader("Tr-XHR-Message"));
>
> response.setContentType("text/xml");
>
> PrintWriterout = response.getWriter();
>
> if (isPartialRequest) {
>
> out.println("<?xml version=\"1.0\"?>");
>
> out.println("<?Tr-XHR-Response-Type ?>\n");
>
> out.println("<redirect>");
>
> out.println("</pageURL>");
>
> out.println("</redirect>");
>
> out.close();
>
> }else {
>
> response.sendRedirect(pageURL);
>
> }
>
>
> Thanks and Regards,
> Samba
>
> On Wed, Jul 22, 2009 at 8:31 PM, Samba <sa...@gmail.com> wrote:
>
> Thanks a lot Harald,
> I'll try it out and let you know how it went..
> Regards,
> Samba
>
>
>
> On Wed, Jul 22, 2009 at 8:05 PM, Kuhn, Harald <HK...@airplus.com> wrote:
>
> Hi Samba,
>
>
>
> Trinidads built-in ppr-Framework has the ability to send redirects
> initiated by the server.
>
> The only steps you have to do are:
>
> · check if it is a ppr-request
>
> o on “normal” requests use response.sendRedirect
>
> o on ppr-requests send ppr-Message containing <redirect>
>
>
>
> Following code examples works on our site
>
>
>
> final boolean isPartialRequest =
> "true".equals(req.getHeader("Tr-XHR-Message"));
>
> if (isPartialRequest) {
>
> final PrintWriter writer = resp.getWriter();
>
> final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
>
> rw.startDocument();
>
> rw.write("<?Tr-XHR-Response-Type ?>\n");
>
> rw.startElement("redirect", null);
>
> rw.writeText(pageURL, null);
>
> rw.endElement("redirect");
>
> rw.endDocument();
>
> rw.close();
>
> }
>
> else {
>
> resp.sendRedirect(pageURL);
>
> }
>
>
>
> Kind regards
>
>
>
> Harald
>
>
>
>
>
> Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
> Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus
> Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister:
> Amtsgericht Offenbach/Main, HRB 8119
>
>
>
>
>
> *From:* Samba [mailto:saasira@gmail.com]
> *Sent:* Wednesday, July 22, 2009 11:59 AM
> *To:* MyFaces Trinidad Discussion
> *Subject:* how to handle redirets for PPR requests on session time out
>
>
>
> Hi,
>
> We are facing trouble in redirecting the users to login page for PPR
> requests after session time out.
> We are having a filter that redirects the users login ( jsp ) page if
> the user is not autheticated or the authentication timed out. But after
> redirecting,
> I'm seeing the following error in firebug console:
>
> *["Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul
> 2009 09:52:49 GMT\nServer: Apache\n..."]Common1_2_7.js (line 10649)*
>
> *["Error ", TypeError: a5 has no properties message=a5 has no properties,
> " delivering XML request status changed to ", function()]*
>
>
>
> 1. I read on the internet that redirects on AJAX requests cannot be
> made server side and can only be made via javascript, is that true?
> 2. I tried adding a PPR hook to identify if the response is
> regarding related to session timeout and if yes, then would change the
> document location to login page
> however, this is not working as expected; perhaps I'm doing
> something wrong.
>
> Here is what I'm doing:
>
>
> function register(){
>
> TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
> }
>
>
>
>
> function callbackMethod(requestEvent)
> {
>
>
> if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
> {
>
> var
> response=+requestEvent.getResponseXML());
> if(has info about session timeout)
>
> documnet.location="/login.jsp";
> }
> }
>
>
> register();
>
> But I'm getting error saying requestEvent.getStatus() is
> not defined.
>
>
>
>
>
> Can some one help me how to redirect users to login page on
> PPR requestts?
>
> Thanks and Regards,
> Samba
>
>
>
>
>
RE: [Trinidad] how to handle redirets for PPR requests on session
time out
Posted by "Kuhn, Harald" <HK...@airplus.com>.
Hi Samba,
I’m not really sure if XmlResponseWriter would do more than your suggestion in this case.
Maybe it writes some additional state or java script.
I would suggest to first implement the solution using XmlResponseWriter und try to inspect the generated XML-Response (i.e. using Firebug) and probably the response headers.
If there is no additional content in the response (or headers), your solution should work as well.
Regards
Harald
Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263 Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister: Amtsgericht Offenbach/Main, HRB 8119
From: Samba [mailto:saasira@gmail.com]
Sent: Wednesday, July 22, 2009 6:19 PM
To: MyFaces Discussion
Subject: Re: [Trinidad] how to handle redirets for PPR requests on session time out
Harald, I just realized that the XmlResponseWriter you referrred to is from trinidad jars; We are actually having a centralized valve at tomcat level that does the redirection.
We would want that piece of code to be independent of any dependencies on any of the UI frameworks.
Is it possible to write some thing like:
final boolean isPartialRequest = "true".equals(req.getHeader("Tr-XHR-Message"));
response.setContentType("text/xml");
PrintWriterout = response.getWriter();
if (isPartialRequest) {
out.println("<?xml version=\"1.0\"?>");
out.println("<?Tr-XHR-Response-Type ?>\n");
out.println("<redirect>");
out.println("</pageURL>");
out.println("</redirect>");
out.close();
}else {
response.sendRedirect(pageURL);
}
Thanks and Regards,
Samba
On Wed, Jul 22, 2009 at 8:31 PM, Samba <sa...@gmail.com>> wrote:
Thanks a lot Harald,
I'll try it out and let you know how it went..
Regards,
Samba
On Wed, Jul 22, 2009 at 8:05 PM, Kuhn, Harald <HK...@airplus.com>> wrote:
Hi Samba,
Trinidads built-in ppr-Framework has the ability to send redirects initiated by the server.
The only steps you have to do are:
• check if it is a ppr-request
o on “normal” requests use response.sendRedirect
o on ppr-requests send ppr-Message containing <redirect>
Following code examples works on our site
final boolean isPartialRequest = "true".equals(req.getHeader("Tr-XHR-Message"));
if (isPartialRequest) {
final PrintWriter writer = resp.getWriter();
final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
rw.startDocument();
rw.write("<?Tr-XHR-Response-Type ?>\n");
rw.startElement("redirect", null);
rw.writeText(pageURL, null);
rw.endElement("redirect");
rw.endDocument();
rw.close();
}
else {
resp.sendRedirect(pageURL);
}
Kind regards
Harald
Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263 Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister: Amtsgericht Offenbach/Main, HRB 8119
From: Samba [mailto:saasira@gmail.com<ma...@gmail.com>]
Sent: Wednesday, July 22, 2009 11:59 AM
To: MyFaces Trinidad Discussion
Subject: how to handle redirets for PPR requests on session time out
Hi,
We are facing trouble in redirecting the users to login page for PPR requests after session time out.
We are having a filter that redirects the users login ( jsp ) page if the user is not autheticated or the authentication timed out. But after redirecting,
I'm seeing the following error in firebug console:
["Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul 2009 09:52:49 GMT\nServer: Apache\n..."]Common1_2_7.js (line 10649)
["Error ", TypeError: a5 has no properties message=a5 has no properties, " delivering XML request status changed to ", function()]
1. I read on the internet that redirects on AJAX requests cannot be made server side and can only be made via javascript, is that true?
2. I tried adding a PPR hook to identify if the response is regarding related to session timeout and if yes, then would change the document location to login page
however, this is not working as expected; perhaps I'm doing something wrong.
Here is what I'm doing:
function register(){
TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
}
function callbackMethod(requestEvent)
{
if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
{
var response=+requestEvent.getResponseXML());
if(has info about session timeout)
documnet.location="/login.jsp";
}
}
register();
But I'm getting error saying requestEvent.getStatus() is not defined.
Can some one help me how to redirect users to login page on PPR requestts?
Thanks and Regards,
Samba
Re: [Trinidad] how to handle redirets for PPR requests on session
time out
Posted by Samba <sa...@gmail.com>.
Harald, I just realized that the XmlResponseWriter you referrred to is from
trinidad jars; We are actually having a centralized valve at tomcat level
that does the redirection.
We would want that piece of code to be independent of any dependencies on
any of the UI frameworks.
Is it possible to write some thing like:
final boolean isPartialRequest =
"true".equals(req.getHeader("Tr-XHR-Message"));
response.setContentType("text/xml");
PrintWriterout = response.getWriter();
if (isPartialRequest) {
out.println("<?xml version=\"1.0\"?>");
out.println("<?Tr-XHR-Response-Type ?>\n");
out.println("<redirect>");
out.println("</pageURL>");
out.println("</redirect>");
out.close();
}else {
response.sendRedirect(pageURL);
}
Thanks and Regards,
Samba
On Wed, Jul 22, 2009 at 8:31 PM, Samba <sa...@gmail.com> wrote:
> Thanks a lot Harald,
> I'll try it out and let you know how it went..
> Regards,
> Samba
>
>
> On Wed, Jul 22, 2009 at 8:05 PM, Kuhn, Harald <HK...@airplus.com> wrote:
>
>> Hi Samba,
>>
>>
>>
>> Trinidads built-in ppr-Framework has the ability to send redirects
>> initiated by the server.
>>
>> The only steps you have to do are:
>>
>> · check if it is a ppr-request
>>
>> o on “normal” requests use response.sendRedirect
>>
>> o on ppr-requests send ppr-Message containing <redirect>
>>
>>
>>
>> Following code examples works on our site
>>
>>
>>
>> final boolean isPartialRequest =
>> "true".equals(req.getHeader("Tr-XHR-Message"));
>>
>> if (isPartialRequest) {
>>
>> final PrintWriter writer = resp.getWriter();
>>
>> final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
>>
>> rw.startDocument();
>>
>> rw.write("<?Tr-XHR-Response-Type ?>\n");
>>
>> rw.startElement("redirect", null);
>>
>> rw.writeText(pageURL, null);
>>
>> rw.endElement("redirect");
>>
>> rw.endDocument();
>>
>> rw.close();
>>
>> }
>>
>> else {
>>
>> resp.sendRedirect(pageURL);
>>
>> }
>>
>>
>>
>> Kind regards
>>
>>
>>
>> Harald
>>
>>
>>
>>
>>
>> Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
>> Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus
>> Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister:
>> Amtsgericht Offenbach/Main, HRB 8119
>>
>>
>>
>>
>>
>> *From:* Samba [mailto:saasira@gmail.com]
>> *Sent:* Wednesday, July 22, 2009 11:59 AM
>> *To:* MyFaces Trinidad Discussion
>> *Subject:* how to handle redirets for PPR requests on session time out
>>
>>
>>
>> Hi,
>>
>> We are facing trouble in redirecting the users to login page for PPR
>> requests after session time out.
>> We are having a filter that redirects the users login ( jsp ) page if
>> the user is not autheticated or the authentication timed out. But after
>> redirecting,
>> I'm seeing the following error in firebug console:
>>
>> *[**"Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul
>> 2009 09:52:49 GMT\nServer: Apache\n..."**]**Common1_2_7.js (line 10649)*
>>
>> *[**"Error "**, **TypeError: a5 has no properties** message=**a5 has no
>> properties**, **" delivering XML request status changed to "**, **
>> function()**]*
>>
>>
>>
>> 1. I read on the internet that redirects on AJAX requests cannot
>> be made server side and can only be made via javascript, is that true?
>> 2. I tried adding a PPR hook to identify if the response is
>> regarding related to session timeout and if yes, then would change the
>> document location to login page
>> however, this is not working as expected; perhaps I'm doing
>> something wrong.
>>
>> Here is what I'm doing:
>>
>>
>> function register(){
>>
>> TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
>> }
>>
>>
>>
>>
>> function callbackMethod(requestEvent)
>> {
>>
>>
>> if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
>> {
>>
>> var
>> response=+requestEvent.getResponseXML());
>> if(has info about session timeout)
>>
>> documnet.location="/login.jsp";
>> }
>> }
>>
>>
>> register();
>>
>> But I'm getting error saying requestEvent.getStatus() is
>> not defined.
>>
>>
>>
>>
>>
>> Can some one help me how to redirect users to login page on
>> PPR requestts?
>>
>> Thanks and Regards,
>> Samba
>>
>
>
Re: [Trinidad] how to handle redirets for PPR requests on session
time out
Posted by Samba <sa...@gmail.com>.
Thanks a lot Harald,
I'll try it out and let you know how it went..
Regards,
Samba
On Wed, Jul 22, 2009 at 8:05 PM, Kuhn, Harald <HK...@airplus.com> wrote:
> Hi Samba,
>
>
>
> Trinidads built-in ppr-Framework has the ability to send redirects
> initiated by the server.
>
> The only steps you have to do are:
>
> · check if it is a ppr-request
>
> o on “normal” requests use response.sendRedirect
>
> o on ppr-requests send ppr-Message containing <redirect>
>
>
>
> Following code examples works on our site
>
>
>
> final boolean isPartialRequest =
> "true".equals(req.getHeader("Tr-XHR-Message"));
>
> if (isPartialRequest) {
>
> final PrintWriter writer = resp.getWriter();
>
> final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
>
> rw.startDocument();
>
> rw.write("<?Tr-XHR-Response-Type ?>\n");
>
> rw.startElement("redirect", null);
>
> rw.writeText(pageURL, null);
>
> rw.endElement("redirect");
>
> rw.endDocument();
>
> rw.close();
>
> }
>
> else {
>
> resp.sendRedirect(pageURL);
>
> }
>
>
>
> Kind regards
>
>
>
> Harald
>
>
>
>
>
> Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
> Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz), Klaus
> Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow · Handelsregister:
> Amtsgericht Offenbach/Main, HRB 8119
>
>
>
>
>
> *From:* Samba [mailto:saasira@gmail.com]
> *Sent:* Wednesday, July 22, 2009 11:59 AM
> *To:* MyFaces Trinidad Discussion
> *Subject:* how to handle redirets for PPR requests on session time out
>
>
>
> Hi,
>
> We are facing trouble in redirecting the users to login page for PPR
> requests after session time out.
> We are having a filter that redirects the users login ( jsp ) page if
> the user is not autheticated or the authentication timed out. But after
> redirecting,
> I'm seeing the following error in firebug console:
>
> *[**"Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul
> 2009 09:52:49 GMT\nServer: Apache\n..."**]**Common1_2_7.js (line 10649)*
>
> *[**"Error "**, **TypeError: a5 has no properties** message=**a5 has no
> properties**, **" delivering XML request status changed to "**, **
> function()**]*
>
>
>
> 1. I read on the internet that redirects on AJAX requests cannot be
> made server side and can only be made via javascript, is that true?
> 2. I tried adding a PPR hook to identify if the response is
> regarding related to session timeout and if yes, then would change the
> document location to login page
> however, this is not working as expected; perhaps I'm doing
> something wrong.
>
> Here is what I'm doing:
>
>
> function register(){
>
> TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
> }
>
>
>
>
> function callbackMethod(requestEvent)
> {
>
>
> if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
> {
>
> var
> response=+requestEvent.getResponseXML());
> if(has info about session timeout)
>
> documnet.location="/login.jsp";
> }
> }
>
>
> register();
>
> But I'm getting error saying requestEvent.getStatus() is
> not defined.
>
>
>
>
>
> Can some one help me how to redirect users to login page on
> PPR requestts?
>
> Thanks and Regards,
> Samba
>
Re: RE:[Trinidad] how to handle redirets for PPR requests on
session time out
Posted by "valdas.zigas" <va...@gmail.com>.
Don't forget to add:
resp.setContentType("application/xml");
Regards,
Valdas
Westhveg wrote:
>
> Hello,
>
> Great code!
>
> I test it succesfuly in Firefox & Chrome, but in Internet Explorer doesn't
> work. Can you help me please?
>
>
> Thanks,
>
> Westh
>
--
View this message in context: http://old.nabble.com/how-to-handle-redirets-for-PPR-requests-on-session-time-out-tp24603322p26745833.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: RE:[Trinidad] how to handle redirets for PPR requests on
session time out
Posted by Westhveg <we...@gmail.com>.
Hello,
Great code!
I test it succesfuly in Firefox & Chrome, but in Internet Explorer doesn't
work. Can you help me please?
Thanks,
Westh
Kuhn, Harald wrote:
>
> Hi Samba,
>
> Trinidads built-in ppr-Framework has the ability to send redirects
> initiated by the server.
> The only steps you have to do are:
>
> · check if it is a ppr-request
>
> o on “normal” requests use response.sendRedirect
>
> o on ppr-requests send ppr-Message containing <redirect>
>
> Following code examples works on our site
>
> final boolean isPartialRequest =
> "true".equals(req.getHeader("Tr-XHR-Message"));
> if (isPartialRequest) {
> final PrintWriter writer = resp.getWriter();
> final XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
> rw.startDocument();
> rw.write("<?Tr-XHR-Response-Type ?>\n");
> rw.startElement("redirect", null);
> rw.writeText(pageURL, null);
> rw.endElement("redirect");
> rw.endDocument();
> rw.close();
> }
> else {
> resp.sendRedirect(pageURL);
> }
>
> Kind regards
>
> Harald
>
>
> Lufthansa AirPlus Servicekarten GmbH · Hans-Böckler-Straße 7 · 63263
> Neu-Isenburg · Germany · Geschäftsführer: Patrick W. Diemer (Vorsitz),
> Klaus Busch · Vorsitzender des Aufsichtsrates: Stephan Gemkow ·
> Handelsregister: Amtsgericht Offenbach/Main, HRB 8119
>
>
> From: Samba [mailto:saasira@gmail.com]
> Sent: Wednesday, July 22, 2009 11:59 AM
> To: MyFaces Trinidad Discussion
> Subject: how to handle redirets for PPR requests on session time out
>
> Hi,
>
> We are facing trouble in redirecting the users to login page for PPR
> requests after session time out.
> We are having a filter that redirects the users login ( jsp ) page if
> the user is not autheticated or the authentication timed out. But after
> redirecting,
> I'm seeing the following error in firebug console:
> ["Invalid PPR response. The response-headers were:\nDate: Wed, 22 Jul 2009
> 09:52:49 GMT\nServer: Apache\n..."]Common1_2_7.js (line 10649)
> ["Error ", TypeError: a5 has no properties message=a5 has no properties, "
> delivering XML request status changed to ", function()]
>
>
> 1. I read on the internet that redirects on AJAX requests cannot
> be made server side and can only be made via javascript, is that true?
> 2. I tried adding a PPR hook to identify if the response is
> regarding related to session timeout and if yes, then would change the
> document location to login page
> however, this is not working as expected; perhaps I'm doing
> something wrong.
>
> Here is what I'm doing:
>
> function register(){
>
> TrPage.getInstance().getRequestQueue().addStateChangeListener(callbackMethod);
> }
>
>
> function callbackMethod(requestEvent)
> {
>
>
> if(requestEvent.getStatus()=TrXMLRequestEvent.STATUS_COMPLETE)
> {
>
> var
> response=+requestEvent.getResponseXML());
> if(has info about session timeout)
>
> documnet.location="/login.jsp";
> }
> }
>
> register();
>
> But I'm getting error saying requestEvent.getStatus() is
> not defined.
>
>
> Can some one help me how to redirect users to login page on
> PPR requestts?
>
> Thanks and Regards,
> Samba
>
>
--
View this message in context: http://www.nabble.com/how-to-handle-redirets-for-PPR-requests-on-session-time-out-tp24603322p25742591.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.