Evolution of Java Web applications in a nutshell

So it all started off with simple FTP . Since files were not sufficient to share information interactively . Simple HTTP ( Hyper Text Translation Protocol ) and HTML files were used to do the job . 

The setup for exchanging static HTML pages over web looked like this :

statichtml

This was ofcourse found insufficient as it did not let a download html page interact with the back-end information , such as displaying real time computational results .  Hence applets came into being . These let to client side computing by using the JVM .

applets

But with time the eminent disadvantages such as security , heavy load etc were realized and this was replaced with server side programming , using servlets . This led to dynamic web pages . The servlets were a big hit as they let open a whole new world of web based programming with the help of Web Container .

servlets

But Servlets gave poor separation between business logic and presentation logic. JavaServer Pages and JavaBeans came into existence to improve the job . and the concept of MVC ( Model – view controller ) was born . 

jsps

However with time the business logic for web applications grew in magnanimous way . Now the business log needed to be defined separately  or integrated from remote locations. so EJBs were made to encapsulate business rules, application-specific logic, and access to data, concurrently . Ejbs

Eventually the whole J2EE multi-tier model looked like this :

 multitier

Thats all that fits in a nutshell  . 

 

autoboxing and auto unboxing

A collection contains only objects. It cannot holds primitives (such as int and double). Although arrays can be used to hold primitives, they are not resizable.
To put a primitive into a collection (such as ArrayList), you have to wrap the primitive into an object using the corresponding wrapper class


Prior to JDK 1.5, you have to wrap a primitive value into an object and unwrap the primitive value from the wrapper object:
// Pre-JDK 1.5
Integer intObj = new Integer(5566); // wrap int to Integer
int i = intObj.intValue(); // unwrap Integer to int
Double doubleObj = new Double(55.66); // wrap double to Double
double d = doubleObj.doubleValue(); // unwrap Double to double

The pre-JDK 1.5 approach involves quite a bit of codes to do the wrapping and unwrapping. JDK 1.5 introduces a new feature called auto-boxing and auto-unboxing to resolve this problem, by delegating the compiler to do the job. For example:
// JDK 1.5
Integer intObj = 5566; // autobox from int to Integer
int i = intObj; // auto-unbox from Integer to int

Double doubleObj = 55.66; // autoboxing from double to Double
double d = doubleObj; // atuo-unbox from Double to double

OOP_WrapperClass

I/O operations

java io


To Read Integer, float number from keyboard while Running the program
import java.util.*;
class ReadNumber
{
public static void main(String args[])
{
System.out.println(“Enter the integer number : “);
Scanner ob=new Scanner(System.in);
int i=ob.nextInt();
System.out.println(“Enter the float number : “);
Scanner ob1=new Scanner(System.in);
float j=ob1.nextFloat();
System.out.println(“Sum is : “+(i+j));
} }

To read a charterer at run-time 

import java.io.*;
class ReadCharecter
{
public static void main(String args[])throws IOException
{
char c;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter characters (‘q’ to quit. “);
do
{
c=(char) br.read();
System.out.println(c);
}while(c!=’q’);
} }

Program to read string instead of single characters 

import java.io.*;
class line
{
public static void main(String args[])throws IOException
{

String str=” “;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“enter lines of text . enter exit to quit”);
do{
System.out.println(str);
str=br.readLine();
}while(!str.equals(“exit”));
} }

physical operation 

io_sequence