Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The purpose of this project is to implement socket and multithreading programmin

ID: 3630438 • Letter: T

Question

The purpose of this project is to implement socket and multithreading programming using java. You need to write java program for: Server: The server receives requests from clients and creates a thread for any request from any client. The server should send a list of all client names who has an account in this mail server to any client who wants to see these names and choose among them to send a message. The server should save any sent message in a text file with any format you need to distinguish between multiple clients. The server should send a list of messages that was sent to any client when he requests it with distinguishing between read and unread messages. The server can respond to any client to delete any received message. Client: Client can log into his account after requesting it from the server by entering username and password. Client can ask the server for a list of names of people who have an account. Client can send and receive messages to/from any use

Explanation / Answer

Dear..
 import java.io.IOException;
import java.io.PrintWriter;
import java.util.Properties;
Dear..
 public class mail extends HttpServlet 
{
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
PrintWriter writer = response.getWriter();
response.setContentType("text/html");
writer.println("<html><head><title>Mail Example</title></head>");
writer.println("<body bgcolor="white">");
writer.println("<h1>Mail Example</h1>");
String mailHost = "your.smtp.server";
String to =
String from = ;request.getParameter("from");
String subject = request.getParameter("subject");
String body = request.getParameter("body");
if ((from != null) && (to != null) && (subject != null) && (body != null))
{
try
{
 Properties props = System.getProperties();
props.put("mail.smtp.host", mailHost);
Session session = Session.getInstance(props,null);
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.setRecipients(Message.RecipientType.TO, new InternetAddress[]
{
new InternetAddress(to)
});
message.setSubject(subject);
message.setContent(body, "text/plain");
Transport.send(message);
writer.println
("<b>Thank you. Your message to " + to + " was successfully sent.</b>");
} catch (Throwable t)
{
writer.println("<b>Unable to send message: <br><pre>");
t.printStackTrace(writer);
writer.println("</pre></b>");
}
}
else
{
writer.println("<form action="/mine/mail" method="POST">");
writer.println("<table border="0">");
writer.println("<tr><td>Message From: </td><td><input type="text" name="from"></td></tr>");
writer.println("<tr><td>Subject: </td><td><input type="text" name="subject"></td></tr>");
writer.println("<tr><td valign="top">Message: </td><td><textarea name="body" rows="10" cols"40"></textarea></td></tr>");
writer.println("<tr><td colspan="2" align="center"><input type="submit" value="Send"></td></tr>");
writer.println("</table>");
writer.println("</form>");
}
writer.println("</body>");
writer.println("</html>");
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
doPost(request, response);
}
}
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote