I have some data in a database which i need to use to generate an HTML file.
The format of the HTML file will always be the same, i.e. it will always look something like this
-----------------------------------------
|
[Header] |
- Advertising banner |
|
[Body] |
|
---------------------------------- |
Content column | content column | |
Content column | content column | |
Content column | content column | |
---------------------------------- |
Content column | content column | |
Content column | content column | |
---------------------------------- |
|
[Footer] |
|
- Copyright information etc |
|
-----------------------------------------
The data i will be reading from the database table will be read using JDBC. I know i can generate the HTML file by manually coding the HTML source with the tags but im sure this is not the correct way of doing it.
Is there some sort of templating mechanism where i have a template for the HTML file which could probably have placeholders for the content sections which i can then update at run time after i have read the content from the database.
I thought that XSLT was specifically created for this purpose but looking at Google it looks like XSLT is for transorming XML to other formats which is not what i want. I could probably convert the data i read from the database into XML and use XSLT but this seems like an additional unessary layer of processing.
What is the usual/common way of approaching this kind of problem?
I would prefer to use Spring/Maven but open to other suggestions.
Thanks
Edit
Also, please note that the HTML file that is generated is not for displaying on the browser/web. It is displayed in an Email. A new HTML file will be generated everyday.
My suggestion would be to use XSLT – many DB can already produce results as XML, or you can write easily code to convert your SQL query results in simple XML:
Once you have this XML using XSLT you can generate any HTML – or many other formats – in a way that is standard, well-supported and very very flexible.