This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

CSS Drop Down Menu

Wednesday, 18 June 2014

AEM/CQ5 Guide Architect

Wednesday, 11 June 2014

AEM/CQ5 WCM Developer's Guide

Thursday, 8 May 2014

AEM/CQ5:User Guide

Saturday, 3 May 2014

AEM:Architecture

Sunday, 27 April 2014

AEM/CQ5.6.1:Introduction

Tuesday, 25 March 2014

Searching:Linear Search

Monday, 24 March 2014

WS:Introduction

Fig: Service Using Without WebService
Fig: WebService[Cross PlateForm Client-Server Communication]
Fig: Client-UDDI-End_Point_Service_Location

Importatnt Elements Of WSDL:-

There are five main elements of WSDL(wiz-dull) file which are given below:-
1-Service
2-Binding
3-Port Type
4-Message
5-Types
Fig:- High Level Architecture: WSDL
Here ,Sample of WSDL file is given below and also each main elements has been explained:-

1:-service

2:-bindings

3:-portType

4:-message

5:-types

Monday, 17 March 2014

Heap Sort

Fig : Heap Sort

Merge Sort

Fig:Merge Sort

Quick Sort

Fig :Quick Sort

Insertion sort

Fig : Insertion sort

Selection Sort

In selection sorting algorithm,
1: Find the minimum value in the array then swap it first position.
2: In next step leave the first value and find the minimum value within remaining values.
3: Then swap it with the value of minimum index position. Sort the remaining values by using same steps. Selection sort is probably the most intuitive sorting algorithm to invent.
The complexity of selection sort algorithm is in worst-case, average-case, and best-case run-time of Θ(n2), assuming that comparisons can be done in constant time.
Fig:- Selection Sort
Selection sort animation.Red is current min. Yellow is sorted list. Blueis current item.
Code description:
In selection sort algorithm to find the minimum value in the array. First assign minimum index in key (index_of_min=x). Then find the minimum value and assign the index of minimum value in key (index_of_min=y). Then swap the minimum value with the value of minimum index.
At next iteration leave the value of minimum index position and sort the remaining values by following same steps.
Working of the selection sort :
Say we have an array unsorted A[0],A[1],A[2]................ A[n-1] and A[n] as input. Then the following steps are followed by selection sort algorithm to sort the values of an array . (Say we have a key index_of_min that indicate the position of minimum value)
1.Initaily varaible index_of_min=0;
2.Find the minimum value in the unsorted array.
3.Assign the index of the minimum value into index_of_min variable.
4.Swap minimum value to first position.
5.Sort the remaining values of array (excluding the first value).

Wednesday, 12 March 2014

HCF(GCD) and LCM

Tuesday, 11 March 2014

Pascal Triangle

In mathematics, Pascal's triangle is a triangular array of the binomial coefficients.The rows of Pascal's triangle are conventionally enumerated starting with row n = 0 at the top. The entries in each row are numbered from the left beginning with k = 0 and are usually staggered relative to the numbers in the adjacent rows.
Note:-A simple construction of the triangle proceeds in the following manner. On row 0, write only the number 1. Then, to construct the elements of following rows, add the number above and to the left with the number above and to the right to find the new value. If either the number to the right or left is not present, substitute a zero in its place. For example, the first number in the first row is 0 + 1 = 1, whereas the numbers 1 and 3 in the third row are added to produce the number 4 in the fourth row as below:-

Thursday, 20 February 2014

Filter

A filter dynamically intercepts requests and responses to transform or use the information contained in the requests or responses. Filters typically do not themselves create responses, but instead provide universal functions that can be "attached" to any type of servlet or JSP page.
In Other words , A filter is an object that is used to perform filtering tasks such as conversion, log maintain, compression, encryption and decryption, input validation etc.
A filter is invoked at the preprocessing and postprocessing of a request. It is pluggable, i.e. its entry is defined in the web.xml file, if we remove the entry of filter from the web.xml file, filter will be removed automatically and we don't need to change the servlet. So it will be easier to maintain the web application.

Usage of Filter:-

Filters are used for different functions as below:-
1-Authentication-Blocking- requests based on user identity.
2-Logging and auditing-Tracking users of a web application
3- Image conversion-Scaling maps, and so on.
4- Data compression-Making downloads smaller.
5- Localization-Targeting the request and response to a particular locale
6- XSL/T transformations of XML content-Targeting web application responses to more that one type of client.
7- to encapsulate recurring tasks in reusable units
8- encryption and decryption
9- mime-type chaining, and caching

Difference Between Servlet And Filter:-

FilterServlet
1-Filter is used for filtering the request and perform some action like authenticity of session, user is valid or not for that request, etc.
1-Servlet is used for performing the action which needs to be taken for particular request like user login, get the response based on user role, interacts with database for getting the data, business logic execution etc
2-Filters differ from web components in that filters usually do not themselves create a response.
2-Servlet technology is used to create web application where it creates response of client’s request themselves.
3- For authorization, a Filter is the best suited This is because they can be configured to run for all pages of a site. So you only need one filter to protect all your pages.
3-Not as much as comparison to Filter.

Note:-

Authentication is the process of determining whether someone or something is, in fact, who or what it is declared to be. In private and public computer networks (including the Internet), authentication is commonly done through the use of logon passwords.
Authorization is the function of specifying access rights to resources, which is related to information security and computer security in general and to access control in particular.

Filter API

Like servlet filter have its own API.The javax.servlet package contains the three interfaces of Filter API
1. Filter
2. FilterChain
3.FilterConfig

How It works:-

1-When You define a filter by implementing the Filter interface. A filter chain, passed to a filter by the container, provides a mechanism for invoking a series of filters. A filter config contains initialization data.
2-The most important method in the Filter interface is the doFilter method, which is the heart of the filter. This method usually performs some of the following actions:-
[a]-Examines the request headers
[b]-Customizes the request object if it wishes to modify request headers or data or block the request entirely
[c]-Customizes the response object if it wishes to modify response headers or data
[d]-Invokes the next entity in the filter chain. If the current filter is the last filter in the chain that ends with the target servlet, the next entity is the resource at the end of the chain; otherwise, it is the next filter that was configured. It invokes the next entity by calling the doFilter method on the chain object (passing in the request and response it was called with, or the wrapped versions it may have created). Alternatively, it can choose to block the request by not making the call to invoke the next entity. In the latter case, the filter is responsible for filling out the response.
[e]-Examines response headers after it has invoked the next filter in the chain
[f]-Throws an exception to indicate an error in processing

Note:-

In addition to doFilter, you must implement the init and destroy methods. The init method is called by the container when the filter is instantiated. If you wish to pass initialization parameters to the filter you retrieve them from the FilterConfig object passed to init.

Tuesday, 11 February 2014

Servlet:Life Cycle

Life Cycle Of Servlet

Web container maintains the life cycle of the Servlet.
1-Servlet classes are loaded
2-init method is invoked.
3-service method is invoked.
4-destroy method is invoked.

Life Cycle in Detail:-

1-When a server loads a servlet, it runs the servlet's init method. Even though most servlets are run in multi-threaded servers, there are no concurrency issues during servlet initialization. This is because the server calls the init method once, when it loads the servlet, and will not call it again unless it is reloading the servlet. The server can not reload a servlet until after it has removed the servlet by calling the destroy method. Initialization is allowed to complete before client requests are handled (that is, before the service method is called) or the servlet is destroyed.
2-After the server loads and initializes the servlet, the servlet is able to handle client requests. It processes them in its service method. Each client's request has its call to the service method run in its own servlet thread: the method receives the client's request, and sends the client its response.
3-Servlets can run multiple service methods at a time. It is important, therefore, that service methods be written in a thread-safe manner. If, for some reason, a server should not run multiple service methods concurrently, the servlet should implement the SingleThreadModel interface. This interface guarantees that no two threads will execute the servlet's service methods concurrently.
4-Servlets run until they are removed from the service. When a server removes a servlet, it runs the servlet's destroy method. The method is run once; the server will not run it again until after it reloads and reinitializes the servlet.
5-When the destroy method runs, however, other threads might be running service requests. If, in cleaning up, it is necessary to access shared resources, that access should be synchronized. During a servlet's lifecycle, it is important to write thread-safe code for destroying the servlet and, unless the servlet implements the SingleThreadModel interface, servicing client requests.

Steps to create Servlet Without Using any IDE:-

1- First of All Create the project folder structure as given below in Image. Here, we can put any name (project name) in place of web-app(context root).
2-Now , Create servlet class and keep inside the Classes folder.Here created SampleHello.java as Below:-
3- Now ,Create a welcome file ,Here Created index.jsp as below:-
4- Now Configure web.xml ,as given below:-
5- Now ,compile the servlet class what you have created here is SampleHello.java using command prompt for compilation of class as below:-
javac –d “dir_of_servletclass_if_not_in_same_dir” –cp “path_of_jar; You_can_add_another_jar_also_after_putting_semicolon” classname.java
since,Here I am in same directory of servlet class so-
javac –cp “D:\customtagjsp\servlet-api-2.5-6.1.5.jar” SampleHello.java
6-Now can see the .class file after compilation,Put it inside the classes folder of project structure and put projectfolder in side the webapps folder of Tomcat server of any version.
Here I am using apache-tomcat-7.0.47, D:\apache-tomcat-7.0.47\webapps\projectfolder
7-Run the server and then run the project as below:- http://localhost:8080/samplehello/ Now we can see the output as below:-




after submitting the form:-

Monday, 10 February 2014

Servlet:Introduction and Architecture Overview

What is Servlet??

A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed by means of a request-response programming model. For such applications, Java Servlet technology defines HTTP-specific servlet classees. The javax.servlet and javax.servlet.http packages provide interfaces and classes for writing servlets. All servlets must implement the Servlet interface, which defines lifecycle methods. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.
Java Servlets often serve the same purpose as programs implemented using the Common Gateway Interface (CGI) script. But Servlets offer several advantages in comparison with the CGI.

Advantages Of Servlet Over CGI:-

Initially, Common Gateway Interface (CGI) server-side scripts were the main technology used to generate dynamic content. Although widely used, CGI scripting technology had many shortcomings, including platform dependence and lack of scalability. CGI Technology enables webserver to call an external program and pass Http request information to external program to process the request .For Each request , it starts with new Process. To address these limitations, Java Servlet technology was created as a portable way to provide dynamic, user-oriented content.
In case of servlet. The web container create threads for handling the multiple request to the servlet.since threads have a lots of benefits over process. For more information about thread and process click here

Some Example Applications where servlets could be used:-

1-A few of the many applications for servlets include,Processing data POSTed over HTTPS using an HTML form, including purchase order or credit card data. A servlet like this could be part of an order-entry and processing system, working with product and inventory databases, and perhaps an on-line payment system.
2-Allowing collaboration between people. A servlet can handle multiple requests concurrently; they can synchronize requests to support systems such as on-line conferencing.
3- Forwarding requests. Servlets can forward requests to other servers and servlets. This allows them to be used to balance load among several servers that mirror the same content. It also allows them to be used to partition a single logical service over several servers, according to task type or organizational boundaries.

Architecture Overview:-

All servlets must implement the Servlet interface, which defines lifecycle methods. When implementing a generic service, you can use or extend the GenericServlet class provided with the Java Servlet API. The HttpServlet class provides methods, such as doGet and doPost, for handling HTTP-specific services.You can be clear by given below image:-
The Servlet interface provides the following methods that manage the servlet and its communications with clients.
1- destroy() Cleans up whatever resources are being held and makes sure that any persistent state is synchronized with the servlet's current in-memory state.
2- getServletConfig() Returns a servlet config object, which contains any initialization parameters and startup configuration for this servlet.
3- getServletInfo() Returns a string containing information about the servlet, such as its author, version, and copyright.
4- init(ServletConfig) Initializes the servlet. Run once before any requests can be serviced.
5- service(ServletRequest, ServletResponse) Carries out a single request from the client.
Servlet writers provide some or all of these methods when developing a servlet.

How Servlet Works:-

1-When a servlet accepts a service call from a client, it receives two objects, ServletRequest and ServletResponse. The ServletRequest class encapsulates the communication from the client to the server, while the ServletResponse class encapsulates the communication from the servlet back to the client.
2-The ServletRequest interface allows the servlet access to information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received it. It also provides the servlet with access to the input stream, ServletInputStream, through which the servlet gets data from clients that are using application protocols such as the HTTP POST and PUT methods. Subclasses of ServletRequest allow the servlet to retrieve more protocol-specific data. For example, HttpServletRequest contains methods for accessing HTTP-specific header information.
3-The ServletResponse interface gives the servlet methods for replying to the client. It allows the servlet to set the content length and mime type of the reply, and provides an output stream, ServletOutputStream, and a Writer through which the servlet can send the reply data. Subclasses of ServletResponse give the servlet more protocol-specific capabilities. For example, HttpServletResponse contains methods that allow the servlet to manipulate HTTP-specific header information.
The classes and interfaces described above make up a basic Servlet. HTTP servlets have some additional objects that provide session-tracking capabilities. The servlet writer can use these APIs to maintain state between the servlet and the client that persists across multiple connections during some time period.

Servlet API

Two packages:
1-javax.servlet-represents interfaces and classes for the Servlet API.This is not specific for any protocol.
2-javax.servlet.http -represents interfaces and classes for the Servlet API.But this is specific for only http request .

Servlet API Package as per jdk1.6

javax.servlet package:--

The javax.servlet package contains a number of classes and interfaces that describe and define the contracts between a servlet class and the runtime environment provided for an instance of such a class by a conforming servlet container.
Interface
AsyncContext
AsyncListener
Filter
FilterChain
FilterConfig
RequestDispatcher
Servlet
ServletConfig
ServletContext
ServletRequest
ServletResponse
Class
GenericServlet
ServletContextEvent
ServletInputStream
ServletOutputStream
ServletRequestAttributeEvent
ServletRequestWrapper
ServletSecurityElement

javax.servlet.http package:--

Interface
HttpServletRequest
HttpServletResponse
HttpSession
HttpSessionAttributeListener
HttpSessionContext
Class
Cookie
HttpServlet
HttpServletRequestWrapper
HttpServletResponseWrapper
HttpSessionBindingEvent
HttpSessionEvent

Sunday, 9 February 2014

JSP:Custom Tags

Custom Tags:-

A custom tag is a user-defined JSP language element. When a JSP page containing a custom tag is translated into a servlet, the tag is converted to operations on an object called a tag handler. The Web container then invokes those operations when the JSP page's servlet is executed.
Advantages of Custom Tags:-
1-Elimenates the need of scriptlate tags which is considered as bad programming approach.

2-Sepeartion of business logic from the jsp so tat it may be easy to maintain.

3-Reusability:-It makes the possibility to make reusability of business logic.

Syntax of Custom Tag:-

There are two ways to use the custom tags:-

1-

2-

Example Of Custom Tag:-

For creating the Custom Tag,We need to follow the following steps:-
1:- Create The tag Handler Class and perform action at the start or at end of tag.
2-Create The tag library descriptor file and define tags
3-Create the JSP file that uses the Custom Tag defined in TLD file.
1:- Create a dynamic project in your IDE(Here I am using Spring Tool Suite™) you can use eclipse or any IDEBut in case of Eclipse you will have to add jsp-api 2.0 jar
The JSP 2.0 specification introduced Simple Tag Handlers for writing these custom tags. To write a customer tab you can simply extend SimpleTagSupport class and override the doTag() method, where you can place your code to generate content for the tag.
2:- Create The tag Handler Class and perform action at the start or at end of tag--
here we create the MyTagHandler.java as given below

3-Now Create tag library file

here we create mytags.tld and put inside the following as mentioned below:- directory Dyanamic_Project_Name\WebContent\WEB-INF\mytags.tld


4-Create the JSP file that uses the Custom Tag defined in TLD file.Here we create index.jsp and in web.xml set as welcome page as given below

1:-web.xml:-



2:-index.jsp:-



Here prefix I have taken as prefix="Sample" and taglib uri="WEB-INF/mytags.tld"
when I run this dynamic project will get the value what tried to print like here will print Hello Custom Tag.
created custom tag without body content like fashion.

Note:-

Spring Tool Suite™ is an Eclipse-based development environment that is customized for developing Spring applications. It provides a ready-to-use environment to implement, debug, run, and deploy your Spring applications, including integrations for Pivotal tc Server, Pivotal Cloud Foundry, Git, Maven, AspectJ, and comes on top of the latest Eclipse releases.It is freely available for development and internal business operations use with no time limits, fully open-source and licensed under the terms of the Eclipse Public License.

Sunday, 26 January 2014

Hibernate : Core Concept

Note:-

This tutorial expects the user have knowledge of both Java and SQL. If you have a limited knowledge of JAVA or SQL, it is advised that

you start with a good introduction to that technology prior to attempting to learn Hibernate.

Hibernate Framework

Hibernate framework simplifies the development of java application to interact with the database. Hibernate is an open source,

lightweight, ORM (Object Relational Mapping) tool. An ORM tool simplifies the data creation, data manipulation and data access. It is a

programming technique that maps the object to the data stored in the database.
Java Application ---- object----ORM----Database


The ORM tool internally uses the JDBC API to interact with the database.

Advantages of Hibernate Framework:-
There are many advantages of Hibernate Framework. They are as follows:

1)Opensource and Lightweight: Hibernate framework is opensource under the LGPL license. The open source GNU
LGPL
(Lesser General Public License) is sufficiently flexible to allow the use of Hibernate in both open source and commercial projects.

2) Fast performance: The performance of hibernate framework is fast because cache is internally used in hibernate framework.
There are two types of cache in hibernate framework first level cache and second level cache. First level cache is
enabled bydefault.

3) Database Independent query: HQL (Hibernate Query Language) is the object-oriented version of SQL. It generates the database
independent queries. So you don't need to write database specific queries. Before Hibernate, If database is changed for the project,
we need to change the SQL query as well that leads to the maintenance problem.

4) Automatic table creation: Hibernate framework provides the facility to create the tables of the database automatically. So there is
no need to create tables in the database manually.

5) Simplifies complex join: To fetch data form multiple tables is easy in hibernate framework.

6) Provides query statistics and
database status:
Hibernate supports Query cache and provide statistics about query and database status.

Hibernate Architecture:-

The Hibernate architecture includes many objects persistent object, session factory, transaction factory, connection factory, session,
transaction etc.

There are 4 layers in hibernate architecutre java application layer, hibernate framework layer, backhand api layer and database layer.
The high level architecture of Hibernate with mapping file and configuration file.

Hibernate framework uses many objects session factory, session, transaction etc. alongwith existing Java API such as JDBC
(Java Database Connectivity), JTA (Java Transaction API) and JNDI (Java Naming Directory Interface).

Core Object Of Hibernate:-

1-SessionFactory

2-Session

3-Transaction

4-ConnectionProvider

5-TransactionFactory

SessionFactory

The SessionFactory is a factory of session and client of ConnectionProvider. It holds second level cache.(optional) of data

. The org.hibernate.SessionFactory interface provides factory method to get the object of Session. You configure Hibernate's

SessionFactory. SessionFactory is a global factory responsible for a particular database. If you have several databases, for easier

startup you should use several configurations in several configuration files.

Session

The session object provides an interface between the application and data stored in the database. It is a short-lived object and wraps

the JDBC connection. It is factory of Transaction, Query and Criteria. It holds a first-level cache (mandatory) of data. The

org.hibernate.Session interface provides methods to insert, update and delete the object. It also provides factory methods for

Transaction, Query and Criteria.

Transaction

The transaction object specifies the atomic unit of work. It is optional. The org.hibernate.Transaction interface provides methods for

transaction management.

ConnectionProvider

It is a factory of JDBC connections. It abstracts the application from DriverManager or DataSource. It is optional.

TransactionFactory

It is a factory of Transaction. It is optional.

Steps to create A sample Example Of Hibernate (Without Using Annotation):-

Software requirement:-

1-Jdk 1.6 2-Eclipse Any Updated Version(I have Used here Eclipse Helios 3.6) 3-Hibernate Library 4-MySql DataBase

Step-1:-

First Download the hibernate jar from http://sourceforge.net/projects/hibernate/files/hibernate3/ Set it to Java build classpath (If You

Are Using the Eclipse.):-as Sample Project->right click->Properties->Java Bulid Path->Libraries->Add External JARs->ok.

Steps- 2:-

Now Create Entity Class (The Class which contains data,meta data which is to stored in to database Here )Here UserDetails.java which Is given below:-

Step 3:-

Now Create UserDetails.hbm.xml file where we configured data ,metadata attributes name of Table name where our data has to be stored in database. As given belows. This file should be in classpath or in side the src folder:-

Step 4:-

Now Create An Schema in MySql database(since here I am using MySql database), Here I have created hibernatesample schema.

Step 5:-

Now Create a Configuration File hibernate.cfg.xml, where I have configured database configuration and mapping file UserDetails.hbm.xml. which is given below:-

Step 6:-

Now create the main class For Hibernate like given below:-
Now Run The main Class of Hibernate.java as here is HibernateTest.java Then Check the schema Definatly You will find Datas stored in Schema configured in .cfg file.

Steps to create A sample Example Of Hibernate (Using Annotation):-

Software requirement:-

1-Jdk 1.6 2-Eclipse Any Updated Version(I have Used here Eclipse Helios 3.6) 3-Hibernate Library 4-MySql DataBase

Step-1:-

First Download the hibernate jar from http://sourceforge.net/projects/hibernate/files/hibernate3/ Set it to Java build classpath (If You

Are Using the Eclipse.):-as Sample Project->right click->Properties->Java Bulid Path->Libraries->Add External JARs->ok.

Steps- 2:-

Now Create Entity Class (The Class which contains data,meta data which is to stored in to database Here )Here UserDetails.java which Is given below:-

Step 3:-

Now Create An Schema in MySql database, Here I have created hibernatesample schema:-

Step 4:-

Now Create a Configuration File hibernate.cfg.xml, where I have configured database configuration and mapping file UserDetails.java which is given below. This file should be in classpath or in side the src folder:--

Step 5:-

Now create the main class For Hibernate like given below:-
Now Run The main Class of Hibernate.java as here is HibernateTest.java Then Check the schema Definatly You will find Datas stored in Schema configured in .cfg file.

Thursday, 23 January 2014

Checking the palindrome Of An given Integer/Reverse Integer

Copy the Text from one To another which file path given by command line argument

Find the file with Special Extension from Folder

Find Unique And Frequent words of Input any file

Find IP address And garbage Collection

For Grabage Collection:-

For IP Address:-

Sorting : Buble Sort

Bubble sort is a sorting algorithm that works by repeatedly stepping through lists that need to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. This passing procedure is repeated until no swaps are required, indicating that the list is sorted. Bubble sort gets its name because smaller elements bubble toward the top of the list.

Bubble Sort

Bubble sort is also referred to as sinking sort or comparison sort. Bubble sort has a worst-case and average complexity of O(n2), where n is the number of items sorted. Unlike the other sorting algorithms, bubble sort detects whether the sorted list is efficiently built into the algorithm. Bubble sort performance over an already sorted list is O(n).

Binary Tree ,Depth and Height

Step [1]:-

First Create Binary Tree class here is TreeNode.java which is given below:-

Step [2]:-

Create A class for all Its Methods like PreOrder,PostOrder,InOrder Traversal ,Depth and Height.Here class name is BinaryTreeMethods.java which is given below:-

Step [3]:-Now Create Main class For the Tree As below:-

LinkedList

Step [1]:-Create Node to create linked list as below:-

Step [2]:-Now create to All Methods of Linked List:-

Step [3]:-Now Create the mainClass to create LinkedList as Below:-

Transpose of Matrix

With help of Tranpose of Matrix we can also find out about the matrix whether it is symmetric or not . i.e. If Tranpose of matrix is equal to the matrix then Matrix is Called as Symmetric.

Multiplication Of Two Matrix

Addition Of Two Matrix

Print all Substring of Input

Check and Prime Number and Also Print The Prime Number

Fibonacci Series

Comparision of Two String

Reverse String And Checking the Palindrom

Floyed’s Triangle

Armstrong Number

Find Factorial of Input Number