You are on page 1of 165

JavaEra.

com
A Perfect Place for All Java Resources



Core Java | Servlet | JSP | JDBC | Struts | Hibernate | Spring
Java Projects | FAQs | Interview Questions | Sample Programs
Certification Stuff | eBooks | Interview Tips | Forums | Java Discussions



For More Java Stuff Visit
www.JavaEra.com
A Perfect Place for All Java Resources

As an admin, let me introduce myself to all
I am Anil Anil Anil Anil Reddy Reddy Reddy Reddy from Hyderabad.
the fullest, loves programming
Why I started JavaEra.com
I was a job seeker like you all but I was not sure about how to attempt an
interview or various companies selection process. I had searched many
Portals on the web & joined many job
was getting the information regarding latest job openings only but not
any resources to chase job selection process by improving my skills.
Why we need those skills? Just
Once upon a time a very strong woodcutter asks for a job in a timber merchant, and he got
it. The paid was really good and so were the work conditions. For that reason, the
woodcutter was determined to do his best. His boss gave him an axe and showed him t
area where he was supposed to work. The first day, the woodcutter brought 18 trees
"Congratulations," the boss said. "Go on that way!" Very motivated for the boss' words, the
woodcutter try harder the next day, but he only could bring 15 trees. The thir
even harder, but he only could bring 10 trees. Day after day he was bringing less and less
trees. "I must be losing my strength", the woodcutter thought. He went to the boss and
apologized, saying that he could not understand what was going on
"When was the last time you sharpened your axe?" the boss asked. "Sharpen? I had no time
to sharpen my axe. I have been very busy trying to cut trees.


Welcome to JavaEra.com.
, let me introduce myself to all of you.
Hyderabad. Im a normal guy who lives life to
loves programming and lives a happy-go-lucky
JavaEra.com?
like you all but I was not sure about how to attempt an
interview or various companies selection process. I had searched many
Portals on the web & joined many job groups. From all those sources I
was getting the information regarding latest job openings only but not
any resources to chase job selection process by improving my skills.
Just go through this small story...
Once upon a time a very strong woodcutter asks for a job in a timber merchant, and he got
it. The paid was really good and so were the work conditions. For that reason, the
woodcutter was determined to do his best. His boss gave him an axe and showed him t
area where he was supposed to work. The first day, the woodcutter brought 18 trees
"Congratulations," the boss said. "Go on that way!" Very motivated for the boss' words, the
woodcutter try harder the next day, but he only could bring 15 trees. The thir
even harder, but he only could bring 10 trees. Day after day he was bringing less and less
trees. "I must be losing my strength", the woodcutter thought. He went to the boss and
apologized, saying that he could not understand what was going on.
"When was the last time you sharpened your axe?" the boss asked. "Sharpen? I had no time
to sharpen my axe. I have been very busy trying to cut trees.

Im a normal guy who lives life to
lucky kind of life.
like you all but I was not sure about how to attempt an
interview or various companies selection process. I had searched many
groups. From all those sources I
was getting the information regarding latest job openings only but not
any resources to chase job selection process by improving my skills.
Once upon a time a very strong woodcutter asks for a job in a timber merchant, and he got
it. The paid was really good and so were the work conditions. For that reason, the
woodcutter was determined to do his best. His boss gave him an axe and showed him the
area where he was supposed to work. The first day, the woodcutter brought 18 trees
"Congratulations," the boss said. "Go on that way!" Very motivated for the boss' words, the
woodcutter try harder the next day, but he only could bring 15 trees. The third day he try
even harder, but he only could bring 10 trees. Day after day he was bringing less and less
trees. "I must be losing my strength", the woodcutter thought. He went to the boss and
"When was the last time you sharpened your axe?" the boss asked. "Sharpen? I had no time

If we are just busy in applying for jobs, when we will sharpen our
skills to chase the job selection p
I dont have many friends who can suggest me or who can share some tips. I got irritated
like anything. I thought that like me, there may be millions of my brothers and sisters across
the nation facing same kind of problem.
So I strongly committed to start a special zone for all job seekers & IT professionals where
everyone can sharpen their skills to find their dream job & in their dream company.
As a result in 10 months nearly 15000+ job seekers joined our family. Thousands of people
got benefited by utilizing our resources.
This is just a start, what we have achieved till now is just 0.1% in our vision which is
Creating a perfect place to share
Now I am not alone in chasing this challenge. We will work together by sharing knowle
giving a ray of hope to millions of our brothers and sisters across the nation.
My Technical Skills:
Google SEO (Search Engine Optimization) Certified.
JSE (Certified), Servlets, JSP, Struts, Hibernate, Spring, PHP, Zend Framework.
HTML, JavaScript, Jquery, AJAX, CSS, Adobe Photo
Flash.
My aim is to provide good and quality articles and content to readers and visitors to
understand easily. All articlesare written and practically tested by me before publishing
online. If you have any query or questions regarding any article feel free to leave a comment
or You can get in touch with me On
Regards
Anil Reddy
Founder & Administrator
JavaEra.com
Email :
anilreddy77466@gmail.com
anilreddy@JavaEra.com.
www.facebook.com/JavaAnil

If we are just busy in applying for jobs, when we will sharpen our
skills to chase the job selection process?
I dont have many friends who can suggest me or who can share some tips. I got irritated
like anything. I thought that like me, there may be millions of my brothers and sisters across
the nation facing same kind of problem.
to start a special zone for all job seekers & IT professionals where
can sharpen their skills to find their dream job & in their dream company.
As a result in 10 months nearly 15000+ job seekers joined our family. Thousands of people
by utilizing our resources.
This is just a start, what we have achieved till now is just 0.1% in our vision which is
Creating a perfect place to share Java knowledge.
Now I am not alone in chasing this challenge. We will work together by sharing knowle
giving a ray of hope to millions of our brothers and sisters across the nation.
Google SEO (Search Engine Optimization) Certified.
JSE (Certified), Servlets, JSP, Struts, Hibernate, Spring, PHP, Zend Framework.
Jquery, AJAX, CSS, Adobe Photoshop CS6, Adobe Illustrator CS5
My aim is to provide good and quality articles and content to readers and visitors to
understand easily. All articlesare written and practically tested by me before publishing
ine. If you have any query or questions regarding any article feel free to leave a comment
ou can get in touch with me On anilreddy@JavaEra.com, www.facebook.com

anilreddy77466@gmail.com,

/JavaAnil
If we are just busy in applying for jobs, when we will sharpen our
I dont have many friends who can suggest me or who can share some tips. I got irritated
like anything. I thought that like me, there may be millions of my brothers and sisters across
to start a special zone for all job seekers & IT professionals where
can sharpen their skills to find their dream job & in their dream company.
As a result in 10 months nearly 15000+ job seekers joined our family. Thousands of people
This is just a start, what we have achieved till now is just 0.1% in our vision which is
Now I am not alone in chasing this challenge. We will work together by sharing knowledge &
giving a ray of hope to millions of our brothers and sisters across the nation.
JSE (Certified), Servlets, JSP, Struts, Hibernate, Spring, PHP, Zend Framework.
shop CS6, Adobe Illustrator CS5, Adobe
My aim is to provide good and quality articles and content to readers and visitors to
understand easily. All articlesare written and practically tested by me before publishing
ine. If you have any query or questions regarding any article feel free to leave a comment
w.facebook.com/JavaAnil






WebServices


www.JavaEra.com
~- ~ ~.~ -- .. . . ...
WEB-SERVICES [Intro) By Mr. SekharReddy ., i ;
Q.) What is distributed technology?
I
' I
A technology is said t o be di stri buted i f it's business objects are geographically dispersed i
I
(across multiple JVM's) and st111 communicating one another.
' I
Q.) Why distributed technology?
I-) Load balancing
I High Availability
I-:, High Processing
Q.) What are different distributed technologies?
I > There are so many di stri buted technologies
o CORBA
o RMI
o EJB
o WEB SERVICES ... etc.
.&
CORBA
> More compl exi ty i n t he i mpl ementati on
I - > Heavy wei ght
Language dependent
I > Commercial
I :, Plat f rom i ndependent
RMI
I > Lack of Enterprise services/Middle ware services
I > Open source
I IVo acknowl edgement
, #
I > Language dependent
I > Plat from i ndependent
E3 B
I-> Supports Enterprise services/Middle ware services i n t he decl arati ve manner
Having mul ti pl e fl avors of APIs t o handle di fferent requi rements
o Session beans
Stateless
Stateful
o Entity beans(not usi ng now)
= JPA
o Message Dri ven Beans
- -
!
Naresh i Technologies, Opp. Satyam Theatre, Ameerpet, Hyderabad, Ph: 040-23746666,23734842
An IS0 9001 : 2000 Certified Company
I
. . . . . . . . . . . . . . . . . . .- - . . . . .. . . -, . . . - - . . - . - - - .- . . ... .- - - - -- . . -
- - .- .- . . . .
Page 1
-
. . - ~ - ~ .. - - ...p-p.p....p-.pp-
WEB-SERVICES (Intro) By Mr. ~ e k h a r ~ e d d v ~ ~ . ~ ~ !
I > Managed by Application server
Robust
I Heavy weight
c> Language Dependent
G Plat from independent
WEB SERVICES
I-? Supports Enterprise services
I > Interoperable (Language independent & Plat from independent)
So, Web services is interoperable distributed technology
I
!
1
Q.) What we require if two persons need to communicate?
1 .) Two persons @
I
I 2.) Medium
3.) Language
4.) RuIes(protocoI)
I
Web services architecture
I f t wo applications needs t o communicate
a Both the applications should be connected (network)
e Both application needs t o communicate by following some rules(protocols)
o Hr r P
o FTP
o SMTP ... etc.
r:, To communicate language is required(Neutra1 language)
o XML
- --
~ a G s h i Technologies, Opp. Satyam Theatre, Arneerpet, Hyderabad, Ph: 040-23746666,23734842
. . . . . . . . . . -. . - - - - - - -
An I S 0 9001 : 2000 Certified Company
P~@Z---
- -. --ppp-p..-- --
WEB-SERVICES (Introl Bv Mr. ~ e k h a r ~ F d x F TI 1
SMTP
I
I n the internet world we prefer t o use H-TTP protocol, and we have so many technologies
, ,
which supports Hl TP protocol.
I
X I
I > Lets assume t hat we are sending employee information form "Consumer" t o "Provider" in
t he XML format as follows.
i
I
<id>ysreddy</id> +.-..- -
__.__.L.---'
Authentication Data
<password>* * * * * *</passwOrdx-------~---'--
<id >88 @8</i d ---_.__
--__
---_
----
<name>sekhar</name>s--..---- --.-..-.-...-
- ~ ___.-----
-__._--- '---:..- -Business Data
<salary>2489</salary> c---,-:--p------
e At "Provider" side i t may be interpreted as follows
---,-
H I
Naresh i Technologies, Opp. Satyam Theatre, Ameerpet, Hyderabad, Ph: 040-23746666 23734842
- I
An I S0 9001 : 2000 Certified Company
- - - - - - .- -. - --
I
Page 3
,,,'
, . , ; , - Authentication Data
<employee> ,,,,,, ,,.. ,,, ,,'
,,I'
,.,.,'' , , . ,
<id>ysreddy</id>:::-. . ,,
,,,... ,,,, ,,,,, I, ,111
..__> ,,,, , 1
,,,' ,,,"
<password>**** **<l,p-,i+" labSWb s i dy .
_,.,"
'-I ...
<id>88688</id> : . "
. ._ ..._. ...
'I.
<name>~ekha~</ ~~me>: . . . .
.... ":a, Business Data .............
.. ..
.......
.........
...............
<sa lary>2489</sa la ry> z-,
</employee>
I -: , So, classification of the information is missing.
I
I
I-> So, we don't send raw XML document(contains business data) t o the providers.
We need classification of the request data like
I
o Processing information/Authentication information
I o Business inforniation
I I-:, To achieve this we will go for SOAP
I 0 SOAP stands for Simple Object Access Protocol
- I-> SOAP is a classification protocol
SOAP is a binding protocol(processing data + business data)
C'onsu msr
Provider
But what services are providing by the Provider should be explained. To know the services
of "Provider", "Consumer" cannot look into the code of of "Provider".
3 So "Consumer" needs the information like what are the services are providing, what they
will take as input, and what t he output they will return, what url has t o call t o get
services ... etc.
~3 "Provider1' will explain all these information in one document called "WSDL".
Q "WSDL" stands for Web Service Description Language
+ "WSDL" is an XML document, because it should be language independent, so t hat any
type of client can understand t he services of the "Provider".
Nares'h i Technologies, Opp. Satyam Theatre, Ameerpet, Hyderabad, Ph: 040-23746666,. 23734842
An IS0 9001 : 2000 Certified Company
- - - - - .- . - -
. .
..-.-. .. ........... ........... .......
Page 4---
.- ~~ - ~ - - -
WEB-SERVICES (Intro) Bv Mr. SekharReddv-- 1
.;t, "WSDL" is the document which explains the services information. But how can
I
"Consumer" get that WSDL document, from where "Consumer" get?
i
L- : , So "WSDL" documents has t o be placed in some location from where "Consumer" can
access them, that location is nothing but "UDDI"
I
I
~2 UDDI stands for Universal Description Discovery and Integration
I UDDI is the Registry where all the WSDL documents are registered
' I
, '
I UDDI should be interoperable, so it is also developed in XPIL \ I
r2 UDDI registry also called XlYL registry
I
-
I
i
i ~.
Naresh i Technologies, Opp. Satyam Theatre, Ari~eerpet, Hyderabad, Ph: 040-23746666,23734842
An I S0 9001 : 2000 Certified Company
I
~ . - -. .-
i
Page 5 ' -
2. ) What is WS-I?
The WS-I (Web Services Interoperability) Organization is an association of I T industry
compa~iies, including IBM and Microsoft, t hat aim t o create Web services specifications
t hat all companies can use.
4.) What are the different standards given by WS-I to implement Web services ?
r3 WS-I has given
o Basic Profile 1.0 (BP 1.0)
o Basic Profile 1.1 (BP 1 .l)
o Basic Profile 2.0 (BP 2.0)
Naresh i Technologies, Opp. Satyam Theatre, Ameerpet, Hyderabad, Ph: 040-23746666,23734842
An I S0 9001 : 2000 Certified Company
. - - - - - -- -
Pa=-6-
, - - - ~
WEB-SERVICES (Intro) By Mr. S e k h a r Re d d v . ,
I Q.) What are Web services?
I
I-:, Web services is a software application t hat confirms t he WS-1's given speicifiations( BP
-.I
l.O/BP l . l / BP 2.0) is said t o be web services.
I
I
I
I
13 Any program t hat is di stri buted i n nature, language i ndependent and pl at f orm neut r al is \
said t o be web services.
I I -
I
I There so many API's, I mpl ement at i ons f or t he WS-I given standards
1
~3 Sun has released "JAX-RPC" API t hat follows BP 1.0 standard
Sun has released "JAX-WS" API t hat follows BP 1. 1 standard
JAX-RPC
-4 ,AX-ws I
JAX-RPC : Java APIs f or XML-based Remote Procedure Call
JAX-WS : Java API f or XPlL Web Services
JAX-P : Java API f or XML Processing
JAX-B : Java Archi tecture f or XML Binding
I i
-
JAX-R : Java API f or XML Registries
1
SAAJ : SOAP wi t h At t achment s API f or Java
1
.-
1
Naresh i Technologies, Opp. Satyam Theatre, Ameerpet, Hyderabad, Ph: 040-23746666,23734842
I
I
. - . -. . - - - -. -. . --
An IS0 9001 : 2000 Certified Company
p a g e - 7 -
Implementation
(from different companies)
-- -- . -- --
Specification
(froni WS-I)
API
(from Sun microsystem)
. . . . ~
. WEB-SERVICES [Intro) By Mr. ~ekhar keddf
JAX-WS RI(from Sun)
BP 1.1 JAX-WS Apache-Axis2(from ASF)
Metro(from Sun)
CXF(from ASF) ... etc.
- - - -- - -- - -- - - pp -
BP 1.0
NOTE: JAX-WS RI(Reference Implementation) was f a~l ed t o access by .Net, means f a~l ed i n
interoperability. Sun then released "metro" implementation of JAX-WS, which resolved
interoperab~lity problem and also added some more features.
i
i NOTE: Apache CXF internally uses spring.
- --
JAX-RPC
! Web Services Development
-- ----
JAX-RPC-SI(from sun)
... Apache-Axis(from ASF) etc
I
I Web services development can done in t wo ways
1. Contract first(top-down) approach
2. Contract last(bottom-up) approach
-
I
, Contract first A ~ ~ r o a c h
-
! WSDL + Services
! -
I
Contract last Amroach 1
I
I
' Services + WSDL I
I
, NOTE:
~3 Services can be developed with any technology like .Net, Java, Php ... etc
...
'
d I n java, Services can be developed using any API like JAX-RPC, JAX-WS, RESTFUL etc..
... I ~3 I n java, Services can be developed using any implementations like sun, apache etc..
I I
But WSDL development is unique, it's not plat form specific, not language specific, not
technology specific, not API specific, not implementation specific.
, So, we can say we are developing web services using
I > JAX-RPC, Contract first approach
I
I 3 JAX-RPC , Contract last approach
I
I
I
NOTE: I n the internet world w& prefer t o use Hl TP protocol, and we have so many technologies I
/ which supports Hl TP protocol.
-
I
! Q.) What are the HTTP protocols implemented API's?
( 1. Servlet API
2. EJB API
i
I
I
Naresh i Technologies, opp. Satyarn Theatre, Ameerpet, Hyderabad, Ph: 040-23746666,23734842
1 I
1
An IS0 9001 : 2000 Certified Company
-. . . . . . . . . . . . . . . . . . . . . . . . . . .-....... --
I
Pa ge8--. ,
--- --
WEB-SERVICES (lntro'l--- Bv Mr. ~ekhar ~edTl t 7
'
Q.) Wh a t i s end poi nt ?
1 I, A component which receives "Consumer" request
I, I n general we use either servlet or ej b as an End Po~nt .
So, we can say we are developing web services using
I > JAX-RPC, Servlet end poi nt url, Contract first approach
1 > JAX-RPC, EJB end point url, Contract last approach
I
i MEP
1 MEP stands for ~es s agd~x c hangi ng Patterns
1
r3 " Cons ~~r ner ~~ can communicate wi t h "Provider" i n t hree ways
o Synchronous request-reply
o Asynchronous request-reply
I
I o Fire and forget
I I Synchr onous r equest - r epl y I
0 I n this "Consumer" sends t he request t o "Provider", and "Consumer" blocks until response
I
comes back f rom t he "Provider", Until response comes back "Consumer" can't proceed.
I
After Response
Received, conti nues
i t s process ......
Asvnchr onous reauest-re~l y
1
I
I
e In this "Consumer" sends the.request t o "Provider", and "Consumer" will not wait until it
'
gets the response. I
I > After request sent t o t he "Provider" it continues i ts flow of execution
I "Consumer" will have " Response Li st ener " which listens t he response f rom t he
"Provider". - i
I
Naresh i Technologies, Opp. Satyam Theatre, Ameerpet, Hyderabad, Ph: 040-23746666,23734842
An I S0 9001 : 2000 Certified Company
i
- - - - -
I
.-,
Page 9





I would try to update our site JavaEra.com everyday with various interesting
facts, scenarios and interview questions. Keep visiting regularly.....
Thanks and I wish all the readers all the best in the interviews.



www.JavaEra.com
A Perfect Place for All Java Resources