E-Mail is one of the most widely used services on the Internet, the traditional email application mode is based on C/s structure, that is, the user uses the client's Mail transceiver tool (such as Outlook, Foxmail, etc.) and the server that provides the mail service (such as 163.net, 263.net, 371.net) communication, before using the Client Mail tool, users need to make some necessary settings, such as specifying the host address and communication port of the mail server, these jobs will have some difficulties for the users who have just started to surf the internet, if the e-mail and the web are combined, That is, through web programming and appropriate system settings, users can get and use the full mail service just by accessing the web, which is a great convenience for users of the Internet, a system called webmail. Webmail is one of the most popular services on the internet and one of the most essential features of many Web sites. In addition webmail also applies to the application of enterprise or campus network.
Usually after the establishment of the background server and the completion of the implementation of the webmail system, and the development of the front desk is mainly the development of tools and background database and mail server interaction problem. The stability and reliability of the various server software running on the Linux platform has been good, and the choice of Cross-platform Java Development Tools makes the system more stable and scalable.
JSP performance
Although JSP provides a powerful feature built on top of the servlet, the performance of the JSP is comparable to that of the servlet. JSP is first compiled into a servlet, which will only add a small amount of code, only need to compile once and can be precompiled, which eliminates the unnecessary burden of running. The difference between JSP and servlet performance is only reflected in the binary of the returned data. This is because the JSP returns with PrintWriter, and the servlet can be applied to faster outputstream.
JSP custom tag libraries can encapsulate a large number of complex Java operations in a form where predefined tags can be easily invoked by people who do not have Java knowledge. Therefore, the JSP custom label library can effectively achieve the Java Programmer and Web designer work division. However, for each label applied on the page, the Web container must create a new label handle object or extract it from the tag buffer. As a result, excessive application of custom labels will result in unnecessary waste of resources.
Bodytags is a special custom label that can extract or replace content that is encapsulated between it. The content between bodytags is typically backed up in memory. Because of the ability to nest and repeat between Bodytags, the application of multi-level bodytags in a program consumes a significant amount of valuable memory and system resources.
Realize the main function of webmail
This system provides the function of acquiring, reading, writing, forwarding, replying, printing, deleting and user management. Considering the cross-platform nature of the system, the use of Java and related technology products for development tools, especially the use of JSP as a service program, so there is no other requirements on the client, at the same time the performance of the system under the high load has been further improved. The entire webmail system uses pure Java code, which starts a thread each response to a service request instead of starting a process like CGI. This can save system resources and improve system performance.
Implementing the main code
Get information entered by the user
For user input content acquisition function is achieved through the GetParameter method, for the input text content, through the following code can be obtained on the server side, the program code is as follows:
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=550 align=center borderColorLight=black border=1>
<tr> <td class=code bgColor=#e6e6e6>
String username=request.getParameter("login");
String password=request.getParameter("password");
Session session2=Session.getInstance(System.getProperties() ,null);
Store store=session2.getStore("pop3");</td></tr>
</table>
Depending on the information entered by the user to connect to the server, the program code is as follows:
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=550 align=center borderColorLight=black border=1>
<tr> <td class=code bgColor=#e6e6e6>
try{
store.connect(host,username+"%nyist.net", password);
}
catch(javax.mail.AuthenticationFailedException e)
{content="用户名与密码不匹配";}</td></tr>
</table>
Receive Message Code Snippets
To connect to the server based on the information entered by the user, the code is:
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=550 align=center borderColorLight=black border=1>
<tr> <td class=code bgColor=#e6e6e6>
store.connect("nyist.net",-1,request.getParameter("username")+"%nyist.net",request
.getParameter("password"));</td></tr>
</table>
Get the information on the server side, the code is as follows:
<table cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=550 align=center borderColorLight=black border=1>
<tr> <td class=code bgColor=#e6e6e6>
Folder folder = store.getFolder("INBOX");
Folder.open (Folder.READ_WRITE);
Message message[]=folder.getMessages();
FetchProfile fp=new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS);
fp.add("X-Mailer");
folder.fetch(message,fp);</td></tr>
</table>