Wednesday, 19 June 2013

OCEJWCD 6 Tutorial: The servlet’s environment

The OCEJWCD 6 is the new exam for Java EE web component developers. This tutorial explains “The servlet’s environment” exam topic in detail with code examples.
Disclaimer : The contents are taken from free resources available on web including Oracle site and Wikipedia.
Servlets communicate with web users over a request response pattern executed by the servlet container. HTTP protocol can process the request−response pattern. Servlet container is essentially a part of a web server that interacts with the servlets. The servlet container is used for managing other features of the servlet lifecycle.

This article shows how to communicate with Servlets. And also understand the HTTP protocols, HTML forms, HttpServlet, related APIs and sample program to manage client sessions and cookies.

Understand more details of the HTTP protocol

Hypertext Transfer Protocol is a stateless protocol. Generally this HTTP protocol is used to transfer the HTML and other information. Uniform Resource Locator (URL) is a universal address for the HTML documents and other resources. This HTTP is belongs to the application layer.
Initially the client creates a connection to HTTP server. The HTTP client sends a message based on the HTTP standard (HTTP Request) and then waits for the answer. Server answers in the form of HTTP response to the client. HTTP client read the response. Then close/release the connection from the server.

Example client request

Request Line:GET /images/help.jpg HTTP 1.1
Header:Connection : Keep-Alive
Referrer : http://localhost:8080/index.html
User-Agent : Mozilla/4.0
Host :
Content-Type : application/x-www-form-urlencoded
Content-Length : 28
Body : name=images&value=bar

Example server response

Status Line HTTP/1.1 200 OK
Header:Date : Mon, 10 June 2013 06:04:34 GMT
Server : Apache/2.4.4
Content-Type : text/html
Content-Length : 2456
Last-Modified : Mon, 10 June 2013 02:43:45 GMT
<header><title>Welcome Image</title>

Types of HTTP Request

Following HTTP types used for perform some actions
HEAD - requests header information.
GET - retrieves a single resource
POST – Send the client information to server.
PUT - Send a resource to be stored on the server.
DELETE - removes resource from specified URL.
TRACE - returns the entire network route from client to server and back.
OPTIONS - returns list of server's supported HTTP methods.
CONNECT - Converts the request connection to a transparent TCP/IP tunnel.
PATCH - Is used to apply partial modifications to a resource.

Understand fundamentals of HTML forms

HTML Page Structure

A HTML page has global structure. The html page has two main element: 1. head and 2. body.
The Head element has following major parts:

  • HEAD element, TITLE element and Meta data.
  • The body element has following major fields: Identification element (class, id), Grouping element (span, p), Header element (H1, h3, h4...)

Simple HTML document:

<TITLE>Welcome to Kate Java Tutorials</TITLE>
<P>Simple HTML page document.</p>

HTML Form:

HTML form has following control types: buttons, checkboxes, radio buttons, menus, text input, file select and object controls.
HTML form control element has following attributes: accept, accept-charset, action, enctype, method, name and target
HTML form input element has following attributes: type, name, value, size, maxlength, checked, src.

Sample HTML Form :

<FORM action="" method="post">
First name: <INPUT type="text" name="firstname"><BR>
Last name: <INPUT type="text" name="lastname"><BR>
email: <INPUT type="text" name="email"><BR>
<INPUT type="radio" name="sex" value="Male"> Male<BR>
<INPUT type="radio" name="sex" value="Female"> Female<BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">

Understand fundamentals of the HttpServlet and related APIs

The Servlet API consists of two packages: javax.servlet and javax.servlet.http. The base functionality is defined in the javax.servlet package whose classes and interfaces outline a generic, protocol-independent implementation.

Servlet API

  • javax.servlet
    • Support generic, protocol-independent servlets
    • Servlet (interface)
    • GenericServlet (class)
    • service()
    • ServletRequest and ServletResponse
    • Provide access to generic server requests and responses
  • javax.servlet.http
    • Extended to add HTTP-specific functionality
    • HttpServlet (extends GenericServlet )
    • doGet()
    • doPost()
    • HttpServletRequest and HttpServletResponse
    • Provide access to HTTP requests and responses

User-defined Servlets

  • Inherit from HttpServlet
    • Override doGet() and doPost()
  • To handle GET and POST requests
    • Have no main() method
HttpServlet must override at least one method, usually one of these:
doGet, if the servlet supports HTTP GET requests
doPost, for HTTP POST requests
doPut, for HTTP PUT requests
doDelete, for HTTP DELETE requests
init and destroy, to manage resources that are held for the life of the servlet
getServletInfo, which the servlet uses to provide information about itself

doGet() and doPost()

protected void doGet( HttpServletRequest req, HttpServletResponse resp)
protected void doPost(HttpServletRequest req, HttpServletResponse resp)

Sample HttpServlet

import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
PrintWriter out = res.getWriter();
out.println("<head><title>hello world</title></head>");
out.println("<big>hello world</big>");

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
doGet(req, res);

Servlet related APIs

For more information refer following documents

Write code that manages client sessions and cookies

For more information on manages client sessions and cookies and example, see

Commercial Exam Simulator for OCEJWCD 6 Certification

EPractize Labs’s OCEJWCD 6 Training Lab

Thursday, 6 June 2013

OCEJWCD ( SCWCD 6) Web Component Developer Certification Exam

The web component developer certification for Java EE is hotter than other exams. Oracle offers two certifications for web component developers one for Java EE 5 and another one for Java EE 6.

Read the full article here.

Friday, 31 May 2013

OCEJWCD 6 Tutorial: Introduction to JavaServer Pages (JSP)

The 1Z0-899 Java EE 6 Web Component Developer Certified Expert Exam focus more on business tier components.  This tutorial is one of the certification exam topics which gives attention into JavaServer Pages (JSP). 

Read the full articleOCEJWCD 6 Tutorial: Introduction to JavaServer Pages (JSP)

Wednesday, 22 May 2013

OCEJWCD 6 Tutorials: Introduction to Java Servlets

This tutorial is one of the certification exam topics which gives attention into Java Servlet Technology . This will help your preparation to pass the 1Z0-899 Java EE 6 Web Component Developer Certified Expert Exam.

Servlet is a Java class that supplies compatible mechanism used to extend the ability of a Web-server that can support dynamic content generation. A servlet can almost be considered an applet that runs on the server side. Servlet provides a platform-independent methods to build Web-based applications. Servlets is a highly efficient CGI programs written in Java. When a Servlet-capable Web server receives a request for a URL that corresponds to a Java Servlet, the server hands the request off to the Servlet for processing. The Servlet dynamically produces a response to the request (typically an HTML Web page) and sends it back to the requesting browser.

Describe web applications, CGI, and the role of Java

Java Web application:

Web application is an computer application which is then deployed on the web server, the user can access that application via the Internet or an intranet using a browser. Java has strong support for building web applications using Java Enterprise technology. A Java web application is a collection of  HTML pages, XML files, webservices, servlets, JSPs Java classes and jars to create dynamic web project.

Java CGI - Common Gateway Interface:

CGI is a scripts to receive the request and generate a response for transferring dynamic information between server and client. A CGI program can be written in any language, including Java, that can be executed by your Web server. CGI programs are commonly used to add search engines, guest-book applications, database-query engines, interactive-user forums, and other interactive applications to Web sites. Most of the input to a CGI program is passed into it through environment variables.

Role of Java:

Following different roles are divided based on the Servlet performance. Receive the explicit data sent by the client, receive the implicit HTTP request data sent by the browser, Generate the results, Dispatch the explicit information to the client and Dispatch the implicit HTTP response data.

Describe benefits of Java servlet technology

The advantages of using servlets is their fast performance and ease of use combined with more power over traditional CGI (Common Gateway Interface). Traditional CGI scripts written in Java have a number of disadvantages when it comes to performance: When a HTTP request is made, a new process is created for each call of the CGI script. This overhead of process creation can be very system-intensive, especially when the script does relatively fast operations. Thus, process creation will take more time than CGI script execution. Java servlets solve this, as a servlet is not a separate process. Each request to be handled by a servlet is handled by a separate Java thread within the Web server process, omitting separate process forking by the HTTP daemon.

Simultaneous CGI request causes the CGI script to be copied and loaded into memory as many times as there are requests. However, with servlets, there are the same amount of threads as requests, but there will only be one copy of the servlet class created in memory that stays there also between requests.

The Web container calls the init()method. This method initializes the servlet and must be called before life of a servlet, the init()method is called only once.

After initialization, the servlet can service client requests. Each requestis serviced in its own separate thread. The Web container calls the service() method of the servlet for every request. The service()method determines the kind of request being made and dispatches it to an appropriate method to handle the request. The developer of the servlet must provide an implementation for these methods. If a request for a method that is not implemented by the servlet is made, the method of the parent class is called, typically resulting in an error being returned to the requester.
Finally, the Web container calls the destroy() method that takes the servlet out of service. The destroy() method, like init(), is called only once in the lifecycle of a servlet.

Create a simple Java Servlet

public class MyServlet extends HttpServlet {
    public void doGet (HttpServletRequest req, HttpServletResponse res) {

Deployment descriptor (web.xml)



Define three-tier architecture

3-Tier client-server architectures have 3 essential components:

  1. A Client PC 
  2. An Application Server 
  3. A Database Server

3-Tier Architecture Considerations: 

  • Client program contains presentation logic only 
  • Less resources needed for client workstation 
  • No client modification if database location changes 
  • Less code to distribute to client workstations 
  • One server handles many client requests 
  • More resources available for server program 
  • Reduces data traffic on the network

Define Model-View-Controller (MVC) architecture

One of the most common Design Patterns is Model-View-Controller (MVC). The model does all the computational work. It is input/output free. All communication with the model is via methods. The controller tells the model what to do. User input goes to the controller. The view shows results; it is a “window” into the model. The view can get results from the controller, or The view can get results directly from the model

The model, as usual, does all the computational work, and no Input / Output. The model can consist of multiple classes. The servlet class (the one that extends HttpServlet) acts as the controller. The servlet gives any relevant information from the user request to the model. The servlet takes the results and passes them on to the view. The view—that is, the HTML page that is returned to the user—is frequently created by JSP.

Model: The domain-specific representation of the information on which the application operates. The model is another name for the application logic layer (sometimes also called the domain layer). Application (or domain)logic adds meaning to raw data (e.g., calculating iftoday is the user’s birthday, or the totals, taxes and shipping charges for shopping cart items). Many applications use a persistent storage mechanism (such as a database) to store data. MVC does not specifically mention the resource management layer because it is understood to be underneath or encapsulated by the Model.

View: Renders the model into a form suitable for interaction, typically a user interface element. MVC is often seen in web applications, where the view is the HTML page and the code which gathers dynamic data for the page.

Controller: Processes and responds to events, typically user actions, and may invoke changes on the model and view

Saturday, 18 May 2013

Best Oracle Java Certification & Training

The most extensive honoured IT certification programs available through Oracle Certifications bring valuable, measurable rewards to Java associate, professionals, master and expert their careers. In this article, we will guide you about Oracle certifications for Java Java programming language and technology. Also it will enhance your basic knowledge and teach you how to get started.

Here some of the impotent guidelines and notes for the who attend the training and who want become certified in Java Programming Technologies.

Why Java Certification & Training

The main reasons for Java Certification & Training is employee skills not matched to coming demand for jobs. There are six major industries IT, Education, Financial services, Business services and Heath services will provide the job for the programmers. So most of the industries will require post-secondary education and training. The real battle for the skill was started for the employee.

Technical changes will create demand for the candidates highly educated and certified in developing Rich user interface, application performance and security, web applications, mobile and other embedded devices.
So certification gives the job seekers with additional qualification and having better changes of being employed. Which means holding the Oracle certification would improve their employment opportunities.

Oracle Java Training Overview

Java training classes - including Java SE 7 lessons - that can help get beginners up to speed on Java and help experienced users become experts in Java.

Training for Java SE Application Development 

This section will guide you to OOPs principles and the Java Programming language, so you can code smarter and develop programs more quickly. Following area must you should need to be familiar.
  • Java SE 7 New Features 
  • Java SE 7 Fundamentals 
  • Java SE 7 Programming 
  • Java Performance Tuning and Optimization 
  • Developing Applications With the Java SE 6 Platform 
  • Object-Oriented Analysis and Design Using UML

Training for Enterprise Development with Java EE 

This level was designed to get you going with enterprise application development and help you become an expert on core Java EE technologies including Enterprise JavaBeans (EJB), Java Persistence API (JPA), Web Services, JavaServer Faces (JSF), JavaServer Pages (JSP).
  • Developing Applications for the Java EE 6 Platform 
  • Web Component Development with Servlets & JSPs, Java EE 6 Developing 
  • Web Applications using JSF Technologies 
  • Business Component Development with EJB Technology, Java EE 6 
  • Building Database Driven Applications with JPA 
  • Developing Web Services Using Java Technology, Java EE 6 
  • Architect Enterprise Applications with Java EE

Oracle Java Certification

Oracle certifications exams and brings you the recognition for your knowledge and skills in developing Rich user interface, application performance and security, web applications, mobile and other embedded devices. Following certification are currently available.

Oracle Entry level and Associate level certification 

  1. Oracle Certified Associate, Java SE 7 Programmer. 
  2. Oracle Certified Associate, Java SE 5/SE 6.

Oracle Professional level certification 

  1. Oracle Certified Professional, Java SE 5 Programmer 
  2. Oracle Certified Professional, Java SE 6 Programmer 
  3. Oracle Certified Professional, Java SE 7 Programmer 
  4. Oracle Certified Professional, Java EE 5 Web Component Developer 
  5. Oracle Certified Professional, Java EE 5 Web Services Developer 
  6. Oracle Certified Professional, Java EE 5 Business Component Developer 
  7. Oracle Certified Professional, Java ME 1 Mobile Application Developer

Oracle Master level certification 

  1. Oracle Certified Master, Java SE 6 Developer 
  2. Oracle Certified Master, Java EE 5 Enterprise Architect 
  3. Oracle Certified Master, Java EE 6 Enterprise Architect

Oracle Expert level certification 

  1. Oracle Certified Master, Java SE 6 Developer 
  2. Oracle Certified Master, Java EE 5 Enterprise Architect 
  3. Oracle Certified Master, Java EE 6 Enterprise Architect

Practice Exams for Oracle Java certification

Practice tests are one of the most effective ways candidates can prepare for Oracle certification exams. Before candidates attend the exams we must test their knowledge. So that's the only way they can know their weakness, How much they can score the marks on the examination. That’s why we need the practice exam.

I would prefer for my training and teaching, Epractize labs Java Certification mock exams really help candidates to self-assess their knowledge using realistic exam simulations. This training lab built on practice exam tools including: Basic and Advanced Session (knowledge level practice exam preferences), Certification Session (Prepare and got real time experience thing with simulated exams) and Quiz Mode (self check in the form of game or mind sport). And also EPractize Labs provide all Oracle certification with industrial standard.

Good luck and Be more competitive in the Job market