16 Jan 2012

A Blank Final Variable

A final variable can only be assigned once in its lifetime. It means they can only be initialized only once. A blank final variable is a one which lacks an initializer.
:



a blank final variable behave differently than instance or static variable. And in this post I'll explore abut how they behave differently and why they do so.


The big statement is The compiler do not assign any default value for a blank final variable. Unlike the instance and static variable who gets default value by the compiler , the blank final do not get any default value.


Compiler Compiler complains on line 13 :  final variable c might  not nave been be initialized  
Therefore a final variable must be explicitly initialized. Initialization can be done either at the time of declaration or any time before using the final variable 


Now the question is how to explicitly initialize a blank final variable.It is also another aspect in which a blank final variable differs from a instance or static variable Lets see how it works
a blank final instance variable can only be initilazed inside the constructor or a instance initializer block but not inside a instance method.
Yes you read right a blank final variable cannot be initilazed inside a instance method.


Have a look


Compiler complains on line 13  cannot assign value to a value to final variable c.


the reason for this is all instance variable must be initilazed by the time object is crested. 


Similarly a blank final  static variable  can only be initilazed into the static initializer block.And yes... yes not inside the static method.This is because by the time class is loaded all static variables must be initialized.


Consider above points before you use a blank final variable next time.So this was all about the blank final variable.

14 Jan 2012

Apache Tomacat versions and Java Servlet/JSP specifications

The Java Servlet and JSP (Java Server Pages) specifications are designed by the JCP community.And the Apache Tomcat software are developed by the Apache Software Foundation having the specific version number.Each Tomcat  version implements the specific specification of the Servlet and JSP..One more thing is that for each upgraded specification of  Servlet and JSP specification the Java platform version is also upgraded or vice-versa.

Here is a mapping table of the Tomact version and a Java Servlet and JSP specification plus Java platform version.


Apache Tomcat version_no. Servlet Specification JSP Specification Java palform (minimum)

7.0x


3.0

2.2

1.6

6.0x

2.5

2.1

1.5

5.5x

2.4

2.0

1.4

4.1x

2.3

1.2

1.3

3.3x

2.2

1.1

1.1

11 Jan 2012

Introduction of Apache Tomcat

 I have been looking  to learn (and work) some open source project .After extensively searching various open source projects online , I set my eye on Apache Tomcat. It is widely popular  web server used for J2EE enterprise applications and most importantly it is purely written in java. Another advantage of learning Tomcat is that one can consolidate the Servlet and JSP topics.
So what is a Apache Tomcat ? It is a web server which implements the specification of  Servlet and JSP. 
How about Tomcat as a servlet container ?  A servlet container an environment in which a servlet is born, live and prosper.Whenever  there is request for the dynamic resource , Tomcat delegates this request to the servlet container and responsible for generating the response.
A figure below will depicts the basic working of Tomcat






A tomcat provides the administrative support for the servlet and other low level services like session management ,class loading etc.
what is the basic architecture of servlet container or Tomcat ?. It is interesting to note that the Tomcat's architecture follows the construction of a Matryoshka doll from Russia.It is all bout the containment of an entity within another entity.







In Tomcat 'container is a generic term used to refer to any component that can contain another component like Server, Service, Engine, Host or Context.
The Server and Service are Top level elements as they represents the running instance of  Tomcat.The Engine, Host and Context are designated as the Containers they are responsible for processing the incoming request and generating the response.Nested components are sub-elements of either top-level elements or Containers such as Valve, Resources, Realm, Loader, Manager  etc.
A Connector is major component of Tomcat architecture. It represents the connection between the client (web browser) and the Tomcat.
So this was the brief introduction to the Apache Tomcat. I'll explore more as i dive into it


 note: Apache Tomcat project is developed under the Apache Software Foundation.