Introduction to Java Server Pages

In this post, we are going to look at Java Server Pages. Below is a quick overview of What is JSP? and how they are different from Servlets.

  • Stands for Java Server Pages
  • Used to Create Web Applications
  • Extension to Servlet
  • Easy to Maintain
  • It is like inserting Java insert HTML
  • Less code than Servlet
  • Access to Java APIs

I hope you’ve enough knowledge of HTML and JAVA before starting JSP.

1. What is JSP?

Basically, Java server pages are used to create dynamic web applications using some HTML tags and inside them some JSP tags. It provides more functionality then servlet and Java Server Pages are extenstion to Servlet.

They are easy to maintain and less line of code is required. Also there is no need to restart or redeploy the service to see the changes.

What-is-JSP

2. Features of JSP:

  • Coding is Easy: If you’re familiar with Html and Java, then it’s very easy for you as you just need to add some Java code inside HTML tags.
  • Less Amount of Code: By defining custom tags, implicit objects we can reduce line of code.
  • Extension to Servlet: Apart from Servlet we also get some extra features like Implicit Objects and predefined and custom tags in JSP.
  • Fast Development: JSP is dynamic, therefore, there is no need to recompile or redeploy the whole module.
  • Easy to maintain: JSP application is super easy to maintain because of the coding standard.

3. JSP Syntax:

Before learning how to create JSP page let me first make you understand the basic syntax of JSP.

As you can see below, we have basic html tags and inside that we have some sort of script which is responsible to add two numbers and print them, called JSP Scriptlet tag.

We’ll learn these tags in further chapter.

<html>
  <body>
    <p><% out.print(5+5); %></p>
  </body>
</html>

4. Creating a simple JSP Page:

In order to create a JSP page you’ll need below things:

  • Apache Tomcat Server
  • JDK
  • Notepad++ or Eclipse IDE.

After installing Tomcat server, follow below steps

  • Create a file with an extension .jsp
  • Put the JSP file into the webapps folder of Tomcat installation directory.
  • Run the Server.
  • Visit browser and type localhost:8080/filename.jsp

I hope you’ve understood basics of What is JSP? and how it works? Follow next chapter to deep dive into the concepts.

1 thought on “Introduction to Java Server Pages”

  1. Your method of explaining the whole thing in this
    article is really good, every one be able to effortlessly be aware of it, Thanks a lot.

    Reply

Leave a Comment