You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Sasha Haghani <ha...@interlog.com> on 2001/04/23 21:52:16 UTC

[General JSP] Invoking a JSP from an external Java class

Hi, I have a general JSP question about how I might call/invoke a JSP from
another Java class (which is not itself a Servlet) using the Servlet/JSP
container.

For instance, I'd like to use a JSP to automatically generate the body of an
e-mail message on a scheduled basis.  In this situation, there wouldn't be
corresponding Request or Session objects.

Are there any methods that can be called on the Servlet/JSP container which
would (a) trigger the compilation of the JSP page into a servlet (if needed)
(b) return the response stream of the JSP (i.e.: service method).

Alternatively, is there anyway to use the getRequestDispatcher or
getNamedDispatcher methods to get a handle to a JSP.

While, I'd like to use a standard container-neutral facility for doing this,
I'd also like to hear about container-specific alternatives which might only
work on Tomcat, BEA WebLogic, etc.

Any help is much appreciated.


Regards,

Sasha Haghani,
Toronto, Canada.

P.S.: I realize that I could invoke the JSP by masquerading as a web browser
and sending a request to the container using a URLConnection object, but I'd
like a more direct and performant solution, if possible.