-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendMessage.jsp
107 lines (98 loc) · 3.86 KB
/
sendMessage.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<%@ page isErrorPage="false" errorPage="error.jsp" import="java.util.Set,java.util.Iterator,java.util.Map,sukhwinder.chat.*"%>
<%
String nickname = (String)session.getAttribute("nickname");
if (nickname != null && nickname.length() > 0)
{
ChatRoomList roomList = (ChatRoomList)application.getAttribute("chatroomlist");
ChatRoom chatRoom = roomList.getRoomOfChatter(nickname);
if ( chatRoom != null)
{
String msg = request.getParameter("messagebox");
if ( msg != null && msg.length() > 0)
{
msg = msg.trim();
chatRoom.addMessage(new Message(nickname, msg, new java.util.Date().getTime()));
}
%>
<HTML>
<HEAD>
<LINK rel="stylesheet" type="text/css" href="chat.css">
<META http-equiv="pragma" content="no-cache">
<meta name="Author" content="Resm [email protected]">
<SCRIPT language="JavaScript" type="text/javascript">
<!--
function winopen(path)
{
chatterinfo = window.open(path,"chatterwin","scrollbars=no,resizable=yes, width=400, height=300, location=no, toolbar=no, status=no");
chatterinfo.focus();
}
//-->
</SCRIPT>
</HEAD>
<BODY onLoad="document.msg.messagebox.focus();" bgcolor="#FFFFFF">
<TABLE width="100%" cellpadding="3" cellspacing="0">
<TR>
<TD width="50%" align="left" valign="top">
<TABLE>
<TR>
<FORM name="msg" action="sendMessage.jsp" method="post">
<TD width="100%">
<INPUT type="text" name="messagebox" maxlength="300" size="35">
<INPUT type="hidden" name="nickname" value="<%=session.getAttribute("nickname")%>">
<INPUT name="submit" type="submit" value="Send">
</TD>
</FORM>
</TR>
</TABLE>
</TD>
<TD width="50%">
<TABLE border="1" cellpadding="3" cellspacing="0" class="panel">
<TR align="left" valign="top">
<FORM name="changeRoom" method="post" action="listrooms.jsp">
<TD width="15%">
<INPUT type="hidden" name="n" value="<%=nickname%>">
<INPUT name="ChangeRoom" type="submit" id="ChangeRoom" value="Change Room">
</TD>
</FORM>
<FORM name="editinfo" action="editinfo" method="post">
<TD width="20%">
<INPUT type="button" value="Edit Profile" onClick='winopen("editInfo.jsp")'>
</TD>
</FORM>
<FORM name="find">
<TD width="10%">
<INPUT type="button" value="Find" onClick='winopen("find.jsp")'>
</TD>
</FORM>
</TR>
<TR align="left" valign="top">
<FORM name="refresh">
<TD>
<INPUT type="Button" value="Refresh" onClick="top.frames[0].location.reload()">
</TD>
</FORM>
<FORM name="logout" action="logout.jsp" method="post" target="_top">
<TD width="10%">
<INPUT type="Submit" value="Logout">
</TD>
</FORM>
<TD> </TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<%
}
else
{
out.write("<h2 class=\"error\">Your room couldn't be found. You can't send message</h2>");
}
}
else
{
response.sendRedirect("login.jsp");
}
%>