Hi all,

I am really confused now about this messages. I think somebody (not me)
should clarify this problem .
I think Chris is right.
Here is a servlet example:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class ProbaServlet extends HttpServlet



     public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException

      {
        PrintWriter toClient=null;
          try{

         res.setContentType("text/html");
         toClient=res.getWriter();
         printHtml(toClient);

       } catch(Exception e)  { toClient.println("Error:"+e);}


       toClient.close();
      }
      private void printHtml(PrintWriter client){

      client.println("<html>");
      client.println("<head></head>");
      client.println("<body bgcolor=\"#FFFFFF\">");
      client.println("How is that this is works");
      client.println("</body>");
      client.println("</html>");
     }
 }//end servlet


Now if the PrintWriter object toClient is not the same as the
PrintWriter object client than it means that everything written in
the client object will NOT go to browser back.
But it DOES.

So what about somebody Finalizing this problem?




----- Original Message -----
From: Chris Pratt <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 13, 1999 9:46 AM
Subject: Re: will this code work?


> Wrong, Wrong, Wrong.  Your example is correct, but that's because you're
> changing the value of the reference, not the value of the String (remember
> String's are immutable).  Java uses Pass by Reference for Objects and Pass
> by Value for intrinsic types (int, float, char, etc).  This has been a
major
> source of confusion with the Java detractors saying that the entire
contents
> of each Object must be copied to the stack since Java is "pointerless".
If
> you don't believe me, try this program.  I bet you get "i = 10"
>     (*Chris*)
>
> class Obj {
>   int i;
>
>   public Obj (int i) {
>     this.i = i;
>   }
>
>   public int add (int j) {
>     i += j;
>     return i;
>   }
>
>   public String toString () {
>     return String.valueOf(i);
>   }
>
> }
>
> public class test {
>
>   public static void process_me(Obj o) {
>     o.add(5);
>   }
>
>   public static void main(String[] args) {
>     Obj obj = new Obj(5);
>     obj.add(5);
>     System.out.println("obj = " + obj);
>   }
>
> }

___________________________________________________________________________
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