The signature for concat is:

String concat(String str)

Therefore,
> // this line has no effects?????why??
> //content has been initialized in the constructor as:
> //content = new String(":");
>
>            content.concat(new String("~~~~~~~\n"));

would require you to do:

content = content.concat(new String("~~~~~~\n"));

Conversly, you can also do this as well:

content += "~~~~~~\n";

Or.. use a StringBuffer.  It's much more efficient (it doesn't create new
String objects every time a string is concatenated).  Use it's
.append(String str) method.



                                                        Erik Sahl
                                                        [EMAIL PROTECTED]
> Hi,
>
> I meet a problem in the servlets. I don't know why the
> concat()method has no
> effects.
> No error , no results. Just Like a blank line.
>
> public void doGet (HttpServletRequest request,
>                            HttpServletResponse response)
>         throws ServletException, IOException
>         {
>            String ipaddress = new String(request.getRemoteAddr());
>            if (!ipname.containsKey(ipaddress))
>            {
>
> ipname.put(request.getRemoteAddr(),request.getParameter("name"));
>            iprequest.put(request.getRemoteAddr(),request);
>            ipresponse.put(request.getRemoteAddr(),response);
>            }
>
> // this line has no effects?????why??
> //content has been initialized in the constructor as:
> //content = new String(":");
>
>            content.concat(new String("~~~~~~~\n"));
>
>             response.setContentType("text/html");
>
>
>             PrintWriter out = response.getWriter();
>             out.println("<html>");
>             out.println("<body>");
>             out.println("<FORM
> action=\"http://155.69.22.31:8080/chat/chat\"
> method=\"post\">");
>             out.println("<P>");
>             out.println("<LABEL for=\"We are talking!\">We are talking!:
> </LABEL><BR>");
>             out.println("<TEXTAREA name=\"history\" rows=\"12\"
> cols=\"50\">");
>             out.println(content);
>             out.println("</TEXTAREA><BR>");
>             out.println("<LABEL for=\"I am speaking!\">I am speaking!:
> </LABEL><BR>");
>             out.println("<input type=text size=40 name=message>");
>             out.println("<INPUT type=\"submit\" value=\"Send\"><INPUT
> type=\"reset\">");
>             out.println("</P>");
>             out.println("</FORM>");
>             out.println("</body>");
>             out.println("</html>");
>         }
>
> Thanksvery much!
>
> Yang
>
>

___________________________________________________________________________
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