Hello Servlet


what’s Servelet ?
Servlet is the type of class used to make a dynamic web page using java code

how we can make a servlet
a simple servlet class can be done by implementing the Servlet interface
but usually we use the servlet in an HTTP conection to make an HTTP response to the user in a form of HTML page, in this case it’s better to use HttpServlet abstract class

Hello Struts


Struts is a java framework for web implements the MVC design pattern.
Struts facilitates the work of page redirection, form submitting, data validation and much more.

a common scenario is a login page
login.jsp that contains two inputs user name and password
a simple java class/bean that maps this information ( has two properties username and password)
an action servlet that receives the login page data and put them into the bean
then make a specific action (Logining) after that redirecting to another page (success page or return to the login page if error happened)



The concept of multithreading is similar to the concept of multitasking

Operating systems allows multiple processes to run on the same time like word and paint and calc

We want the same behavior in the scope of a single process/java application, we want to be able to launch multiple functions at the same time, this concept is called multithreading, and every bunch of code that runs in parallel with another is called to be run on a thread.

We can make a simple thread in only 3 steps

  1. Extending Thread class
  2. Overriding run method
  3. Call start method to start the thread


Building simple Data Access Layer


The aim of this tutorial is to manage the access of a table in database from separate layer written in java, this layer usually called Data Access Layer (DAL)
this layer consists of A simple class/POJO/Bean called Data Transfer Object(DTO) this object is just a simple mapping to the table, every column in the table would be a member variable in the class.

our aim is to order this layer to create, modify, delete or search for an entity Using simple java objects rather than dialing with SQL statements and Database issues.

Database Creation

We want to create a simple table for users, we may create it using these fields

  • id
  • name
  • password
  • age


One to One Chat using sockets


Moving from the article Hello TCP sockets

We want to make a continuous one-to-one chat between two nodes
the two nodes at the beginning would be client and server
after connection establishment they should act similar as two nodes

Dynamic breadcrumb / navigation menu


A breadcrumb / navigation menu should track all the moves of the user from a page to another

the concept of making a dynamic navigation menu is to save every visited page in a list so that it contains all the visited pages from the home page until the current page
when i click on any menu item (return to a previous page on my navigation) i should clear all the pages after this page from the list.

user visits history should be stored among all user requests and should be unique to every user, so we would store navigation information in Session scope


Using Tag interface


The Tag interface is the main interface in custom tags
we can make our own custom tag by implementing this interface

When the container evaluates the custom tag, it first pass the PageContext object of the current page and the parent Tag of this custom tag.
Then the container calls the doStartTag that decides to include or skip the body of the tag then it calls the doEndTag that decides to continue parsing the rest of the page or to stop.
The tag is used many times by the container before it got out of service then the containers calls release method.


Hello JSF


Java Server Faces (JSF) is component-based framework that facilitates using HTML elements because you will not responsible anymore for writing parts of your HTML code

An example is to make a login page

we will start by making a bean represents our data
it will contain two properties represents the name and the password (two attributes, two setters and two getters )

also we’ll include a method that checks if that login details is valid or not
for simplicity we’ll choose a simple rule
if the name equals password then it’s correct login information
we can change this lines of code by what you want as for example connection to our database to check for these details

package beans;

public class User {

    private String name;
    private String pass;

    public void setName(String name) { = name;

    public void setPass(String pass) {
        this.pass = pass;

    public String getName() {
        return name;

    public String getPass() {
        return pass;

    public String check()
            return "welcome";
            return null;


there is something missing
till now it’s just a bean
we need to tell the framework that it’s a managed bean providing a name for it and a scope to be put into

Managed Bean
JSF framework uses some kind of beans called Managed Beans to store form data
so we will start to make our own ManagedBean


Simple Web Service client using java


We are now going to make a simple connection to a web service

suppose we made a web service called Hello

the first thing we should have is an interface of that service class to be able to call its services using java code
After that we ‘d write some code to connect to that service

fortunately there is a tool in JDK called wsimport that can do all of that if you just provided it with a valid WSDL URL


Simple web service in java


We are introducing a very simple sample of making a web service in java
the sample “Hello world” service will be responsible for saying hello to the name that I’ll send it to that service


Go to Top