You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2007/12/12 13:49:24 UTC

Make ServletContext available to scripts?

Hi,

Having access to ServletContext in scripts would be useful to allow
scripts to access java objects initialized by other servlets.

If we agree, I'll add a suitable constant to SlingScriptEngine, and
change ScriptHelper and MicroslingScriptResolver accordingly.

-Bertrand

Re: Make ServletContext available to scripts?

Posted by Felix Meschberger <fm...@gmail.com>.
Cool.

Regards
Fliex

Am Mittwoch, den 12.12.2007, 14:21 +0100 schrieb Bertrand Delacretaz:
> On Dec 12, 2007 2:11 PM, Felix Meschberger <fm...@gmail.com> wrote:
> 
> > ...we can the servlet context through:
> >
> >     request.getServiceLocator().getService(ServletContext.class);
> 
> Good idea, that requires just registering the ServletContext with the
> MicroslingServiceLocator.
> 
> I'll implement it this way as it has little impact.
> 
> -Bertrand


Re: Make ServletContext available to scripts?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Dec 12, 2007 2:11 PM, Felix Meschberger <fm...@gmail.com> wrote:

> ...we can the servlet context through:
>
>     request.getServiceLocator().getService(ServletContext.class);

Good idea, that requires just registering the ServletContext with the
MicroslingServiceLocator.

I'll implement it this way as it has little impact.

-Bertrand

Re: Make ServletContext available to scripts?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Dec 12, 2007 2:24 PM, Philipp Koch <ph...@day.com> wrote:
> >     request.getServiceLocator().getService(ServletContext.class);
> and what about microsling?

Coming up, see https://issues.apache.org/jira/browse/SLING-136

-Bertrand

Re: Make ServletContext available to scripts?

Posted by Philipp Koch <ph...@day.com>.
>     request.getServiceLocator().getService(ServletContext.class);
and what about microsling?
regards, philipp

On 12/12/07, Carsten Ziegeler <cz...@apache.org> wrote:
> Felix Meschberger wrote:
> > Hi Betrand,
> >
> > Am Mittwoch, den 12.12.2007, 13:49 +0100 schrieb Bertrand Delacretaz:
> >> Hi,
> >>
> >> Having access to ServletContext in scripts would be useful to allow
> >> scripts to access java objects initialized by other servlets.
> >
> > This is definitely reasonable. Therefore the ServletContext is available
> > as an OSGi Service in Sling.
> >
> >> If we agree, I'll add a suitable constant to SlingScriptEngine, and
> >> change ScriptHelper and MicroslingScriptResolver accordingly.
> >
> > The SlingScriptEngine does not exist anymore. And I also think, that
> > providing this through a constant is not a good thing.
> >
> > I could imagine, that we might provide the ServletContext through the
> > SlingScriptHelper as getServletContext(). But I am not sure, whether is
> > worth it if we can the servlet context through:
> >
> >     request.getServiceLocator().getService(ServletContext.class);
> >
> > I would prefer this.
> >
> Me, too.
>
> Carsten
>
> --
> Carsten Ziegeler
> cziegeler@apache.org
>

Re: Make ServletContext available to scripts?

Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger wrote:
> Hi Betrand,
> 
> Am Mittwoch, den 12.12.2007, 13:49 +0100 schrieb Bertrand Delacretaz:
>> Hi,
>>
>> Having access to ServletContext in scripts would be useful to allow
>> scripts to access java objects initialized by other servlets.
> 
> This is definitely reasonable. Therefore the ServletContext is available
> as an OSGi Service in Sling.
> 
>> If we agree, I'll add a suitable constant to SlingScriptEngine, and
>> change ScriptHelper and MicroslingScriptResolver accordingly.
> 
> The SlingScriptEngine does not exist anymore. And I also think, that
> providing this through a constant is not a good thing.
> 
> I could imagine, that we might provide the ServletContext through the
> SlingScriptHelper as getServletContext(). But I am not sure, whether is
> worth it if we can the servlet context through:
> 
>     request.getServiceLocator().getService(ServletContext.class);
> 
> I would prefer this.
> 
Me, too.

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org

Re: Make ServletContext available to scripts?

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Betrand,

Am Mittwoch, den 12.12.2007, 13:49 +0100 schrieb Bertrand Delacretaz:
> Hi,
> 
> Having access to ServletContext in scripts would be useful to allow
> scripts to access java objects initialized by other servlets.

This is definitely reasonable. Therefore the ServletContext is available
as an OSGi Service in Sling.

> If we agree, I'll add a suitable constant to SlingScriptEngine, and
> change ScriptHelper and MicroslingScriptResolver accordingly.

The SlingScriptEngine does not exist anymore. And I also think, that
providing this through a constant is not a good thing.

I could imagine, that we might provide the ServletContext through the
SlingScriptHelper as getServletContext(). But I am not sure, whether is
worth it if we can the servlet context through:

    request.getServiceLocator().getService(ServletContext.class);

I would prefer this.

WDYT ?

Regards
Felix



Re: Make ServletContext available to scripts?

Posted by Carsten Ziegeler <cz...@apache.org>.
Bertrand Delacretaz wrote:
> Hi,
> 
> Having access to ServletContext in scripts would be useful to allow
> scripts to access java objects initialized by other servlets.
> 
> If we agree, I'll add a suitable constant to SlingScriptEngine, and
> change ScriptHelper and MicroslingScriptResolver accordingly.
> 
I don't see a problem in making the servlet context available. However I
don't think that its a good design if a script or a servlet relies on
something another servlet has created. Servlets are for generating
responses to requests but not for preparing the environment.

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org