I'm trying to develop a web application that it obtains information from a server (in a mysql database ) and it is shown to the client (via browser) this information.
I want to use backbone.js and the default templates system (underscore.js) in the client part. For other hand, I want to use jsp for accessing to information from the mysql database in the server.
My problem is that I don't know so fine if it's possible to combine jsp and underscore.js (independently of syntax's problems associated to the fact what <% %> structure is the same to both technologies of).
I have searched about it, but I haven't found any example that use both technologies.
it's possible to combine both? or why not? can somebody show me some example?
Thanks in advance!!
MODIFIED AS NEXT:
I'm aware of syntax problem's existence, but I don't understand as to combine both (jsp and undescore.js). If I have the next template (underscore.js) in a html file:
<!-- language: lang-js -->
<script type="text/template" id="showTemplate">
<h2>
<%= title %>
<small>by: <%= author %></small>
</h2>
<p style="white-space:pre-wrap;"><%= description %></p>
</script>
And I have a backbone's view that replace the 'title', 'author' and 'description' fields of the template with the corresponding values:
<!-- language: lang-js -->
viewExample = Backbone.View.extend({
// the constructor
initialize: function (options) {
this.note = options.note;
},
// populate the html to the dom
render: function () {
this.$el.html(_.template($('#formTemplate').html(), {title: "Environment", author:"Albert", description:"textDescription"}));
return this;
}
});
How can I do for getting that value of a 'title', 'author' and 'description' fields is obtained from server via jsp?