The book I have must be dated.  All the examples fail to do this.  But then I seem to 
remember reading something about the server being responsible for closing the output 
stream.  Was this ever true? And if it was, did it change?  I did noticed all the 
examples from the Sun tutorial close the stream.  Either way, it's noted and my code 
is better for it.  Thanks.

Craig A. Ritchie

On Sun, 05 December 1999, Dennis Lundberg wrote:

> 
> Hi there
> 
> You forgot to close the output stream in your servlet. See my comment below.
> 
> At 21:08 1999-12-04 -0500, you wrote:
> >I get no output from my servlet when using the <SERVLET> tag in a .jhtml
> >file.  I've installed the ApacheJSSI.jar following the instructions.  My
> >servlet is as simple as it can get:
> >
> >import java.io.*;
> >import java.text.*;
> >import java.util.*;
> >import javax.servlet.*;
> >import javax.servlet.http.*;
> >
> >public class CurrentTime extends HttpServlet
> >{
> > public void doGet(HttpServletRequest req, HttpServletResponse res)
> >  throws ServletException, IOException
> > {
> >  res.setContentType("text/html");
> >  PrintWriter out = res.getWriter();
> >
> >  Date date = new Date();
> >  DateFormat df = DateFormat.getInstance();
> >
> >  String zone = req.getParameter("zone");
> >  if (zone != null)
> >  {
> >   TimeZone tz = TimeZone.getTimeZone(zone);
> >   df.setTimeZone(tz);
> >  }
> >
> >  out.println(df.format(date));
> 
> // Dennis comment: you need to close the outputstream here!
>    out.close();
> 
> > }
> >
> >The .jhtml is pretty simple also:
> >
> ><html>
> > <head>
> >
> > <!-- header - edit "Data/yourHtmlHeader" to customize -->
> > <!-- contents - edit "EventHandlers/Html file/onCreate" to customize -->
> > <meta name="generator" content="ModelWorks IDE">
> >
> > <title>Times!</title>
> >
> > </head>
> > <body>
> >  The current time here is:
> >  <SERVLET CODE=../servlets/CurrentTime.class>
> >  Not supported
> >  </SERVLET>
> >  <P>
> >  The current time in London is:
> >  <SERVLET CODE=../servlets/CurrentTime.class>
> >   <PARAM NAME=zone VALUE=GMT>
> >  Not supported
> >  </SERVLET>
> >  <P>
> >  The current time in New York is:
> >  <SERVLET CODE=../servlets/CurrentTime.class>
> >   <PARAM NAME=zone VALUE=EST>
> >  Not supported
> >  </SERVLET>
> >  <P>
> > </body>
> ></html>
> >
> >I feel the servlet is being called because none of the "Not Supported" show
> >up in the resulting .html.  I feel I'm missing something simple.  Can
> >anybody give me a clue.
> >
> >Craig A. Ritchie
> >
> >
> >
> >
> >
> >------------------------------------------------------------
> >To subscribe:    [EMAIL PROTECTED]
> >To unsubscribe:  [EMAIL PROTECTED]
> >Problems?:       [EMAIL PROTECTED]
> >
> >
> >
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> Dennis Lundberg, Utvecklingsledare, IT-avdelningen
> e-post: [EMAIL PROTECTED]
> http://www.mdh.se/servlet/VisaPerson?fornamn=Dennis&efternamn=Lundberg
> tel: +46-(0)21-101516, fax: +46-(0)21-101544
> Mälardalens högskola, Box 883, S-72123 Västerås, SWEDEN
> 
> 
> ------------------------------------------------------------
> To subscribe:    [EMAIL PROTECTED]
> To unsubscribe:  [EMAIL PROTECTED]
> Problems?:       [EMAIL PROTECTED]




------------------------------------------------------------
To subscribe:    [EMAIL PROTECTED]
To unsubscribe:  [EMAIL PROTECTED]
Problems?:       [EMAIL PROTECTED]

Reply via email to