----- Original Message -----
From: "Jess Holle" <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Thursday, September 18, 2008 6:36 PM
Subject: Invoking JSP/servlet from non-request thread?
I want to invoke JSPs/servlets from non-request threads, e.g. to render
HTML for use in e-mails, etc.
I tried the simple-minded approach (with Tomcat 6.0.18):
ServletContext servletContext = MyContextMonitor.getContext(
"/myContextName" );
RequestDispatcher dispatcher =
servletContext.getRequestDispatcher( "/somePage.jsp" );
dispatcher.include( new Request( servletContext ), new
Response() );
where Request and Response are mock HttpServletRequest and
HttpServletResponse implementations. Response's output stream and
writer are routed to System.out.
I get the dispatcher fine. I get output if I use
"/somePropertiesFile.properties" in place of "/somePage.jsp" -- but only
if I use include(), not forward(). I don't get output for /somePage.jsp
in either case.
Any ideas? Anyone /successfully /doing this sort of thing?
Is there an existing library for this that I'm overlooking? It seems
really bizarre that for all the time and energy invested in servlet and
JSP based HTML page generation that there's not a standard bridge to
using servlets and JSPs from other threads to generate HTML files,
e-mails, etc.
--
Jess Holle
Jess, someone a while back was trying something similar, and I dont think
they came right...
Part of the reason is that even though TC makes is look simple, its one hell
of an engine... like for example the buffering and things like chunking,
where its not actually happening in one conversation...
I think you going to find it much easier just making a dummy http client...
Url Connection or something like that.
If it was just JSP's and one was trying to generate html, I would guess that
tying straight into Jasper with a dummy engine may work...
I would also just google for MIME and things like JavaMail... in the hope
you stumble onto engines/tricks others are using...
good luck
---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]