×
☰ See All Chapters

Java Server Pages (JSP) Tutorial

Learning JSP is easy when compared to servlets. Without much knowledge of the JSP API you can code JSP.  There are 5 main basic elements of the JSP.

    1. Scripting elements.

    2. Directives

    3. Standard actions

    4. EL (Expression Language)

    5. JSTL (JSP Standard Tag Library)

Apart from these elements there are very few other topics and which are not big also. If you have learnt these elements of JSP then you can develop simple to complex applications using JSP.

Create a file with the name “demo.jsp” with .jsp extension and save the file with the below code.

<html>

<body bgcolor="yellow">

        <h1>HELLO JSP</h1>

</body>

</html>

 

jsp-tutorial-0
 

Run the application in server. Now you have developed a JSP application successfully.

Why JSP over Servlet?

JSP is not meant to replace servlets, JSP is an extension of the servlet technology, and it is common practice to use both servlets and JSP pages in the same web applications.

Servlet is the mandatory prerequisite knowledge for JSP, if you are not familiar with servlet technology, please read our servlet tutorial before reading JSP tutorial.

When you have to send along HTML page from a servlet, it becomes cumbersome to programmers. If the HTML code is static content then it becomes still more head ache. Programmers have to construct a very long string of HTML.

If in later time, any changes come, it takes more time to change. It becomes difficult for maintenance.

Sun/Oracle understood this problem and developed JSP technology.

JSP is not a replacement for servlets, but JSP is an extension of the servlet technology. JSP should be used only for presentation logic and servlet should contain controller logic.


All Chapters
Author