> I am wondering, is it ALWAYS guaranteed that if you specify
> contentType="text/xml" in a JSP page, it will return XML? Does this work
> with all servlet engines? Or is this a feature that each vendor must
> implement for it to work?

setContentType is just a promise to the client that the content is of that
type. In IE if you set the content type to "text/xml" it will process the
XML or will display an error page if the data is not well-formed XML. It's
up to you (the page developer) to make sure the content type and the content
match.

> I don't mean from a web browser. I mean in code..is it something like:
>
> URL url = new URL("http://www.xxx.com/path/page.jsp");
> FileInputStream fis = new FileInputStream(url.openStream());

This will work but you may want to use the HttpURLConnection, something like
this -

//////////////////////// CODE /////////////////////

java.net.URL url = new java.net.URL(urlString);
java.net.HttpURLConnection con =
(java.net.HttpURLConnection)url.openConnection();
con.setRequestMethod(strMethod);

con.connect();

java.io.InputStreamReader ins = new
java.io.InputStreamReader(con.getInputStream());
java.io.BufferedReader bufReader = new java.io.BufferedReader(ins);
String strOutput = null;

do
{
        strOutput = bufReader.readLine();
        if (strOutput != null)
                System.out.println(strOutput);
}while (strOutput != null);

//////////////////////// CODE /////////////////////

HttpURLConnection 'understands' HTTP, but be aware it has certain
limitations.

> Or is there some other way to actually invoke a resource from a
> web site, in
> code, so as to get the web server to do whatever it does to produce the
> output (in this case, the above "should" invoke the JSP page much like a
> browser would..and get the HTML output, not the actual text that comprises
> the JSP page).
>
> If it is not supported by all servlet engines, then is there some standard
> way, tool, app, etc that can handle this?

There won't be a standard way apart from going through HTTP.

BTW have you checked out Cocoon? (http://xml.apache.org/cocoon). This is a
servlet engine that will process XML and XSLT, it's worth looking at just to
get some ideas,

Kevin Jones
DevelopMentor
www.develop.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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