aspose file tools
The moose likes JSP and the fly likes Email character issue Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Email character issue" Watch "Email character issue" New topic
Author

Email character issue

Ed Carrington
Ranch Hand

Joined: Oct 11, 2007
Posts: 77
I am trying to figure out how to escape the & character in my JSP and Java files.

Mailto link not working because it cuts off the mail string after Data:


Java email in Java class:




I also tried double escape slashes and it still not working.
Please advise how I escape or handle the & character.
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Hi Ed,

Since the email address is a part of href of the A tag, you should use URL encoder to encode it. For the email address "Data&Location\@mycompany.com", the actual value should be Data%26Location@mycompany.com



Hope it helps,

Duc


“Everything should be as simple as it is, but not simpler.” Albert Einstein
Ed Carrington
Ranch Hand

Joined: Oct 11, 2007
Posts: 77
Thanks, that worked for my JSP.

The Java class for my email program still is not working.

None of the emails got sent because of the & issue with the first array value.
The email program does work if I eliminate the email with the &.

Here are my attempts:


Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
Ed Carrington wrote:
None of the emails got sent because of the & issue with the first array value.
The email program does work if I eliminate the email with the &.

Here are my attempts:



Can you elaborate this? My previous solution is only used in href of A tag. It has nothing to do with sending an email in Java.
Ed Carrington
Ranch Hand

Joined: Oct 11, 2007
Posts: 77
I am using JavaMail to send the emails out and it always worked in the past.
The & is the issue that is causing it to now work now. How do I handle that character in my String array using JavaMail?
Duc Vo
Ranch Hand

Joined: Nov 20, 2008
Posts: 254
JavaMail should have no problem with "&" character, which is a valid character of an email address.

What is your code? (i.e. how did you set the recipients to the message?)
what was the error? (i.e. exception occur somewhere or some recipients received emails, some didn't?)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Email character issue
 
Similar Threads
post request to url
Init param problem
Use mailto in jsp
Java Sending Email - failed
Insert HyperLinks at Email Body