• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP vs Thymeleaf

 
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am going to develop a website. While I was learning technology Spring boot and Servlet & JSP, I came across a new technology Thymeleaf. They have said that using JSP is much painful than using Thymeleaf. So it's recommended to use Thymeleaf.
They have even provided a comparison b/t JSP and thymeleaf here.
Even on the Spring forum, its is recommended to use thymeleaf. here

Could someone advise me what would be best for me to develop website. Where I can get proper support for the technology I am using, should be fast to learn and fast to develop, should be fast in execution.
Any advice would be heartily appreciated.

Thanks
 
Saloon Keeper
Posts: 15491
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, compared to Thymeleaf, JSP is quite a drag. You could also check out FreeMarker.

Honestly, I'd probably go with Thymeleaf, simply because it seems to have a very active community, which is mostly a good sign.
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stephan,
Could you please provide any useful resource to learn thymeleaf(other than their official website).
 
Stephan van Hulst
Saloon Keeper
Posts: 15491
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you could probably just google for Thymeleaf tutorial...
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how is thymeleaf as compared to JSP in terms of speed and performance. Is it fast or slow as compared to JSP ?
 
Stephan van Hulst
Saloon Keeper
Posts: 15491
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what I read, Thymeleaf is pretty slow compared to other templating languages, while JSP is very fast, with FreeMarker and Velocity coming close. However, Thymeleaf supports natural templates (templates that will render nicely in your browser even if you don't run them through the template engine).

For me, the ease of development and maintainability rank much higher than rendering speed of the page, which you might not even notice anyway. Why don't you just try it out? Write a page in Thymeleaf, write a page in JSP, time how much time you spent on understanding either language and how much time you spent on writing the page, and time how much time it takes to load the page.

I would only recommend using JSP if you've determined Thymeleaf is too slow for your purposes.
 
Stephan van Hulst
Saloon Keeper
Posts: 15491
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I would only recommend using JSP if you've determined Thymeleaf is too slow for your purposes.


Even then, FreeMarker or Velocity might be preferred.
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thymeleaf looks interesting - it hadn't been on my list of things to check out. It now is :-).

Aside from processing speed, I want to mention one advantage JSP has IMO: the availability of tag libraries. While those seem to be in slow decline in favor of jQuery plugins and the like, there are still a lot of very useful tag libraries out there. That's something to consider especially for complex pages. I wouldn't rank FreeMarker or Velocity higher than JSP, just for that reason.
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found a good comparison among these here.
And came to know that if I want my application to be ready very fast and easy to maintain, then Thymeleaf would be good choice. But if the number of requests,Requests per second,Time per request etc. are major concerns, then Freemaker would be the best choice.
Velocity is not a good choice any way since it has very bad support.

So, what I am doing as of now is, I will start with thymeleaf and design my first web application which is not concerned about user traffic. Then I will have a better understanding of template engine, so it will not take much effort to learn Freemaker for large traffic websites.
 
Tim Moores
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

then Freemaker would be the best choice


That page specifically says that the speed difference between Velocity, FreeMarker and JSP is rather small. That implies that other considerations will/should likely be the deciding factor between them.
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Moores wrote:That page specifically says that the speed difference between Velocity, FreeMarker and JSP is rather small. That implies that other considerations will/should likely be the deciding factor between them.


Yes, that why I choose Thymeleaf as the first technology to learn as it is easy to learn and for my first project, speed is not the major factor. And once I get to know how to make web apps using spring boot and Thymeleaf, it will be easy to switch template engine depending on the requirement.
 
Stephan van Hulst
Saloon Keeper
Posts: 15491
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:But if the number of requests,Requests per second,Time per request etc. are major concerns, then Freemaker would be the best choice.


You cannot draw that conclusion. It depends on the type of the requests, the complexity of the templates, etc.

The only way you will know which is right for your application in terms of speed, is to benchmark them for your application yourself, and only after you're not happy with the speed of the easiest one to develop with.
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:The only way you will know which is right for your application in terms of speed, is to benchmark them for your application yourself, and only after you're not happy with the speed of the easiest one to develop with.


But it will be difficult to develop the application once again from scratch if I made wrong technology choice. I am confused now. Can you please advice  me a path. My website will not have that much of traffic as of now, but yes I have to code it very fast in 50days. Wouldn't Freemaker be the best choice, as it has good speed, less complex then JSP, good support ?
 
Stephan van Hulst
Saloon Keeper
Posts: 15491
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, the best choice depends on your application. You don't even know yet if Thymeleaf is going to be too slow.

You can write a proof of concept with different languages before you write your entire application. If the difference in speed between the two versions of the proof of concept is too large, go for the faster language. If you don't notice a big difference, go with the easier language.

Your proof of concept can just be one page that you expect is going to take the most traffic. Then, perform load and stress tests.
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright. Thanks Stephan
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:Wouldn't Freemaker be the best choice, as it has good speed, less complex then JSP


I'd argue that JSP is only as complex as you make it. Sure, you could put a bunch of crap in views that doesn't belong there and cause the JSPs to be nightmarish; or you could do it right, and keep the JSPs as simple as possible, doing all the heavy lifting in the controllers where it belongs.

In my opinion, the "problems" with JSP are that people have been using it badly for over 20 years and so there are lots of examples out there that are just plain awful. Even books on JSP get it wrong.

But if you already know JSP, and have the discipline to keep the views simple, I'd suggest that you probably don't need to spend time learning yet another technology.

Just my 2¢
 
Puspender Tanwar
Ranch Hand
Posts: 658
2
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Sure, you could put a bunch of crap in views that doesn't belong there and cause the JSPs to be nightmarish; or you could do it right, and keep the JSPs as simple as possible, doing all the heavy lifting in the controllers where it belongs.


Hi Bear, could you please explain it with an example. Or any resource you might have, please share.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Essentially, do all the work in the controllers and other Java classes, and send data to the JSP. If you need to do anything more complicated in the JSP than simply use EL expressions and simple JSTL looping, you are making the JSP do too much work.

Basically, your JSP should look mostly like a simple HTML page with some JSTL and EL markup to show the dynamic data.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic