Chapter 6: Advanced Tomcat Features This is the
Chapter 6: Advanced Tomcat Features This is the JSP that will accept user input and submit the e-mail details to the SendMailServletfor sending. Sending E-mail via JavaMail Sessions Start Tomcat 6, and you can test the example that uses JavaMail to send e-mail. Use the following URL: http://localhost:8080/examples/jsp/mail/sendmail.jsp Figure 6-6 shows the JSP-generated form that you can fill out to send e-mail. Figure 6-6: Accessing JavaMail via JNDI You can fill out the form shown in Figure 6-6 to actually send an e-mail message (assuming that you have the SMTP server configured properly). This JSP collects information for an e-mail message from the user, and then submits it to the SendMailServlet for processing and sending. The following code shows how SendMailServlet (or other Web application code) can look up and utilize the JNDI mail session: private final Object lock = new Object(); … // Acquire our JavaMail session object Session session = null; Synchronized(lock) { Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup( java:comp/env ); session=(Session) envCtx.lookup( mail/Session ); } …
If you looking for unlimited one inclusive web hosting plan please check web hosting plan website.