You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Jess Holle <je...@ptc.com> on 2008/09/17 14:48:33 UTC

In-process connector?

Is there an in-process connector for Tomcat somewhere out there?

Specifically I want to be able to embed Tomcat and use JSPs, etc, to 
generate HTML but without requiring loopback HTTP(S) requests.

Does such a thing exist?  If not, would this be hard to add?

Pointers and suggestions would be much appreciated.

--
Jess Holle


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


Re: In-process connector?

Posted by Costin Manolache <co...@gmail.com>.
About how to word the question for tomcat-dev: "Hi, I'm interested in
developing an 'in-process' feature if it's not already there,
will start sending out patches " :-)

BTW - there is also an 'in-memory' connector in coyote, not sure what's his
status - but it can be easily enhanced.
You actually need 3 things:
- launching tomcat in-process - there are few ways to do this ( easy if you
can keep the dir layout, harder but possible if you don't )
- use a connector that doesn't open ports
- some API to make it easier to communicate with the connector - basically
populate the coyote request and pull the response.


Costin

On Mon, Oct 6, 2008 at 12:44 PM, Jess Holle <je...@ptc.com> wrote:

> Cool.
>
> Thanks for the helpful reply.
>
> I just wish I could have figured out how to word my question better so as
> to elicit this helpful information to start with -- instead of getting told
> I was posting to the wrong group and chasing my tail with it.
>
> --
> Jess Holle
>
>
> Costin Manolache wrote:
>
>> Well, there is interest - the tomcat-lite in the sandbox does allow that (
>> there is even a TomcatLiteNoConnector unit test ).
>>
>> The code is broken right now - in process of moving part of it to trunk
>> and
>> adjusting it to be easier to digest. Will take quite a while
>> before it's ready for an official release - but ability to run 'in
>> process'
>> ( either as unit tests,  or as you describe ) is one of the goals.
>>
>> Costin
>>
>> On Mon, Oct 6, 2008 at 11:16 AM, Jess Holle <je...@ptc.com> wrote:
>>
>>
>>> Having looked into this further it seems clear Tomcat is not designed to
>>> provide any reasonably reliable / easy-to-use means of making a JSP or
>>> servlet request from within the process but outside a connector request
>>> thread.  If one wants to properly do this it would appear one has to call
>>> org.apache.catalina.core.StandardEngineValve.invoke() oneself -- with
>>> Tomcat
>>> Request and Response objects.  Ideally there would be a way to instead
>>> implement HttpServletRequest and HttpServletResponse as desired,
>>> mimicking
>>> remote client to the degree needed, get a RequestDispatcher [from a
>>> cached
>>> ServletContext], and call forward(), for instance -- possibly capturing
>>> the
>>> context class loader in a ContextListener and setting that as the context
>>> class loader around all this.  That /kind of/ works for include(), but
>>> skips
>>> all servlet filters and does not work at all for forward().
>>>
>>> I fully realize the servlet specification spells out no such mechanism,
>>> but
>>> I believe there is a clear gap here.  One should be able to embed Tomcat
>>> in
>>> an application and /easily /invoke a JSP or servlet to produce an HTML
>>> e-mail body, for instance.  This should involve a minimum of
>>> Tomcat-specific
>>> APIs.
>>>
>>> It is hard to understand why one should be unable to re-use one's JSPs
>>> and
>>> servlet investment to produce HTML for other purposes than HTTP
>>> responses.//
>>>  It is also quite unclear to me why there appears to be no interest in
>>> addressing this need.
>>>
>>> --
>>> Jess Holle
>>>
>>>
>>> Jess Holle wrote:
>>>
>>>
>>>> I find no user documentation on anything like what I'm looking for.
>>>>
>>>> I thus am /assuming/ this would be an extension to Tomcat and thus more
>>>> appropriate for a development forum than a user forum.
>>>>
>>>> I want to call JSPs, etc, from Java code to generate HTML.  I'm not
>>>> looking for a web server connector -- that would be a clear user group
>>>> question.
>>>>
>>>> Remy Maucherat wrote
>>>>
>>>>> On Wed, 2008-09-17 at 07:48 -0500, Jess Holle wrote
>>>>>
>>>>>> Is there an in-process connector for Tomcat somewhere out there?
>>>>>>
>>>>>> Specifically I want to be able to embed Tomcat and use JSPs, etc, to
>>>>>> generate HTML but without requiring loopback HTTP(S) requests.
>>>>>>
>>>>>> Does such a thing exist?  If not, would this be hard to add?
>>>>>>
>>>>>> Pointers and suggestions would be much appreciated.
>>>>>>
>>>>>>
>>>>> There is a user list for questions on Tomcat usage.
>>>>>
>>>>> Rémy
>>>>>
>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: In-process connector?

Posted by Jess Holle <je...@ptc.com>.
Cool.

Thanks for the helpful reply.

I just wish I could have figured out how to word my question better so 
as to elicit this helpful information to start with -- instead of 
getting told I was posting to the wrong group and chasing my tail with it.

--
Jess Holle

Costin Manolache wrote:
> Well, there is interest - the tomcat-lite in the sandbox does allow that (
> there is even a TomcatLiteNoConnector unit test ).
>
> The code is broken right now - in process of moving part of it to trunk and
> adjusting it to be easier to digest. Will take quite a while
> before it's ready for an official release - but ability to run 'in process'
> ( either as unit tests,  or as you describe ) is one of the goals.
>
> Costin
>
> On Mon, Oct 6, 2008 at 11:16 AM, Jess Holle <je...@ptc.com> wrote:
>   
>> Having looked into this further it seems clear Tomcat is not designed to
>> provide any reasonably reliable / easy-to-use means of making a JSP or
>> servlet request from within the process but outside a connector request
>> thread.  If one wants to properly do this it would appear one has to call
>> org.apache.catalina.core.StandardEngineValve.invoke() oneself -- with Tomcat
>> Request and Response objects.  Ideally there would be a way to instead
>> implement HttpServletRequest and HttpServletResponse as desired, mimicking
>> remote client to the degree needed, get a RequestDispatcher [from a cached
>> ServletContext], and call forward(), for instance -- possibly capturing the
>> context class loader in a ContextListener and setting that as the context
>> class loader around all this.  That /kind of/ works for include(), but skips
>> all servlet filters and does not work at all for forward().
>>
>> I fully realize the servlet specification spells out no such mechanism, but
>> I believe there is a clear gap here.  One should be able to embed Tomcat in
>> an application and /easily /invoke a JSP or servlet to produce an HTML
>> e-mail body, for instance.  This should involve a minimum of Tomcat-specific
>> APIs.
>>
>> It is hard to understand why one should be unable to re-use one's JSPs and
>> servlet investment to produce HTML for other purposes than HTTP responses.//
>>  It is also quite unclear to me why there appears to be no interest in
>> addressing this need.
>>
>> --
>> Jess Holle
>>
>>
>> Jess Holle wrote:
>>     
>>> I find no user documentation on anything like what I'm looking for.
>>>
>>> I thus am /assuming/ this would be an extension to Tomcat and thus more
>>> appropriate for a development forum than a user forum.
>>>
>>> I want to call JSPs, etc, from Java code to generate HTML.  I'm not
>>> looking for a web server connector -- that would be a clear user group
>>> question.
>>>
>>> Remy Maucherat wrote
>>>> On Wed, 2008-09-17 at 07:48 -0500, Jess Holle wrote
>>>>> Is there an in-process connector for Tomcat somewhere out there?
>>>>>
>>>>> Specifically I want to be able to embed Tomcat and use JSPs, etc, to
>>>>> generate HTML but without requiring loopback HTTP(S) requests.
>>>>>
>>>>> Does such a thing exist?  If not, would this be hard to add?
>>>>>
>>>>> Pointers and suggestions would be much appreciated.
>>>>>           
>>>> There is a user list for questions on Tomcat usage.
>>>>
>>>> Rémy


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


Re: In-process connector?

Posted by Costin Manolache <co...@gmail.com>.
Well, there is interest - the tomcat-lite in the sandbox does allow that (
there is even a TomcatLiteNoConnector unit test ).

The code is broken right now - in process of moving part of it to trunk and
adjusting it to be easier to digest. Will take quite a while
before it's ready for an official release - but ability to run 'in process'
( either as unit tests,  or as you describe ) is one of the goals.

Costin


On Mon, Oct 6, 2008 at 11:16 AM, Jess Holle <je...@ptc.com> wrote:

> Having looked into this further it seems clear Tomcat is not designed to
> provide any reasonably reliable / easy-to-use means of making a JSP or
> servlet request from within the process but outside a connector request
> thread.  If one wants to properly do this it would appear one has to call
> org.apache.catalina.core.StandardEngineValve.invoke() oneself -- with Tomcat
> Request and Response objects.  Ideally there would be a way to instead
> implement HttpServletRequest and HttpServletResponse as desired, mimicking
> remote client to the degree needed, get a RequestDispatcher [from a cached
> ServletContext], and call forward(), for instance -- possibly capturing the
> context class loader in a ContextListener and setting that as the context
> class loader around all this.  That /kind of/ works for include(), but skips
> all servlet filters and does not work at all for forward().
>
> I fully realize the servlet specification spells out no such mechanism, but
> I believe there is a clear gap here.  One should be able to embed Tomcat in
> an application and /easily /invoke a JSP or servlet to produce an HTML
> e-mail body, for instance.  This should involve a minimum of Tomcat-specific
> APIs.
>
> It is hard to understand why one should be unable to re-use one's JSPs and
> servlet investment to produce HTML for other purposes than HTTP responses.//
>  It is also quite unclear to me why there appears to be no interest in
> addressing this need.
>
> --
> Jess Holle
>
>
> Jess Holle wrote:
>
>> I find no user documentation on anything like what I'm looking for.
>>
>> I thus am /assuming/ this would be an extension to Tomcat and thus more
>> appropriate for a development forum than a user forum.
>>
>> I want to call JSPs, etc, from Java code to generate HTML.  I'm not
>> looking for a web server connector -- that would be a clear user group
>> question.
>>
>> Remy Maucherat wrote:
>>
>>> On Wed, 2008-09-17 at 07:48 -0500, Jess Holle wrote:
>>>
>>>
>>>> Is there an in-process connector for Tomcat somewhere out there?
>>>>
>>>> Specifically I want to be able to embed Tomcat and use JSPs, etc, to
>>>> generate HTML but without requiring loopback HTTP(S) requests.
>>>>
>>>> Does such a thing exist?  If not, would this be hard to add?
>>>>
>>>> Pointers and suggestions would be much appreciated.
>>>>
>>>>
>>>
>>> There is a user list for questions on Tomcat usage.
>>>
>>> Rémy
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>>
>>>
>>>
>>
>>
>

Re: In-process connector?

Posted by Jess Holle <je...@ptc.com>.
Having looked into this further it seems clear Tomcat is not designed to 
provide any reasonably reliable / easy-to-use means of making a JSP or 
servlet request from within the process but outside a connector request 
thread.  If one wants to properly do this it would appear one has to 
call org.apache.catalina.core.StandardEngineValve.invoke() oneself -- 
with Tomcat Request and Response objects.  Ideally there would be a way 
to instead implement HttpServletRequest and HttpServletResponse as 
desired, mimicking remote client to the degree needed, get a 
RequestDispatcher [from a cached ServletContext], and call forward(), 
for instance -- possibly capturing the context class loader in a 
ContextListener and setting that as the context class loader around all 
this.  That /kind of/ works for include(), but skips all servlet filters 
and does not work at all for forward().

I fully realize the servlet specification spells out no such mechanism, 
but I believe there is a clear gap here.  One should be able to embed 
Tomcat in an application and /easily /invoke a JSP or servlet to produce 
an HTML e-mail body, for instance.  This should involve a minimum of 
Tomcat-specific APIs.

It is hard to understand why one should be unable to re-use one's JSPs 
and servlet investment to produce HTML for other purposes than HTTP 
responses.//  It is also quite unclear to me why there appears to be no 
interest in addressing this need.

--
Jess Holle

Jess Holle wrote:
> I find no user documentation on anything like what I'm looking for.
>
> I thus am /assuming/ this would be an extension to Tomcat and thus 
> more appropriate for a development forum than a user forum.
>
> I want to call JSPs, etc, from Java code to generate HTML.  I'm not 
> looking for a web server connector -- that would be a clear user group 
> question.
>
> Remy Maucherat wrote:
>> On Wed, 2008-09-17 at 07:48 -0500, Jess Holle wrote:
>>   
>>> Is there an in-process connector for Tomcat somewhere out there?
>>>
>>> Specifically I want to be able to embed Tomcat and use JSPs, etc, to 
>>> generate HTML but without requiring loopback HTTP(S) requests.
>>>
>>> Does such a thing exist?  If not, would this be hard to add?
>>>
>>> Pointers and suggestions would be much appreciated.
>>>     
>>
>> There is a user list for questions on Tomcat usage.
>>
>> Rémy
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>>   
>


Re: In-process connector?

Posted by Jess Holle <je...@ptc.com>.
I find no user documentation on anything like what I'm looking for.

I thus am /assuming/ this would be an extension to Tomcat and thus more 
appropriate for a development forum than a user forum.

I want to call JSPs, etc, from Java code to generate HTML.  I'm not 
looking for a web server connector -- that would be a clear user group 
question.

Remy Maucherat wrote:
> On Wed, 2008-09-17 at 07:48 -0500, Jess Holle wrote:
>   
>> Is there an in-process connector for Tomcat somewhere out there?
>>
>> Specifically I want to be able to embed Tomcat and use JSPs, etc, to 
>> generate HTML but without requiring loopback HTTP(S) requests.
>>
>> Does such a thing exist?  If not, would this be hard to add?
>>
>> Pointers and suggestions would be much appreciated.
>>     
>
> There is a user list for questions on Tomcat usage.
>
> Rémy
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>   


Re: In-process connector?

Posted by Remy Maucherat <re...@apache.org>.
On Wed, 2008-09-17 at 07:48 -0500, Jess Holle wrote:
> Is there an in-process connector for Tomcat somewhere out there?
> 
> Specifically I want to be able to embed Tomcat and use JSPs, etc, to 
> generate HTML but without requiring loopback HTTP(S) requests.
> 
> Does such a thing exist?  If not, would this be hard to add?
> 
> Pointers and suggestions would be much appreciated.

There is a user list for questions on Tomcat usage.

Rémy



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


Re: In-process connector?

Posted by Jess Holle <je...@ptc.com>.
I guess I should clarify.

I want Java code to do in-process requests to JSPs (etc) for HTML.

This shouldn't involve sockets or JNI -- just a plain simple mechanism 
to take ServletRequest/HttpServletRequest and 
ServletResponse/HttpServletResponse objects and toss these (in process) 
at Tomcat and let it pass these to the normal FilterChain, etc, with the 
output written to the response stream/writer.  Nothing terribly fancy, 
but this would allow in-process use of JSPs to generate HTML for various 
non-browser purposes.  Otherwise one is stuck with the unnecessary 
dichotomy of generating browser HTML one way and all other HTML some 
other way -- unless one forgoes any technology, like JSP, that relies on 
the servlet API.

Henri Gomez wrote:
> There was a JNI connector sometimes ago.
>
> I'm unsure if it's still maintened
>
> 2008/9/17 Jess Holle <je...@ptc.com>:
>   
>> Is there an in-process connector for Tomcat somewhere out there?
>>
>> Specifically I want to be able to embed Tomcat and use JSPs, etc, to
>> generate HTML but without requiring loopback HTTP(S) requests.
>>
>> Does such a thing exist?  If not, would this be hard to add?
>>
>> Pointers and suggestions would be much appreciated.
>>
>> --
>> Jess Holle
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>   


Re: In-process connector?

Posted by Henri Gomez <he...@gmail.com>.
There was a JNI connector sometimes ago.

I'm unsure if it's still maintened

2008/9/17 Jess Holle <je...@ptc.com>:
> Is there an in-process connector for Tomcat somewhere out there?
>
> Specifically I want to be able to embed Tomcat and use JSPs, etc, to
> generate HTML but without requiring loopback HTTP(S) requests.
>
> Does such a thing exist?  If not, would this be hard to add?
>
> Pointers and suggestions would be much appreciated.
>
> --
> Jess Holle
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

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