Hi All


i am using JBuilder 3.0 i am trying to develop a real simple chat 
servlet i have done all the session things....
but now what i want is that every users should have his own 
nick ....and 2nd the page should constantly refresh if new msg from 
other user is posted (i tried to use respose.setRefersh() but wasnt 
available for jdk1.2)

u can go throw my code and tell me for the suggestion and improvment.

Regards


package untitled2;

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

public class Servlet1 extends HttpServlet {
             private HttpSession se;
             private String ck;
             private  String oipt;
             private String nam;
             private String ipt;
             private int a=0;
  //Initialize global variables
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
                 
  }
  public void doPost(HttpServletRequest request, HttpServletResponse 
response) throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = new PrintWriter (response.getOutputStream());
    String s=request.getParameter("a");
    se=request.getSession(true);
    Integer c=(Integer)se.getValue("c");
    c= new Integer(1521);
    se.putValue("c",c);
    ipt  =request.getParameter("a");
   nam=request.getParameter("n");
 /* if(a==0){
  Cookie my=new Cookie("login",nam);
  response.addCookie(my);
           a=1;}
           else
           {
           Cookie[] myc;
           myc=request.getCookies ();
            for(int i=0;i<myc.length;i++)
            {
            out.println(myc[i].getName())             ;
            nam=myc[i].getValue();
           }
           }  */
  out.println("<html>");
    out.println("<head><title>Servlet1</title></head>");
    out.println(se.getValue("c").toString());
    out.println("<body>");
    out.print("<FORM  
action=http://localhost:8080/servlet/untitled2.Servlet1 
method=POST>");


  ck=request.getParameter("b");


  out.println("<TextArea name=b wrap=VIRTUAL rows=25 cols=80>");

               if(ipt!=null || oipt!=null || ck!=null)

             {
             out.println(ck);
             out.println(nam+" Says :" +oipt);
             out.println(nam+" Says :" +ipt);
             }
                 else
                 out.println("Welcome To PrEsToN ChAt....!!!!!");

   out.println("</Textarea>");
                out.println("<br>");
                 out.println("<br>");
                out.println("<br>");
    out.println("<input type=text name=a size=95>");
    out.println("<input type=submit value=SEND>");
      oipt=ipt ;

    out.println("</body></html>");
    out.close();
  }

  //Get Servlet information
  public String getServletInfo() {
    return "untitled2.Servlet1 Information";
  }
}








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~-> 

If you have any comments or questions, submit it on the message board.
NO spam/ads/job posting or you will be BANNED from this group. Exception can be 
made it happen by notify me ahead of time.
all new members' message will be verified by me (spam..) before it get posted. 
Yahoo! Groups Links

<*> To reply to this message, go to:
    http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17663
    Please do not reply to this message via email. More information here:
    http://help.yahoo.com/help/us/groups/messages/messages-23.html

<*> To visit your group on the web, go to:  
    http://groups.yahoo.com/group/java_official/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to