Skip to main content

JSP Tutorial for Beginners

Here is a quick-start JSP tutorial for beginners. Before you read this tutorial, I suggest you to have a per-requisite knowledge of servlets in Java.
In this tutorial you are going to learn:
  • Scriptlets, Declarations and Expressions
  • JSP Directives
  • XML Tags
  • Working with JSP beans
  • Custom tags

Introduction to JSP 

JSP stands for Java Server Pages. It is a tag based approach that mixes both the HTML and the java servlet code. The reasons why we should use JSP will be the strongest foundation for you.
  • You do not need to write servlet classes anymore. They are replaced by JSP.
  • Tag based approach is more cleaner and programmer friendly.
  • HTML mixed with servlet code will provide all logic at one place.
  • You NEED NOT COMPILE servlets, RESTART server. Because the server automatically checks if a JSP page is modified upon each request. If modified, jasper container translates JSP to servlet (.java) file, compiles it and then loads it automatically.
  • Simplified data processing with beans approach.

1. Scriptlets, Declarations and Expressions

The very basics of JSP you need to start coding with.

2. JSP Directives

3. XML Tags

A clean, tag based approach for JSP.

4. JSP Beans

How JSP simplifies data processing with MVC using beans?

5. Custom tags 

Create custom tags to improve re-usability.


Popular posts from this blog

Setting Background Image in JFrame - Swing

Here is sample tutorial, a simple trick that enables you to set background image for JFrame.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class BackgroundImageJFrame extends JFrame
JButton b1;
JLabel l1;
public BackgroundImageJFrame()
setTitle("Background Color for JFrame");
One way
setLayout(new BorderLayout());
JLabel background=new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png"));
background.setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am a button");
// Another way
setLayout(new BorderLayout());
setContentPane(new JLabel(new ImageIcon("C:\\Users\\Computer\\Downloads\\colorful design.png")));
setLayout(new FlowLayout());
l1=new JLabel("Here is a button");
b1=new JButton("I am …

Add two numbers in JSP easily

Here is an example on adding up two numbers in JSP. This is very simple as you see below. This requires very small piece of code. All i have done here is created a HTML file containing the input fields which contain the numbers to add up.Now the values in the input field are of type String, so i have done type casting and converted them into int using Integer.parseInt(). See how easy it looks.

Creating Transparent JPanel in Swing

It is a quite common question, "how to create transparent panels in swing" and if you think that the solution is critical and involves a lot of hacks, you are wrong. Yes, because creating transparent panels in swing is as easy and you are already might be familiar with it.