Phil Swenson wrote:
>
> What is the best method for calling another JSP from a JSP?  I don't want to
> redirect and I don't care about the output.
>
> The following works, but I thought there might be a simpler method:
>
>         URL url = new URL("http://blah.com/cp/blah.jsp?parm=" + param);
>         URLConnection connection = url.openConnection();
>         BufferedReader read = new BufferedReader(new
> InputStreamReader(url.openStream()));
>         read.close();

If you want the calling JSP to continue processing the request after calling
the other JSP, you can use <jsp:include>. If you don't want to continue
processing after the call, you can use <jsp:forward> (assuming the calling
JSP doesn't write anything to the response, explicitly or by just containing
template text).

But if you don't care about the output from the called JSP, maybe you should
consider if the functionality implemented by the called JSP would be better
implemented as a bean or a custom action. I know there are different opinions,
but I prefer to use JSP pages for presentation only (and possibly as face-less
request processing "front components" in fairly simple applications), and
other types of components for everything else (servlets, JavaBeans, utility
classes, EJBs, etc.).

Hans
--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to