jsp requestScope and pageScope question

164 views
Skip to first unread message

wim.lustenhouwer

unread,
Nov 30, 2016, 6:06:21 AM11/30/16
to Hippo Community
Hi all,

I'm looking for someone with extended JSP knowledge. I'm currently upgrading a 7.9 project. This project has a whole host of jsp templates with attributes directly notetd 
(like <h1>${document.title}</h1> So naturally this should be requestScope.document etc...

but since there are so many templates I figured it would be easier (and slightly more readable to start all jps's with
<c:set var="document" value="${requestScope.document}"/>
I do the same in .tag files but with pageScope, the question know would be whether this actually helps or if I'm just moving the problem to a single set method. 

Also FFR:
naturally attributes created in the templates like for example hst:link var="foo", do not get the requestScope treatment (no requestScope.foo here).


Woonsan Ko

unread,
Nov 30, 2016, 9:22:29 AM11/30/16
to hippo-c...@googlegroups.com
On Wed, Nov 30, 2016 at 6:06 AM, wim.lustenhouwer <wim.lust...@finalist.nl> wrote:
Hi all,

I'm looking for someone with extended JSP knowledge. I'm currently upgrading a 7.9 project. This project has a whole host of jsp templates with attributes directly notetd 
(like <h1>${document.title}</h1> So naturally this should be requestScope.document etc...
 

but since there are so many templates I figured it would be easier (and slightly more readable to start all jps's with
<c:set var="document" value="${requestScope.document}"/>
It's because the "document" attribute was set to "request" (HstRequest which extends HttpServletRequest). 
I do the same in .tag files but with pageScope, the question know would be whether this actually helps or if I'm just moving the problem to a single set method. 
Most tag libraries sets an attribute in the page scope by default. So, if the attribute was set by tag library with the default scope, then you're right, you need to refer to it via pageScope. 

Also FFR:
naturally attributes created in the templates like for example hst:link var="foo", do not get the requestScope treatment (no requestScope.foo here).
<hst:link> tag always stores the result into an attribute with the variable name ("var") into pageScope if "var" attribute is set in the tag.

(As a side note, the tag could have provided "scope" attribute like <hst:setBundle/> tag, but not at the moment. Although the code has already implemented it internally, the attribute was not exposed in tag definition.)

Regards,

Woonsan 



--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.



--
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

Wim Lustenhouwer

unread,
Nov 30, 2016, 9:42:06 AM11/30/16
to hippo-c...@googlegroups.com
Hi Woonsan

Thank you for the clarification. I still have a question though. 
The tags are perfectly clear now, but for the regular JSP’s I wonder if my “trick” actually works.

So I have documents which have like 6 references to ${document}, 
Instead of refactoring all of them to say requestScope.document, I added the mentioned code on top of the document, namely:
<c:set var="document" value="${requestScope.document}"/>

So I’m wondering if this is sufficient. Can you help me with this?

Regards
Wim

To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.


Woonsan Ko

unread,
Nov 30, 2016, 9:53:14 AM11/30/16
to hippo-c...@googlegroups.com
On Wed, Nov 30, 2016 at 9:42 AM, Wim Lustenhouwer <wim.lust...@finalist.nl> wrote:
Hi Woonsan

Thank you for the clarification. I still have a question though. 
The tags are perfectly clear now, but for the regular JSP’s I wonder if my “trick” actually works.

So I have documents which have like 6 references to ${document}, 
Instead of refactoring all of them to say requestScope.document, I added the mentioned code on top of the document, namely:
<c:set var="document" value="${requestScope.document}"/>

So I’m wondering if this is sufficient. Can you help me with this?
One corner case is, what if ${requestScope.document} is null? Then the line wouldn't help in that case. In other most cases, I think it would save your efforts a lot. Brilliant.

Regards,

Woonsan

Jasper Floor

unread,
Nov 30, 2016, 9:57:25 AM11/30/16
to Hippo Community
On Wed, Nov 30, 2016 at 3:53 PM, Woonsan Ko <w....@onehippo.com> wrote:


On Wed, Nov 30, 2016 at 9:42 AM, Wim Lustenhouwer <wim.lust...@finalist.nl> wrote:
Hi Woonsan

Thank you for the clarification. I still have a question though. 
The tags are perfectly clear now, but for the regular JSP’s I wonder if my “trick” actually works.

So I have documents which have like 6 references to ${document}, 
Instead of refactoring all of them to say requestScope.document, I added the mentioned code on top of the document, namely:
<c:set var="document" value="${requestScope.document}"/>

So I’m wondering if this is sufficient. Can you help me with this?
One corner case is, what if ${requestScope.document} is null? Then the line wouldn't help in that case. In other most cases, I think it would save your efforts a lot. Brilliant.

But the case where ${requestScope.document} is null is exactly the case that caused problems. Though this should be fixed now (for tomcat) afaik.

mvg,
Jasper

Wim Lustenhouwer

unread,
Nov 30, 2016, 10:08:18 AM11/30/16
to hippo-c...@googlegroups.com
Hi guys,

We make a habit of null checking everything, 

so basically: 
<c:set var="form" value="${requestScope.form}"/>
<c:if test="${not empty form}">
Do I get around the problem like this, or will the engine still look outside of requestScope for form in this case?
regards
Wim

To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.


Jasper Floor

unread,
Nov 30, 2016, 10:14:22 AM11/30/16
to Hippo Community
I should also adjust my previous reply in that it isn't {requestScope.document} is null where the problem is but {document} is null. If you explicitly scope it doens't go outside the scope. If you check for null like this then you are covered. 

mvg,
Jasper

regards
Wim


Regards,

Woonsan
 

Regards
Wim




To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.



-- 
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.


-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.



-- 
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.

-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.

Woonsan Ko

unread,
Nov 30, 2016, 10:14:27 AM11/30/16
to hippo-c...@googlegroups.com
On Wed, Nov 30, 2016 at 10:08 AM, Wim Lustenhouwer <wim.lust...@finalist.nl> wrote:
Hi guys,

We make a habit of null checking everything, 

so basically: 
<c:set var="form" value="${requestScope.form}"/>
<c:if test="${not empty form}">
Do I get around the problem like this, or will the engine still look outside of requestScope for form in this case?
Null checking is not a big concern here in the perspective of performance.
The major problem is, JSP EL Engine may look up all the imported static members if an attribute name cannot be resolved in pageScope, requestScope, etc. (See https://tomcat.apache.org/migration-8.html#JavaServer_Pages_2.3 for detail.)
So, if the first line sets a non-null attribute, then that's fine afterward when using "form". Otherwise, you could meet the performance issue which can be circumvented more safely with ${requestScope.form} or ${pageScope.form}.

Regards,

Woonsan
 
regards
Wim


Regards,

Woonsan
 

Regards
Wim




To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.



-- 
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.


-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.



-- 
Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466

-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.

-- 
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
--- 
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsub...@googlegroups.com.

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Jasper Floor

unread,
Nov 30, 2016, 10:21:25 AM11/30/16
to Hippo Community
On Wed, Nov 30, 2016 at 4:14 PM, Woonsan Ko <w....@onehippo.com> wrote:


On Wed, Nov 30, 2016 at 10:08 AM, Wim Lustenhouwer <wim.lust...@finalist.nl> wrote:
Hi guys,

We make a habit of null checking everything, 

so basically: 
<c:set var="form" value="${requestScope.form}"/>
<c:if test="${not empty form}">
Do I get around the problem like this, or will the engine still look outside of requestScope for form in this case?
Null checking is not a big concern here in the perspective of performance.
The major problem is, JSP EL Engine may look up all the imported static members if an attribute name cannot be resolved in pageScope, requestScope, etc. (See https://tomcat.apache.org/migration-8.html#JavaServer_Pages_2.3 for detail.)
So, if the first line sets a non-null attribute, then that's fine afterward when using "form". Otherwise, you could meet the performance issue which can be circumvented more safely with ${requestScope.form} or ${pageScope.form}.

good point. You are still hitting the issue like this. But this has been addressed in tomcat:

mvg,
jasper


Regards,

Woonsan
 
regards
Wim


Regards,

Woonsan
 

Regards
Wim




To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Ard Schrijvers

unread,
Dec 1, 2016, 4:25:43 AM12/1/16
to hippo-c...@googlegroups.com
On Wed, Nov 30, 2016 at 4:21 PM, Jasper Floor <j.f...@onehippo.com> wrote:
>
>
>
> On Wed, Nov 30, 2016 at 4:14 PM, Woonsan Ko <w....@onehippo.com> wrote:
>>
>>
>>
>> On Wed, Nov 30, 2016 at 10:08 AM, Wim Lustenhouwer <wim.lust...@finalist.nl> wrote:
>>>
>>> Hi guys,
>>>
>>> We make a habit of null checking everything,
>>>
>>> so basically:
>>>
>>> <c:set var="form" value="${requestScope.form}"/>
>>> <c:if test="${not empty form}">
>>>
>>> Do I get around the problem like this, or will the engine still look outside of requestScope for form in this case?
>>
>> Null checking is not a big concern here in the perspective of performance.
>> The major problem is, JSP EL Engine may look up all the imported static members if an attribute name cannot be resolved in pageScope, requestScope, etc. (See https://tomcat.apache.org/migration-8.html#JavaServer_Pages_2.3 for detail.)
>> So, if the first line sets a non-null attribute, then that's fine afterward when using "form". Otherwise, you could meet the performance issue which can be circumvented more safely with ${requestScope.form} or ${pageScope.form}.
>
>
> good point. You are still hitting the issue like this. But this has been addressed in tomcat:
> https://bz.apache.org/bugzilla/show_bug.cgi?id=57583

Note I checked the code of the initial improvement they made in tomcat
and it was kind of...poor. It was a request scoped cache IIRC. Not
sure how much they improved, but to be spec compliant, you will hit a
performance penalty when you use ${document} instead of
${requestScope.document} in case you *know* it is meant to be taken
from the requestScope. So imho, use requestScope if you know the meant
scope is requestScope

Regards Ard
>>>>>> --
>>>>>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>>>>>
>>>>>> To post to this group, send email to hippo-c...@googlegroups.com
>>>>>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>>>>>> ---
>>>>>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>>>>>> Visit this group at https://groups.google.com/group/hippo-community.
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> w....@onehippo.com www.onehippo.com
>>>>> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
>>>>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>>>>> US +1 877 414 4776 (toll free)
>>>>> Europe +31(0)20 522 4466
>>>>>
>>>>> --
>>>>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>>>>
>>>>> To post to this group, send email to hippo-c...@googlegroups.com
>>>>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>>>>> ---
>>>>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/hippo-community.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>>>>
>>>>> To post to this group, send email to hippo-c...@googlegroups.com
>>>>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>>>>> ---
>>>>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>>>>> Visit this group at https://groups.google.com/group/hippo-community.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> w....@onehippo.com www.onehippo.com
>>>> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
>>>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>>>> US +1 877 414 4776 (toll free)
>>>> Europe +31(0)20 522 4466
>>>>
>>>> --
>>>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>>>
>>>> To post to this group, send email to hippo-c...@googlegroups.com
>>>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>>>> ---
>>>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>>>> Visit this group at https://groups.google.com/group/hippo-community.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>>
>>> To post to this group, send email to hippo-c...@googlegroups.com
>>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>>> ---
>>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/hippo-community.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>>
>>> To post to this group, send email to hippo-c...@googlegroups.com
>>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>>> ---
>>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/hippo-community.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>> --
>> w....@onehippo.com www.onehippo.com
>> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
>> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
>> US +1 877 414 4776 (toll free)
>> Europe +31(0)20 522 4466
>>
>> --
>> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>>
>> To post to this group, send email to hippo-c...@googlegroups.com
>> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
>> ---
>> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/hippo-community.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-c...@googlegroups.com
> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.




--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
states of America.

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

Wim Lustenhouwer

unread,
Dec 1, 2016, 8:39:09 AM12/1/16
to hippo-c...@googlegroups.com
Hi Ard

Thank you for looking into it. It feels mega redundant to write out the request scope for every variable though. So if I understand correctly, than by introducing a page variable to hold the requestScope variable, then i’d still need to prefix all those calls to pageScope.x? 

Sidenote, this problem seemed to be fixed in a Tomcat 8.something.23, did you mean I still need to prefix my variables? (it’s terror for readability imho)

Regards
Wim

Ard Schrijvers

unread,
Dec 1, 2016, 8:42:41 AM12/1/16
to hippo-c...@googlegroups.com
On Thu, Dec 1, 2016 at 2:39 PM, Wim Lustenhouwer
<wim.lust...@finalist.nl> wrote:
>
> Hi Ard
>
> Thank you for looking into it. It feels mega redundant to write out the request scope for every variable though. So if I understand correctly, than by introducing a page variable to hold the requestScope variable, then i’d still need to prefix all those calls to pageScope.x?
>
> Sidenote, this problem seemed to be fixed in a Tomcat 8.something.23, did you mean I still need to prefix my variables? (it’s terror for readability imho)

It has been a long time but when I looked at the first 'fix' in tomcat
I considered it to be a very poor hacky fix...perhaps they improved it
later, I don't know

Regards Ard

Jasper Floor

unread,
Dec 1, 2016, 8:54:19 AM12/1/16
to Hippo Community
On Thu, Dec 1, 2016 at 2:42 PM, Ard Schrijvers <a.schr...@onehippo.com> wrote:
On Thu, Dec 1, 2016 at 2:39 PM, Wim Lustenhouwer
<wim.lust...@finalist.nl> wrote:
>
> Hi Ard
>
> Thank you for looking into it. It feels mega redundant to write out the request scope for every variable though. So if I understand correctly, than by introducing a page variable to hold the requestScope variable, then i’d still need to prefix all those calls to pageScope.x?
>
> Sidenote, this problem seemed to be fixed in a Tomcat 8.something.23, did you mean I still need to prefix my variables? (it’s terror for readability imho)

It has been a long time but when I looked at the first 'fix' in tomcat
I considered it to be a very poor hacky fix...perhaps they improved it
later, I don't know

It was addressed in Tomcat 8.0.33. Whether that was sufficient I do not actually know. If you know your variables will not be undefined in the desired scope then you don't need to scope them. The null check you add does reduce the problem as well, since it avoids possible multiple calls to an undefined variable. You can explicitly scope only that as well, since if you pass that the rest is in a known scope. 

It is advisable to add performance tests for your site (in any case really). This will at least give an indication of any possible impact and what, if any, issues you need to fix.


A colleague analyzed the problem at the time: 

mvg,
Jasper

 

Regards Ard
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>
> --
> w....@onehippo.com     www.onehippo.com
> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>
> --
> w....@onehippo.com     www.onehippo.com
> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>
> --
> w....@onehippo.com     www.onehippo.com
> Boston - 745 Atlantic Ave, 8th Floor, Boston MA 02111
> Amsterdam - Oosteinde 11, 1017 WT Amsterdam
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
>
>
> --
> Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
> Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
> states of America.
>
> US +1 877 414 4776 (toll free)
> Europe +31(0)20 522 4466
> www.onehippo.com
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
>
> To post to this group, send email to hippo-community@googlegroups.com

> RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
> ---
> You received this message because you are subscribed to the Google Groups "Hippo Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

> Visit this group at https://groups.google.com/group/hippo-community.
> For more options, visit https://groups.google.com/d/optout.




--
Hippo Netherlands, Oosteinde 11, 1017 WT Amsterdam, Netherlands
Hippo USA, Inc. 71 Summer Street, 2nd Floor Boston, MA 02110, United
states of America.

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

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)

To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Woonsan Ko

unread,
Dec 1, 2016, 9:43:47 AM12/1/16
to hippo-c...@googlegroups.com
On Thu, Dec 1, 2016 at 8:54 AM, Jasper Floor <j.f...@onehippo.com> wrote:


On Thu, Dec 1, 2016 at 2:42 PM, Ard Schrijvers <a.schr...@onehippo.com> wrote:
On Thu, Dec 1, 2016 at 2:39 PM, Wim Lustenhouwer
<wim.lust...@finalist.nl> wrote:
>
> Hi Ard
>
> Thank you for looking into it. It feels mega redundant to write out the request scope for every variable though. So if I understand correctly, than by introducing a page variable to hold the requestScope variable, then i’d still need to prefix all those calls to pageScope.x?
>
> Sidenote, this problem seemed to be fixed in a Tomcat 8.something.23, did you mean I still need to prefix my variables? (it’s terror for readability imho)

It has been a long time but when I looked at the first 'fix' in tomcat
I considered it to be a very poor hacky fix...perhaps they improved it
later, I don't know
The 'fix' in Tomcat 8.0.33 was not a request scope caching, but it was to avoid class lookup *if* the expression variable is *single*.
*single* means no property paths. For example, "document", "info", etc. are *single*, but "document.title", "info.size", etc are not. Please follow the second e-mail thread link from Jasper's reference for details. (The request scope caching was suggested by someone before, but not accepted, fyi.)
Therefore, the 'fix' is very helpful in most cases.
 

It was addressed in Tomcat 8.0.33. Whether that was sufficient I do not actually know. If you know your variables will not be undefined in the desired scope then you don't need to scope them. The null check you add does reduce the problem as well, since it avoids possible multiple calls to an undefined variable. You can explicitly scope only that as well, since if you pass that the rest is in a known scope. 

It is advisable to add performance tests for your site (in any case really). This will at least give an indication of any possible impact and what, if any, issues you need to fix.
Logically speaking, if you run Tomcat 8.0.33+, then I don't expect you get any performance penalty by not fixing those. However, I haven't done any performance testing to compare the real results, so like Jasper suggested, it would be better to make sure if there's no differences in performance.

Regards,

Woonsan
Reply all
Reply to author
Forward
0 new messages