Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 89566 invoked by uid 500); 2 Dec 2002 15:29:27 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 89547 invoked from network); 2 Dec 2002 15:29:26 -0000 content-class: urn:content-classes:message Subject: Transform JSP 2 XSP MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Mon, 2 Dec 2002 16:29:56 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.0.6344.0 Message-ID: <3671ACD9D9D5C648A6181F8048DC9A5D7C6C2C@srvde016.weidmueller.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Transform JSP 2 XSP Thread-Index: AcKaF6sfsKcCN2+bRgqMuUkQBPZfug== From: "Scherler, Thorsten" To: "Cocoon-Dev (E-Mail)" X-OriginalArrivalTime: 02 Dec 2002 15:29:56.0617 (UTC) FILETIME=[AB26D790:01C29A17] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Hello group, I would like to transform a jsp to XSP. Here is the jsp: import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class SendMail extends HttpServlet { private String smtpHost; // Initialize the servlet with the hostname of the SMTP server // we'll be using the send the messages public void init(ServletConfig config) throws ServletException { super.init(config); smtpHost =3D config.getInitParameter("smtpHost"); smtpHost =3D "sbm5501"; } public void doPost( HttpServletRequest request, HttpServletResponse response ) throws ServletException, java.io.IOException { String from =3D request.getParameter("from"); String to =3D request.getParameter("to"); String cc =3D request.getParameter("cc"); String bcc =3D request.getParameter("bcc"); String smtp =3D request.getParameter("smtphost"); String subject =3D request.getParameter("subject"); String filename =3D request.getParameter("attach"); String text =3D request.getParameter("body"); PrintWriter writer =3D response.getWriter(); if (subject =3D=3D null) subject =3D "Null"; if (text =3D=3D null) text =3D "No message"; text =3D text + "\n\n Message is processed by Mahesh More by Java SMTP Client"; String status; try { // Create the JavaMail session java.util.Properties properties =3D System.getProperties (); if (smtp =3D=3D null) smtp =3D "sbm5501"; properties.put("mail.smtp.host", smtp); Session session =3D Session.getInstance(properties, null); // Construct the message MimeMessage message =3D new MimeMessage(session); // Set the from address Address fromAddress =3D new InternetAddress(from); message.setFrom(fromAddress); // Parse and set the recipient addresses Address[] toAddresses =3D InternetAddress.parse(to); message.setRecipients (Message.RecipientType.TO,toAddresses); Address[] ccAddresses =3D InternetAddress.parse(cc); message.setRecipients (Message.RecipientType.CC,ccAddresses); Address[] bccAddresses =3D InternetAddress.parse(bcc); message.setRecipients (Message.RecipientType.BCC,bccAddresses); // Set the subject and text message.setSubject(subject); /** message.setText(text); Transport.send(message); // Attach file with message writer.println("

file passed =3D "+filename); File file =3D new File(filename); if (file.exists()) { // create and fill the first message part MimeBodyPart mbp1 =3D new MimeBodyPart(); mbp1.setText(text); // create the second message part MimeBodyPart mbp2 =3D new MimeBodyPart(); // attach the file to the message FileDataSource fds =3D new FileDataSource(filename); mbp2.setDataHandler(new DataHandler(fds)); mbp2.setFileName(fds.getName()); // create the Multipart and its parts to it Multipart mp =3D new MimeMultipart(); mp.addBodyPart(mbp1); mp.addBodyPart(mbp2); // add the Multipart to the message message.setContent(mp); } else { message.setText(text); } // send the message Transport.send(message); status =3D "

Congratulations,

Your message was sent.

"; } catch (AddressException e) { status =3D "There was an error parsing the addresses. " + e; } catch (SendFailedException e) { status =3D "

Sorry,

There was an error sending the message.

" + e; } catch (MessagingException e) { status =3D "There was an unexpected error. " + e; } // Output a status message response.setContentType("text/html"); writer.println("Status"); writer.println("

" + status + "

"); writer.close(); } } > Mit freundlichem Gruss, >=20 > Thorsten Scherler > Marketing / Telefonmarketing >=20 > Weidm=FCller GmbH & Co. > P.O. Box 2807 > 33058 Paderborn > Tel.:+ 49 - 5252-960-350 > Fax:+ 49 - 5252-960-116 > eMail: thorsten.scherler@weidmueller.de>=20 > http://www.weidmueller.de >=20 >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org