Hi there, I am working with JSP with JMail in order to upload a file. I have
pasted the source and error that I am working with as below. However, I
couldn't find where is the NULLPOINTEREXCEPTION occured. Please help..
Thank you in Advance.
Best Regards
Anders
=======================================================================
<html>
<head><title>Sending a stationary request</title></head>
<body>
<p align="center"><b>Stationary Notification Request.</b></p>
<form enctype="multipart/form-data" method=post action="./testmail.jsp">
<table align="center">
<tr><td>TO:</td><td><input name="to" size="50" /></td></tr>
<tr><td>FROM:</td><td><input name="from" size="50" /></td></tr>
<tr><td>CC:</td><td><input name="cc" size="50" /></td></tr>
<tr><td>BCC:</td><td><input name="bcc" size="50" /></td></tr>
<tr><td>FILE:</d><td><input type="file" name="getfile"></td></tr>
<tr>
<td>Subject</td>
<td><input name="subject" size="35" value=""</td>
</tr>
<tr><td colspan="2"><textarea name="text" cols="50"
rows="20"></textarea></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="Send
Email"/></td></tr>
</table>
</form>
</body>
</html>
========================================================================
<%@ page import="java.util.*, javax.mail.*,
javax.mail.internet.*,javax.activation.*" errorPage = "errordetails.jsp" %>
<%
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.pacific.net.hk");
Session s = Session.getInstance(props,null);
MimeMessage message = new MimeMessage(s);
String getfrom = request.getParameter("from");
String toAddresses = request.getParameter("to");
String ccAddresses = request.getParameter("cc");
String bccAddresses = request.getParameter("bcc");
String filename = request.getParameter("getfile");
String subject = request.getParameter("subject");
String text = request.getParameter("text");
message.setFrom(new InternetAddress(getfrom));
InternetAddress[] address = {new InternetAddress(toAddresses)};
message.setRecipients(Message.RecipientType.TO, address);
message.setSubject(subject);
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(text);
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
message.setContent(mp);
message.setSentDate(new Date());
Transport.send(message);
%>
<html>
<p align="center">The Message has been sent.<br></p>
<p align="center"><a href="mailrequest.jsp">Click here to send
another!</a></p>
</html>
===================================================================
======================Error Page Log=================
Our Error Page
We got ourselves an exception:
java.lang.NullPointerException:
Application Attributes
javax.servlet.context.tempdir /opt/tomcat/work/localhost_8080%2Fanders
sun.servlet.workdir /opt/tomcat/work/localhost_8080%2Fanders
Request Attributes
javax.servlet.jsp.jspException java.lang.NullPointerException:
Parameters