Modify the Response header

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Modify the Response header

Resistol
Hi all,

I would like to modify the response header after performing some business logic on the results page (not the results from the query). I realized that as stated in the HST-2 Request Processing documentation, it is possible to some logic in the doBeforeRender.

However, at this moment the content of page has not been generated and I cannot do the processing. In the same line of the comment there, is it possible to have some business logic defined after the rendering has happened?

Basically, I would like to adjust the header of the response (HST Aggregated Page) once the content has been processed. I need to put the headers for the mobile application we are building.

Cheers,

Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Jeroen Reijn
Administrator
Hi,

On Wed, Oct 3, 2012 at 12:25 PM, Resistol <[hidden email]> wrote:

> Hi all,
>
> I would like to modify the response header after performing some business
> logic on the results page (not the results from the query). I realized that
> as stated in the HST-2 Request Processing documentation, it is possible to
> some logic in the doBeforeRender.
>
> However, at this moment the content of page has not been generated and I
> cannot do the processing. In the same line of the comment there, is it
> possible to have some business logic defined after the rendering has
> happened?

Could you elaborate what kind of post-processing you would like to do?
>
> Basically, I would like to adjust the header of the response (HST Aggregated
> Page) once the content has been processed. I need to put the headers for the
> mobile application we are building.

Why do you need to do this 'after' the content is rendered. In the
render phase only data is written to the output stream. What kind of
information are you missing in the doBeforeRender phase?

>
> Cheers,
>
>
>
>
>
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/Modify-the-Response-header-tp7579442.html
> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



--
Jeroen Reijn
Solution Architect
Hippo

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

http://about.me/jeroenreijn
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Resistol
Jeroen Reijn wrote
Could you elaborate what kind of post-processing you would like to do?
Basically, I have some documents specifically targeted for mobile devices and will treat all links in a different way. Even those found in rich text values. I can verify in the layout (jsp) if the document has the target set for mobile devices, but it is cumbersome accessing the response from there.

In the request, we know it is coming from the specific client, but it also includes a key parameter. If the parameter is found in the content of the page, we need to include a different parameter on the header of the response.

Additionally, for our auditing purposes, this post-processing might also be valuable when storing the whole page returned to the client.  

Jeroen Reijn wrote
Why do you need to do this 'after' the content is rendered. In the
render phase only data is written to the output stream. What kind of
information are you missing in the doBeforeRender phase?
Based on the data written to the output stream, thus processing, we include a proper parameter in the header response. With this header value, the client will treat the content accordingly.

Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Woonsan Ko-3

I think you can simply set/add header with response object in #doBeforeRlender() or jsp page whatever you want.

Woonsan

Sent from my mobile phone. Apologies for any typos.

On Oct 3, 2012 8:06 AM, "Resistol" <[hidden email]> wrote:
Jeroen Reijn wrote
> Could you elaborate what kind of post-processing you would like to do?

Basically, I have some documents specifically targeted for mobile devices
and will treat all links in a different way. Even those found in rich text
values. I can verify in the layout (jsp) if the document has the target set
for mobile devices, but it is cumbersome accessing the response from there.

In the request, we know it is coming from the specific client, but it also
includes a key parameter. If the parameter is found in the content of the
page, we need to include a different parameter on the header of the
response.

Additionally, for our auditing purposes, this post-processing might also be
valuable when storing the whole page returned to the client.


Jeroen Reijn wrote
> Why do you need to do this 'after' the content is rendered. In the
> render phase only data is written to the output stream. What kind of
> information are you missing in the doBeforeRender phase?

Based on the data written to the output stream, thus processing, we include
a proper parameter in the header response. With this header value, the
client will treat the content accordingly.





--
View this message in context: http://hippo.2275632.n2.nabble.com/Modify-the-Response-header-tp7579442p7579447.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Bert Leunis
Hello,

Did you consider a setup using different channels? You could have a website and one or more mobile channels configured that will show the same content, but for every channel in a specific way. This way you can benefit from the out-of-the-box context and channel aware functionalities of the hst link rewriting.

I have never come across a situation where I needed a #doAfterRender method. As Woonsan mentioned, setting the headers on the HstResponse can be done in the #doBeforeRender. At this point in the rendering process you should be able to get to all information you need to determine your response. getParameter and getPublicRequestParameter methods of the BaseHstComponent class should help (your components could/should extend that class).
 
With kind regards/Met vriendelijke groet,
Bert Leunis

Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4I 466
www.onehippo.com



On Wed, Oct 3, 2012 at 2:23 PM, Woonsan Ko <[hidden email]> wrote:

I think you can simply set/add header with response object in #doBeforeRlender() or jsp page whatever you want.

Woonsan

Sent from my mobile phone. Apologies for any typos.

On Oct 3, 2012 8:06 AM, "Resistol" <[hidden email]> wrote:
Jeroen Reijn wrote
> Could you elaborate what kind of post-processing you would like to do?

Basically, I have some documents specifically targeted for mobile devices
and will treat all links in a different way. Even those found in rich text
values. I can verify in the layout (jsp) if the document has the target set
for mobile devices, but it is cumbersome accessing the response from there.

In the request, we know it is coming from the specific client, but it also
includes a key parameter. If the parameter is found in the content of the
page, we need to include a different parameter on the header of the
response.

Additionally, for our auditing purposes, this post-processing might also be
valuable when storing the whole page returned to the client.


Jeroen Reijn wrote
> Why do you need to do this 'after' the content is rendered. In the
> render phase only data is written to the output stream. What kind of
> information are you missing in the doBeforeRender phase?

Based on the data written to the output stream, thus processing, we include
a proper parameter in the header response. With this header value, the
client will treat the content accordingly.





--
View this message in context: http://hippo.2275632.n2.nabble.com/Modify-the-Response-header-tp7579442p7579447.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Michiel Rop
In reply to this post by Woonsan Ko-3
Hi all,

Concerning setting the content type in the component:

When a request is processed by multiple components ( e.g. header, content, footer, etc...), they all can set the content type. When you set the content type in the jsp you make sure that one will actually be used. The jsp for sure is the last "component" that is called.

On Wed, Oct 3, 2012 at 2:23 PM, Woonsan Ko <[hidden email]> wrote:

I think you can simply set/add header with response object in #doBeforeRlender() or jsp page whatever you want.

Woonsan

Sent from my mobile phone. Apologies for any typos.

On Oct 3, 2012 8:06 AM, "Resistol" <[hidden email]> wrote:
Jeroen Reijn wrote
> Could you elaborate what kind of post-processing you would like to do?

Basically, I have some documents specifically targeted for mobile devices
and will treat all links in a different way. Even those found in rich text
values. I can verify in the layout (jsp) if the document has the target set
for mobile devices, but it is cumbersome accessing the response from there.

In the request, we know it is coming from the specific client, but it also
includes a key parameter. If the parameter is found in the content of the
page, we need to include a different parameter on the header of the
response.

Additionally, for our auditing purposes, this post-processing might also be
valuable when storing the whole page returned to the client.


Jeroen Reijn wrote
> Why do you need to do this 'after' the content is rendered. In the
> render phase only data is written to the output stream. What kind of
> information are you missing in the doBeforeRender phase?

Based on the data written to the output stream, thus processing, we include
a proper parameter in the header response. With this header value, the
client will treat the content accordingly.





--
View this message in context: http://hippo.2275632.n2.nabble.com/Modify-the-Response-header-tp7579442p7579447.html
Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Best regards,
Michiel Rop

--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Resistol
Actually, we needed this "doAfterRendering" for three different issues.

In the first scenario, we are currently adding the header parameter in the response in one of the components (doBeforeRender) after checking the request, and we prepare the mobile links accordingly in the JSP (except for the rich text values which we do not have a solution yet). We considered the channels but the application is hybrid and can run on multiple devices/platforms. We did not want to add a new channel for each platform...
[Partially solved]

In the second scenario, there is one requirement to audit all responses given of specific locations. Probably, we will define a Servlet for this but we are not sure how to proceed. If there was an "doAfterRendering", we just store the content from the response output stream.
[Not implemented yet]

In the third scenario, we use EasyForms as to create questionaries and surveys. As they can become very large (not multipart yet), we store them on the client (mobile device) and allow them to fill them offline. When, submitting the survey however we need to verify that the form is actually the same as the currently published so we sent a hashcode of the page to the server. If the computed hascode is equal then we allow the submit otherwise we reload the survey. It is similar to a cache and it is clear we can do the processing on the device as well but it is only advisable to do this on the server, where there is "no" limitation on processing (limited cpu, battery life, memory, etc., data plan).
[Solve only in one device platform...]
Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Woonsan Ko-3

Hi Resistol,

Please see my comments inline.

(Sent from my mobile phone. Apologies for any typos.)

On Oct 4, 2012 5:52 AM, "Resistol" <[hidden email]> wrote:
>
> Actually, we needed this "doAfterRendering" for three different issues.
>
> In the first scenario, we are currently adding the header parameter in the
> response in one of the components (doBeforeRender) after checking the
> request, and we prepare the mobile links accordingly in the JSP (except for
> the rich text values which we do not have a solution yet). We considered the

If you need to inspect the result output from hst: html tag in your jsp for some reason, you can provide a custom contentRewriter bean to the tag. If it overrides #rewrite() method from the default implementation, SimpleContentRewriter, then you can take chances.

> channels but the application is hybrid and can run on multiple
> devices/platforms. We did not want to add a new channel for each platform...
> [Partially solved]
>
> In the second scenario, there is one requirement to audit all responses
> given of specific locations. Probably, we will define a Servlet for this but
> we are not sure how to proceed. If there was an "doAfterRendering", we just
> store the content from the response output stream.
> [Not implemented yet]

Would contentRewriter overriding solve this problem and the other be low?

Regards,

Woonsan

>
> In the third scenario, we use EasyForms as to create questionaries and
> surveys. As they can become very large (not multipart yet), we store them on
> the client (mobile device) and allow them to fill them offline. When,
> submitting the survey however we need to verify that the form is actually
> the same as the currently published so we sent a hashcode of the page to the
> server. If the computed hascode is equal then we allow the submit otherwise
> we reload the survey. It is similar to a cache and it is clear we can do the
> processing on the device as well but it is only advisable to do this on the
> server, where there is "no" limitation on processing (limited cpu, battery
> life, memory, etc., data plan).
> [Solve only in one device platform...]
>
>
>
> --
> View this message in context: http://hippo.2275632.n2.nabble.com/Modify-the-Response-header-tp7579442p7579459.html
> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Modify the Response header

Woonsan Ko-3
In reply to this post by Michiel Rop

My comments below.

(Sent from my mobile phone. Apologies for any typos.)
On Oct 4, 2012 4:34 AM, "Michiel Rop" <[hidden email]> wrote:
>
> Hi all,
>
> Concerning setting the content type in the component:
>
> When a request is processed by multiple components ( e.g. header, content, footer, etc...), they all can set the content type. When you set the content type in the jsp you make sure that one will actually be used. The jsp for sure is the last "component" that is called.

Just for clarification, rendering is ordered by child to parent. So if content type is set in render templates, the root (layout) template will make changes finally.

Woonsan

>
> On Wed, Oct 3, 2012 at 2:23 PM, Woonsan Ko <[hidden email]> wrote:
>>
>> I think you can simply set/add header with response object in #doBeforeRlender() or jsp page whatever you want.
>>
>> Woonsan
>>
>> Sent from my mobile phone. Apologies for any typos.
>>
>> On Oct 3, 2012 8:06 AM, "Resistol" <[hidden email]> wrote:
>>>
>>> Jeroen Reijn wrote
>>> > Could you elaborate what kind of post-processing you would like to do?
>>>
>>> Basically, I have some documents specifically targeted for mobile devices
>>> and will treat all links in a different way. Even those found in rich text
>>> values. I can verify in the layout (jsp) if the document has the target set
>>> for mobile devices, but it is cumbersome accessing the response from there.
>>>
>>> In the request, we know it is coming from the specific client, but it also
>>> includes a key parameter. If the parameter is found in the content of the
>>> page, we need to include a different parameter on the header of the
>>> response.
>>>
>>> Additionally, for our auditing purposes, this post-processing might also be
>>> valuable when storing the whole page returned to the client.
>>>
>>>
>>> Jeroen Reijn wrote
>>> > Why do you need to do this 'after' the content is rendered. In the
>>> > render phase only data is written to the output stream. What kind of
>>> > information are you missing in the doBeforeRender phase?
>>>
>>> Based on the data written to the output stream, thus processing, we include
>>> a proper parameter in the header response. With this header value, the
>>> client will treat the content accordingly.
>>>
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context: http://hippo.2275632.n2.nabble.com/Modify-the-Response-header-tp7579442p7579447.html
>>> Sent from the Hippo CMS 7 mailing list archive at Nabble.com.
>>> _______________________________________________
>>> Hippo-cms7-user mailing list and forums
>>> http://www.onehippo.org/cms7/support/forums.html
>>
>>
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
>
>
>
>
> --
> Best regards,
> Michiel Rop
>
> --
>
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> Boston - 1 Broadway, Cambridge, MA 02142
>
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
> www.onehippo.com
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html