Claire Ryan wrote:
> what's the method to use for to write to HTTP output, i 've tried using
> response.write(String), but this doesn't work, any ideas?
> thanks in advance
> claire
Grab the JSP cheat-sheet at http://java.sun.com/products/jsp/ which will
tell you about all the implicit objects you may access in your scriptlet
code in JSP pages. One of these is the "out" object, defined to be a
JspWriter which will have all sorts of operations for writing out text,
not that I would encourage this in JSP scriptlet code. If you need
println and printing of non-String stuff, you should wrap that JspWriter
with a PrintWriter, as in:
<% java.io.PrintWriter pw = new java.io.PrintWriter(out);
pw.println("<HTML>...</HTML>");
%>
On the other hand, if you are writing a servlet, you need to examine the
Servlet API specification, available for download at the same URL
above. In there you will see a discussion of the
HttpServletResponse.getOutputStream() method, which again, can be
wrapped with a PrintWriter for text/html output:
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
response.setContentType("text/html; charset=iso8859-1");
PrintWriter pw = new PrintWriter(response.getOutputStream());
pw.println("<HTML>....</HTML>");
. . .
pw.flush();
}
===========================================================================
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