geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevan Miller <kevan.mil...@gmail.com>
Subject Re: Injecting EJB directly into a JSP
Date Wed, 02 Jul 2008 13:38:45 GMT

On Jul 2, 2008, at 3:36 AM, David Jencks wrote:

>
> On Jul 1, 2008, at 6:21 PM, purdticker wrote:
>
>>
>> At the top of my jsp:
>>
>> <%!
>> @EJB(name="ejb/ReportTrends")
>> private ReportTrends rt;
>> %>
>>
>> Within the body tags:
>>
>>   <%
>>   if (rt != null) {
>>   	out.println(rt.getData());
>>   }
>>   else {
>>   	out.println("rt is null");
>>   }
>>   %>
>>
>> The page displays "rt is null".
>>
>> I've tried this same code inside a servlet and rt is not null.  Is it
>> possible to inject an EJB directly into a jsp?
>
> Annotations/injections are not supported in jsps as far as I can  
> tell from reading the servlet and jsp specs.  If you can find some  
> indications they are supported they might not be too hard to  
> implement.

Per JSP.7.1.11, they're supported in a JSP container, but only with in  
tag handlers and event listeners. So, agreed that above scenario isn't  
supported by the spec. That said, supporting it doesn't seem too  
unreasonable, either. If someone were to get this enabled, I wouldn't  
complain...

--kevan

Mime
View raw message