').text(message.body);
+ var messageTime = $('').text(message.sent);
+ messageContent.append($('
'), messageTime);
+ messageBox.append(messageContent);
+
+ chatContainer.append(messageBox);
+ });
+ },
+ error: function(error) {
+ // handle error response
+ }
+ });
+
+ });
+});
+
+$(document).ready(function() {
+ var input = $('.chatbox-input input');
+
+ input.on('keydown', function (e) {
+ if (e.key == 'Enter') {
+ e.preventDefault();
+
+ var message = input.val().trim(); // get the message from the input field
+
+ if (message === "") {
+ return; // if no message was typed and 'Enter' is pressed, do nothing
+ }
+ var date = new Date();
+ var hours = date.getHours();
+ var minutes = date.getMinutes();
+
+// Pad with '0' to make sure we always get 2 digits
+ hours = (hours < 10) ? "0" + hours : hours;
+ minutes = (minutes < 10) ? "0" + minutes : minutes;
+
+ var time = hours + ":" + minutes; // current time in "HH:MM" format
+ // append the message to the chat container
+ var msgHtml = ' ';
+ $('.chat-container').append(msgHtml);
+
+ // clear the input field
+ input.val('');
+
+ // make a POST request to your servlet
+ $.ajax({
+ url: '../GetMessages',
+ type: 'POST',
+ data: {
+ // change with actual sender ID
+ recipient: contact_id,
+ body: message
+ },
+ success: function (response) {
+ }
+ });
+ }
+ });
+});
\ No newline at end of file
diff --git a/src/main/webapp/JSP/login.jsp b/src/main/webapp/JSP/login.jsp
index c181632..8e78cfb 100644
--- a/src/main/webapp/JSP/login.jsp
+++ b/src/main/webapp/JSP/login.jsp
@@ -73,7 +73,7 @@