Ian Corner wrote:
>
> Hi
> how do you implement a carriage return when using JSP to construct the body
> of an email?
>
> For example, I want the email to look like this:
> Make: Ford
> Model: Mustang
> Movie: Bullet
>
> Instead when the form submitting this data is processed and the email
> constructed I get this:
> Make: FordModel: MustangMovie: Bullet
It depends on what you mean with "when using JSP to construct the body".
If you mean that you write the text in the body of a JSP custom action
element, the JSP container is required to preserve linefeed characters.
<xxx:sendMail to="[EMAIL PROTECTED]">
first line
second line
third line
</xxx:sendMail>
As long as your tag handler doesn't remove the linefeed characters,
everything should work fine.
If you mean that you construct the body with code in a bean or
tag handler, just make sure you use println() (or other standard
Java methods for adding linefeed characters.
A couple of possible issues:
* If the MIME header for the mail defines the content to be of type
text/html, and the mail reader is capable of rendering HTML,
linefeed characters will be ignored by the mail reader. Make sure
you use a text/plain as the MIME type for the mail.
* Linefeed is represented differently on different platforms (just
one "newline" character on Unix, "newline" + "carriage return"
on Windows). Mail readers usually handles this fine though.
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets