0

Hello!
We want to send an email from a jsp to the Recipient (variable: youradress) from the emailadress given in our profile (variable: myadress).

There appears a error message at the command Transport.send(message).

<%@ page language="java"
import="java.util.*, javax.mail.*, javax.mail.internet.*"
%>
<%@ page language="java" import="model.User" %>
<%
model.User user = db.DBMUser.getUserById(session.getAttribute("user").toString());
String mymail = user.getEmail();
String mailadresse = request.getParameter("mailadresse");
String nachricht = request.getParameter("nachricht");

InternetAddress myadress = new InternetAddress(mymail);
InternetAddress youradress = new InternetAddress(mailadresse);

try{
   Properties prop=new Properties();
   prop.put("mail.smtp.host","mail.gmx.net");
   Session s = Session.getDefaultInstance(prop);
   //MimeMessage message = new MimeMessage(s);
Message message = new MimeMessage(s);

   message.setFrom(myadress);
   message.addRecipient(Message.RecipientType.TO,youradress);
   message.setSubject("Einladung");
   message.setText(nachricht);
   message.setContent(message, "text/plain");
   Transport.send(message);

   out.println("Ihre E-Mail wurde erfolgreich versandt.");
}
catch(MessagingException msgexcep) {
   out.println(msgexcep.getMessage());
}
%>

error message in the browser:
org.apache.jasper.JasperException: An exception occurred processing JSP page /send.jsp at line 34


31: message.addRecipient(Message.RecipientType.TO,youradress);
32: message.setSubject("Einladung zur Heimwehplattform");
33: message.setText(nachricht);
34: Transport.send(message);
35:
36: out.println("Ihre E-Mail wurde erfolgreich versandt.");
37: }

4
Contributors
8
Replies
10
Views
9 Years
Discussion Span
Last Post by peter_budo
0

Look at the web applications logs for a stacktrace and a better exception message.

You should not be using scriptlets, however. Write a Bean.

0

Look at the web applications logs for a stacktrace and a better exception message.

You should not be using scriptlets, however. Write a Bean.

Here the stacktrace:

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

0

That is not everything, try again.

oh sorry i forgot the rest

root cause

javax.servlet.ServletException: javax.mail.internet.AddressException: Illegal address in string ``''
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.send_jsp._jspService(send_jsp.java:104)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

javax.mail.internet.AddressException: Illegal address in string ``''
javax.mail.internet.InternetAddress.<init>(InternetAddress.java:108)
org.apache.jsp.send_jsp._jspService(send_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


i also looked in the apache/logs directory, but i couldnt find a log-file from that day

0

ok. i have tested the example today. and the error message changed.. but now i dont understand whats wrong

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

javax.servlet.ServletException: java.lang.NoClassDefFoundError: javax/net/ssl/SSLSocket
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.send_jsp._jspService(send_jsp.java:105)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.lang.NoClassDefFoundError: javax/net/ssl/SSLSocket
com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:324)
com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:201)
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1359)
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
javax.mail.Service.connect(Service.java:288)
javax.mail.Service.connect(Service.java:169)
javax.mail.Service.connect(Service.java:118)
javax.mail.Transport.send0(Transport.java:188)
javax.mail.Transport.send(Transport.java:118)
org.apache.jsp.send_jsp._jspService(send_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

0

says it all, that class isn't there.
Now, don't ask me where it is, but it's not where it's supposed to be.

0

I'm getting little rusty on web development with Java, however error is clear class not found. Are you sure you set SSL properly? Here is how to for Tomcat 6 (same can be found for lower versions)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.