TJOSY
asked on
Replacing HTML parameters with Java
Hi,
As a part of our department requirements, we need to send out HTML emails that are predefined.
These templates are stored in a table.
Please consider the below case
<HTML>
<TR>
<TD>
#NAME#
</TD>
</TR>
</HTML>
Value for the tag #NAME# needs to be picked up from the database and the HTML template populated accordingly.
Could you please advise, on how this can be achieved with Java ? Any sample code would be highly appreciated.
I have the code ready to send out emails. Only worry is to populate the HTML templates with the values form the database.
Regards
As a part of our department requirements, we need to send out HTML emails that are predefined.
These templates are stored in a table.
Please consider the below case
<HTML>
<TR>
<TD>
#NAME#
</TD>
</TR>
</HTML>
Value for the tag #NAME# needs to be picked up from the database and the HTML template populated accordingly.
Could you please advise, on how this can be achieved with Java ? Any sample code would be highly appreciated.
I have the code ready to send out emails. Only worry is to populate the HTML templates with the values form the database.
Regards
You can use JSTL to achieve this .....
you set the value in java and get the values in Java like
request.setParameter("name ","sathish ");
in JSP
<HTML>
<TR>
<TD>
${name}
</TD>
</TR>
</HTML>
you set the value in java and get the values in Java like
request.setParameter("name
in JSP
<HTML>
<TR>
<TD>
${name}
</TD>
</TR>
</HTML>
Do you have code to get Name?
http://www.exampledepot.com/egs/java.sql/connectoracle.html
get name value in code and send using mail code.
http://www.exampledepot.com/egs/java.sql/connectoracle.html
get name value in code and send using mail code.
ASKER
Hi All,
The example I provided was just a sample. In our case the HTML templates are quite large. These are infact some newsletters. that we need to send out to customers periodically.
The java code needs to call the templates(stored as a column in a database table) and then needs to replace the tags with the appropriate value (again picked up from different tables). Then the HTML needs to be emailed.
Regards
The example I provided was just a sample. In our case the HTML templates are quite large. These are infact some newsletters. that we need to send out to customers periodically.
The java code needs to call the templates(stored as a column in a database table) and then needs to replace the tags with the appropriate value (again picked up from different tables). Then the HTML needs to be emailed.
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks mrcoffee365.
You have provided me a simple solution that will serve my purpose.
I can do the coding for that. Now once I replace all the tags with the values from the database, how can I provide the output HTML to the users ?
Thanks and regards
You have provided me a simple solution that will serve my purpose.
I can do the coding for that. Now once I replace all the tags with the values from the database, how can I provide the output HTML to the users ?
Thanks and regards
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good luck! You can ask another question if you need help using Javamail. Also, there are a lot of answers already in EE about it.
http://velocity.apache.org/engine/devel/user-guide.html