JavaMail, Sun's Sample App and Tomcat 4.x
I recently downloaded Sun’s sample application for JavaMail. As the name implies, JavaMail is Sun’s Java API for interfacing with email systems. Using JavaMail, you can access POP or IMAP accounts, as well as send messages.
Unfortunately, Sun’s sample app does not run on Tomcat 4.x for two reasons: their WEB-INF/web.xml is malformed and their tags are not fully qualifies. Both of these issues were most likely ignored by older versions of Tomcat, but this one picky.
Remember the good-old days when it was ok to define a tag-library before defining a servlet in web.xml? Well, forget those days. Tomcat 4 wants web.xml to adhere tp the following DTD:
So, modify web.xml and places all the servlet tags first, the servlet-mapping tags second and the taglib tag last.
The next problem was harder to figure out. I was getting errors on the JSP pages, telling me that classes used for JavaMail’s custom tags weren’t being found. Basically, the JavaMail taglib JAR had classe files that weren’t in a fully qualified directory (eg. com.sun.javamail.taglib), they were at the root of the JAR. For some reason this kept Jasper from finding them and using them to compile the JSPs. Long story short, modify the following files:
<%@ page import="MessageTag" %><br/>
<%@ page import="MessageInfo" %><br/>
<%@ page import="ListAttachmentsTag" %>
<%@ page import="ListMessagesTag" %><br/>
<%@ page import="MessageInfo" %>
<%@ page import="SendTag" %>
Hope that helps!
Hey there. My name is Carter Rabasa and I am a husband and father of two beautiful daughters Catherine and Emily. I live in Seattle, WA.
- @cubanlinks on Twitter