On Thu, 17 Jun 1999, Java List wrote:

> I've written two static methods for handeling errors in my Servlets.
> The return value is a PrintWriter object which contains the errors
> formattted in an HTML page.  One of the methods takes a single
> (String) error as it's arguement, and the other takes multiple
> errors (Vector) as its arguement.  When I try to print this returned
> PrintWriter object in my Servlet, I'm getting a hash code rather
> than a String - ( i.e.  java.io.PrintWriter@b44b5d6f)
>
> Any Suggestions???

I think you're misunderstanding what a PrintWriter is.  It's an object
you write things to, not an object used to create a string, which
seems to be the way you're using it.  All those writer.println
statements should be generating output on stdout (are they?).  Anyway,
sounds like you want to use a StringBuffer.


> -Nash
>
>
> Here's one of the  error handeling method:
> ---------
>         public static String getMultipleErrorsAsString(Vector error)  {
>
>                 PrintWriter writer = new PrintWriter(System.out);
>                 Header errorHead = new Header("Error");
>                 Body errorBody = new Body("#FFFFFF");
>                 writer.println(errorHead.printBasicHeader());
>                 writer.println(errorBody.printBasicBody());
>                 for (Enumeration e = error.elements(); e.hasMoreElements();)  {
>                         writer.println(e.nextElement().toString());
>                 }
>                 writer.println("</body></html>");
>
>                 return writer.toString();  //  <-- Why does this return a hash code
> rather than a String?
>         }
> ---------
>
>
>
> And the line of code that calls the method from the Servlet:
> ------------
> out.print(Global.getMultipleErrorsAsString(global.SQLerrors));
> ------------
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

Milt Epstein
Research Programmer
Software/Systems Development Group
Computing and Communications Services Office (CCSO)
University of Illinois at Urbana-Champaign (UIUC)
[EMAIL PROTECTED]

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to