Hi all,
i start to work on chat utility on my company email application product.
here i populate able to populate chat grid like gmail in my mail application product.
in which two text area , here i able to submit chat text whatever user has entered, right now i am struggling how that current chat text display on upper text area in same jsp page without refreshing whole jsp page....
plzzzz guide before this i never work this kind of chat email application...i m very new about that..
here i can wrote what i understand... here is very urgent requirement fot me on my live project....help me for this urgent development...
i really appreciate ur reply...
here i m submitting data in database using Ajax bt rt now i try to find out how current chat text we able to display to chat user..
chat.jsp
<%String myuserid=request.getParameter("myid");%>
<div id="chatmessagediv" class="mailbluetextb" style="width:100%; height=150;background-color:#FFFFF;">
</div>
<html>
<body>
<table border="1">
<tr>
<td>
<textarea name="chattextmessage" id="chattextmessage" row=5 cols=50></textarea>
</td>
</tr>
<tr class="mailbluetextb">
<td><textarea name="txtmessage" id="txtmessage" rows=5 cols=50></textarea></td>
</tr>
<tr>
<td><A HREF="#" onclick="javascript:sendmessage1();" onmouseover="document.send_but.src='../images/ico_send_on.gif'" onmouseout="document.send_but.src='../images/ico_send_off.gif'"><IMG src="../images/ico_send_off.gif" BORDER="0"
ALT="Send" NAME="send_but" align="absbottom"></A></td>
</tr>
</table>
</body>
</html>
java script file
function sendmessage1()
{
alert("sendmessage1....functiion called");
var message=document.getElementById("txtmessage").value;
xmlHttp5=GetXmlHttpObject();
alert('chat message......'+message);
alert('chatid...'+id1);
alert("xmlHttp5..."+xmlHttp5);
//var url = "savechatmessage.jsp";
//var url="savechatmessage.jsp?myid=+id1&emailmessag1="+message;
//var url ="savechatmessage.jsp?emailmessag1=+message&myid="+id1;
var url="savechatmessage.jsp?emailmessag1="+message+"&myid="+id1;
var params = "email="+id1+"&emailmessage1="+message;
alert('url...'+url);
alert('params...'+params);
xmlHttp5.open("POST",url,true);
xmlHttp5.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp5.setRequestHeader("Content-length", params.length);
xmlHttp5.setRequestHeader("Connection", "close");
xmlHttp5.onreadystatechange = stateChangedValue;
xmlHttp5.send(params);
}
function stateChangedValue()
{
alert('stateChangeValue function called...');
if(xmlHttp5.readyState == 4 && xmlHttp5.status == 200)
{
//alert(xmlHttp5.responseText);
xmlDoc=xmlHttp5.responseXML;
alert('xmDoc...'+xmlDoc);
document.getElementById("chatmessagediv").innerHTML +=""+name11+":"+" "+xmlDoc.getElementsByTagName("text")[0].childNodes[0].nodeValue;
alert(document.getElementById("chatmessagediv").innerHTML +=""+name11+":"+" "+xmlDoc.getElementsByTagName("text")[0].childNodes[0].nodeValue);
document.getElementById("txtmessage").value="";
alert(document.getElementById("txtmessage").value="");
}
if(xmlHttp5.readyState == 4 && xmlHttp5.status != 200)
alert("connected failed");
}
savechatmessage.jsp
<%@ include file="../../database/dbinit.jsp"%>
<%
String strUpdate = "";
String chat_id = request.getParameter("myid");
String chat_text = request.getParameter("emailmessag1");
System.out.println("chat_id...."+chat_id);
System.out.println("chat_text..."+chat_text);
strUpdate="insert into lookup(chat_id,chat_text) values('" + chat_id + "','" + chat_text + "')";
out.println(strUpdate);
System.out.println("strUpdate....."+strUpdate);
dbBean.setQuery(strUpdate);
System.out.println("insert query is set");
dbBean.execute();
System.out.println("statement is successfully execute");
out.println("statement is excecute...");
%>
<%@ include file="../../database/dbClose.jsp"%>
here i am including all required soucre code files....
again thnks in advance