You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Strauch <mi...@hannonhill.com> on 2017/03/02 20:18:58 UTC

ELContext no longer available to tagfiles

Hello!

I’ve recently upgraded from Tomcat 8.0.23 to 8.0.41 and noticed that the EL
context that is available to JSPs in my application is no longer available
in tagfiles used inside those JSPs (which was the case in 8.0.23).

We have a servlet listener declared in our web.xml which reacts to
contextInitialized events by adding an ElContextListener to the current
JSPApplicationContext (accessed
via JspFactory.getDefaultFactory().getJspApplicationContext()).  This
ELContextListener populates the current ElContext (acquired via
the ELContextEvent passed to the contextCreated method) with a number of
static tools that we use in our EL expressions inside JSPs and tagfiles.

The contextCreated() calls to our ElContextListener appear to be the same
between 8.0.23 and 8.0.41 when testing with the same JSP; but inside the
tagfiles themselves, the classes that we are adding to the context are not
available.  For example, we are adding an ArrayUtils class which we were
previously accessing via an expression like
${ArrayUtils.contains(pageScope.someArray, pageScope.someValue}.  This
expression works inside a JSP, but not in a tagfile.

I looked through the changelog entries between 8.0.23 and 8.0.41 and came
across a couple items which may be related to this issue:

- 58178: Expressions in a tag file should use the tag file's PageContext
rather than that of the containing page.
- Following on from the fix for 58178, expressions in a tag file should use
the tag file's imports rather than those of the containing page.

Is there some way to preserve the behavior we were relying on before?  It
seems like either more contextCreated events should be firing (perhaps once
per tagfile invocation?) to make up for the changes listed above or that
the ElContext being used should be passed from the JSP “context” into the
tagfiles.  Just reading above change entries, though, the latter solution
seems like it’d require reverting those exact changes which doesn’t seem
ideal.

Thanks for the help!

--
Mike Strauch
w. www.hannonhill.com
e mike.strauch@hannonhill.com

Re: ELContext no longer available to tagfiles

Posted by Mark Thomas <ma...@apache.org>.
On 24/03/17 22:52, Mike Strauch wrote:
> On Fri, Mar 24, 2017 at 3:21 PM, Mike Strauch
> <mi...@hannonhill.com> wrote:
>> ...  I\u2019ll take a look.
> 
> Appears to be working.  Thanks again!

Great. Thanks for the confirmation.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mike Strauch <mi...@hannonhill.com>.
On Fri, Mar 24, 2017 at 3:21 PM, Mike Strauch
<mi...@hannonhill.com> wrote:
> ...  I’ll take a look.

Appears to be working.  Thanks again!

-- 
Mike Strauch
Lead Software Engineer, Hannon Hill
w. www.hannonhill.com
e mike.strauch@hannonhill.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mike Strauch <mi...@hannonhill.com>.
On Tue, Mar 7, 2017 at 2:54 AM, Mark Thomas <ma...@apache.org> wrote:
>
> I think I have fixed this. The fix includes a simplistic test case.
> Verification of the fix would be appreciated.
>
> Mark

Hey Mark,

Apologies, I just noticed your reply.  I see the fix in the 8.0.42
release.  I’ll take a look.

-- 
Mike Strauch
Lead Software Engineer, Hannon Hill
w. www.hannonhill.com
e mike.strauch@hannonhill.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mark Thomas <ma...@apache.org>.
On 03/03/17 19:58, Mike Strauch wrote:
>> Exactly. An ELContext is being created so that listener should fire.
> 
> Cool, thanks!

I think I have fixed this. The fix includes a simplistic test case.
Verification of the fix would be appreciated.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mike Strauch <mi...@hannonhill.com>.
> Exactly. An ELContext is being created so that listener should fire.

Cool, thanks!

-- 
Mike Strauch
Lead Software Engineer, Hannon Hill
w. www.hannonhill.com
e mike.strauch@hannonhill.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mark Thomas <ma...@apache.org>.
On 3 March 2017 18:08:26 GMT+00:00, Mike Strauch <mi...@hannonhill.com> wrote:
>>> The former solution looks possible and - based on a fairly quick
>review
>>> of the specs - should be happening anyway.
>
>Just wanted to clarify here.  Are you saying that it is correct to
>assume that each tagfile invocation should be accompanied by a
>ElContextListener.contextCreated() call?

Exactly. An ELContext is being created so that listener should fire.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mike Strauch <mi...@hannonhill.com>.
>> The former solution looks possible and - based on a fairly quick review
>> of the specs - should be happening anyway.

Just wanted to clarify here.  Are you saying that it is correct to
assume that each tagfile invocation should be accompanied by a
ElContextListener.contextCreated() call? or would there be some other
event handler we’d have to hook into for ElContext’s used by tagfiles?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mike Strauch <mi...@hannonhill.com>.
On Thu, Mar 2, 2017 at 1:02 PM, Mark Thomas <ma...@apache.org> wrote:
>
> I think you have correctly identified the commits responsible for the
> change of behaviour you see.
>
> Of the two solutions you propose, I agree the latter solution is not viable.
>
> The former solution looks possible and - based on a fairly quick review
> of the specs - should be happening anyway.
>
> What would be very helpful would be if you could put together the
> simplest possible web application that demonstrates this problem and
> attach it a new Bugzilla issue.
>
> I have some initial ideas for how to fix this but it would be helpful to
> have a test case to confirm any proposed fix.
>
> Thanks,
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>

Hey Mark,

Thanks for the quick reply.  We do have a work around for the problem,
but I will create a webapp that replicates it as soon as I can.

Thanks again!

-- 
Mike Strauch
Lead Software Engineer, Hannon Hill
e mike.strauch@hannonhill.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: ELContext no longer available to tagfiles

Posted by Mark Thomas <ma...@apache.org>.
On 02/03/17 20:18, Mike Strauch wrote:
> Hello!
> 
> I\u2019ve recently upgraded from Tomcat 8.0.23 to 8.0.41 and noticed that the EL
> context that is available to JSPs in my application is no longer available
> in tagfiles used inside those JSPs (which was the case in 8.0.23).
> 
> We have a servlet listener declared in our web.xml which reacts to
> contextInitialized events by adding an ElContextListener to the current
> JSPApplicationContext (accessed
> via JspFactory.getDefaultFactory().getJspApplicationContext()).  This
> ELContextListener populates the current ElContext (acquired via
> the ELContextEvent passed to the contextCreated method) with a number of
> static tools that we use in our EL expressions inside JSPs and tagfiles.
> 
> The contextCreated() calls to our ElContextListener appear to be the same
> between 8.0.23 and 8.0.41 when testing with the same JSP; but inside the
> tagfiles themselves, the classes that we are adding to the context are not
> available.  For example, we are adding an ArrayUtils class which we were
> previously accessing via an expression like
> ${ArrayUtils.contains(pageScope.someArray, pageScope.someValue}.  This
> expression works inside a JSP, but not in a tagfile.
> 
> I looked through the changelog entries between 8.0.23 and 8.0.41 and came
> across a couple items which may be related to this issue:
> 
> - 58178: Expressions in a tag file should use the tag file's PageContext
> rather than that of the containing page.
> - Following on from the fix for 58178, expressions in a tag file should use
> the tag file's imports rather than those of the containing page.
> 
> Is there some way to preserve the behavior we were relying on before?  It
> seems like either more contextCreated events should be firing (perhaps once
> per tagfile invocation?) to make up for the changes listed above or that
> the ElContext being used should be passed from the JSP \u201ccontext\u201d into the
> tagfiles.  Just reading above change entries, though, the latter solution
> seems like it\u2019d require reverting those exact changes which doesn\u2019t seem
> ideal.

I think you have correctly identified the commits responsible for the
change of behaviour you see.

Of the two solutions you propose, I agree the latter solution is not viable.

The former solution looks possible and - based on a fairly quick review
of the specs - should be happening anyway.

What would be very helpful would be if you could put together the
simplest possible web application that demonstrates this problem and
attach it a new Bugzilla issue.

I have some initial ideas for how to fix this but it would be helpful to
have a test case to confirm any proposed fix.

Thanks,

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org