Hey!

If you mean something like this:
public class myClass extends HttpServlet
{

     // Create a PrintWriter to write the response
     java.io.PrintWriter out = new java.io.PrintWriter(resp.getOutputStream());
     // Set the content type of the response
     resp.setContentType("text/html");

     // Print the HTML header
     out.println("<html>");
     out.println("<head>");
     ...
     ...
  public void doGet(HttpServletRequest req,
                    HttpServletResponse resp)
    throws ServletException, java.io.IOException
    {
     String  myVariable = "This is the string";
     ...
     ...
      myMethod(myVariable, out);     //pass a reference of object
     ...
     ...
      // Wrap up
      out.println("</html>");
      out.flush();
      out.close();
     }

     myMethod(java.lang.String theVar, java.io.PrintWriter out) {
          out.println(theVar);
     }
}

I have found that this works for me.

I am confused by your statement, "I use this vector to hold the results of my database 
query and pass the records to my applet.

The question I would ask is are you displaying Vector contents in the applet or are 
you displaying in the HTML document?

If you are using an applet, why not just get a JDBC connection to the database, fill 
up your Vector and have at it.  Why are you using a servlet?

Danny Rubis




Karl Doane wrote:

> Hi,
>      I am using JSDK2.0 and JDK 1.8 and I have a quick question about thread safety. 
> I have read that the dopost and doget method are thread safe since each thread has a 
>copy of its own.  My question is, if I create a local variable (a vector) to that 
>method and then pass that variable off to another method which will write it to an 
>output stream, can I safely use that variable in this method??  I use this vector to 
>hold the results of my database query and pass the records to my applet.
>
> I have read some books on Threads and Servlets but they really are not that clear 
>about passing variables and whether or not you need to Syncronize them.  I also could 
>have missed this quite easily.
>
> Thanks
> Karl
>
> ___________________________________________________________________________
> 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

___________________________________________________________________________
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