Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

chat servlet

  Asked By: Jimmy    Date: Sep 08    Category: Java    Views: 1455
  

i am developing beginers level chat room servlet. i have done all
the session tracking part and sending part of it.
i can make users to connect to same session . but i am having probe
in the reciving part and the format in which msg can be recived.

for example if user A send msg to user b the user B can not see the
msg until he /she post a msg to user A. I mean session isnt
refreshing it self when msg are send .

and secondly he or she can see only last msg rather then entire
conversational.

if any one can lead me to source where i can find example of
beginers level that would be great full. or suggestion about the
correction in existing code.i am pasting a source of mine i havent
formatted the HTML yet ..

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

public class Servlet1 extends HttpServlet {


String oipt;
//Initialize global variables
public void init(ServletConfig config) throws ServletException {
super.init(config);
}

//Process the HTTP Post request
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");



HttpSession se=request.getSession(true);
Integer c=(Integer)se.getValue("c");

c= new Integer(1521);
se.putValue("c",c);
String ipt =request.getParameter("a");
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>");
out.println(oipt);
out.println(ipt);
oipt=ipt ;
out.println("<input type=text name=a>");
out.print("<input type=submit value=Submit><input type=reset
value=Reset></form>");
out.println("</body></html>");
out.close();
}

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

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Mark R     Answered On: Sep 08

You can get the page refreshed automatically.
and you can save all the message in server side, when
the page asked for refresh, send  them back.

 
Didn't find what you were looking for? Find more on chat servlet Or get search suggestion and latest updates.




Tagged: