Trying to get a better understanding of what JSP is?

JC0133

Senior member
Nov 2, 2010
201
1
76
I started a new job and I am learning a lot about Java(still fairly new to it) and web development.

We are using Spring Boot, IntelliJ, etc.

I am trying to get a much better understanding of JSP. This is the response I got from stack overflow.

JSP is a Java view technology running on the server machine which allows you to write template text in client side languages (like HTML, CSS, JavaScript, ect.). JSP supports taglibs, which are backed by pieces of Java code that let you control the page flow or output dynamically. A well-known taglib is JSTL. JSP also supports Expression Language, which can be used to access backend data (via attributes available in the page, request, session and application scopes), mostly in combination with taglibs.

I didn't complete understand this 100%.

I don't know what taglib or expression language is (what I googled wasn't every helpful)?

The reason I am even asking this is cause I was debugging some test classes errors, and once I got them to work, I wanted to test some of the output in the UI application. That is when he told me to match and track the test controller back to the implementation controller.

Which made sense and I already did that, then track the areas you were testing to the proper end points(methods), that made sense and I already had did that. Then I got confused because it tracked back to an application properties file which lead me to .jsp file with html code.

So when I was reading up on Java MVC, I learned it stands for model, view, controller.

So is the JSP the view part of "MVC" and that is normally the html webpage?

If I trace the code back to a .jsp file, does that normally mean I found the proper html page of the application that I am working on?

Will the code always trace back to a .jsp page for a web application?

I appreciate any supportive answers, good YouTube tutorials or websites where I can look this stuff up and study on my on.
 

Cogman

Lifer
Sep 19, 2000
10,284
138
106
You can think of JSP the same way that you think of PHP. That is, it allows you to embed functionality within some HTML.

JSP, like PHP, is only evaluated on the server.

Now, TBH, I don't really think JSP is the way to go now-a-days. IMO, it is much better to just do a static HTML page with a web framework such as React, Angular, or Vue. Java is best fit for writing rest endpoints. The Javascript frameworks are much better suited for GUI design.
 
  • Like
Reactions: cytg111

purbeast0

No Lifer
Sep 13, 2001
53,475
6,316
126
Yeah JSP's are kind of antiquated technology at this point. I'd strongly suggest going a different route and do what @Cogman says.
 

cytg111

Lifer
Mar 17, 2008
25,230
14,719
136
You can think of JSP the same way that you think of PHP. That is, it allows you to embed functionality within some HTML.

JSP, like PHP, is only evaluated on the server.

Now, TBH, I don't really think JSP is the way to go now-a-days. IMO, it is much better to just do a static HTML page with a web framework such as React, Angular, or Vue. Java is best fit for writing rest endpoints. The Javascript frameworks are much better suited for GUI design.
Servlets are still at the core of many things but JSP? Its been 7-8 years maybe more since I was asked to do some maintenance on some old code... its not a thing today.
 

lnanek

Junior Member
Aug 16, 2020
13
1
11
JSPs basically compile HTML plus some basic tags like looping and data binding into a servlet. It's basically like EJS or Handlebars is for NodeJS, but for Java. Tag libs are reusable tags in the JSP HTML that can do something like present a complex widget to the user. I don't think anyone would start a new project in JSP, but there could be enterprises with large deployments that already use it.

Expression language was a way to do some basic math/string formatting/reference following on variables you are referring to in the HTML template. It allowed the code that called the JSP to do less work getting all the data into variables in the page context for the JSP to output.

Debugging can hit JSPs because they are the equivalent of a servlet with a bunch of print calls to the output stream with HTML string arguments.
 
  • Like
Reactions: cytg111