35

I have learned about servlets and the JSP's before, but I don't know what is the JSTL and the difference between the JSP and the JSTL.

Aaron Kurtzhals
  • 2,036
  • 3
  • 17
  • 21
Questions
  • 20,055
  • 29
  • 72
  • 101
  • 2
    Related: http://stackoverflow.com/questions/2095397/what-is-the-difference-between-jsf-servlet-and-jsp In a nut: JSP is a **view technology** and JSTL is a **JSP taglibrary**. You don't use the one *or* other. You just use JSP *with* JSTL. – BalusC Sep 15 '10 at 12:00
  • Check out - [JavaServer Pages Standard Tag Library](http://www.oracle.com/technetwork/java/index-jsp-135995.html) - [A JSTL primer](http://www.ibm.com/developerworks/java/library/j-jstl0211.html) Btw these come up by googling "jstl" as the first and third hit, respectively. – Péter Török Sep 15 '10 at 07:26

1 Answers1

43

JSP is a technology similar to ASP that let you embed Java code inside HTML pages. This code can be inserted by means of <% %> blocks or by means of JSP tags. The last option is generally preferred over the first one, since tags adapt better to own tag representation form of HTML, so your pages will look more readable. JSP lets you even define your own tags (you must write the code that actually implement the logic of those tags in Java). JSTL is just a standard tag library provided by Sun (well, now Oracle) to carry out common tasks (such as looping, formatting, etc.).

Fernando Miguélez
  • 11,196
  • 6
  • 36
  • 54
  • @Frenando Miguelez, thank you for your reply. If I implement the JSTL, is it the same code of the JSP? ( I mean the ) or the .jsp will change to .jstl? thank you. – Questions Sep 15 '10 at 07:39
  • You use just plain normal JSPs. The only difference is that you must declare at the beginning of JSP what part (core, sql, etc.) of JSTL you will be using: http://www.java2s.com/Code/Java/JSTL/JSTLImportaPage.htm – Fernando Miguélez Sep 15 '10 at 08:08
  • 1
    Client-side developer's opinion: The less the templating language looks like HTML, the more legible, IMO. Just using `>` tokens was a design flaw. Nothing uglier/more confusing than a giant pile of intertwined taglib/HTML written by server-side or app dev just looking to hammer in some nails. – Erik Reppen Jan 17 '13 at 17:47
  • @FernandoMiguélez what did you meant by `since tags adapt better to own tag representation form of HTML` – Kasun Siyambalapitiya Aug 18 '16 at 13:25