Sunday, 28 July 2013

HTML DOM



HTML DOM: 

 
The HTML DOM defines a standard way for accessing and manipulating HTML documents.
The DOM presents an HTML document as a tree-structure.


What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing HTML and XML documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
  • Core DOM - standard model for any structured document
  • XML DOM - standard model for XML documents
  • HTML DOM - standard model for HTML documents

What is the XML DOM?
The XML DOM defines the objects and properties of all XML elements, and the methods to access them.

What is the HTML DOM?
The HTML DOM is:
  • A standard object model for HTML
  • A standard programming interface for HTML
  • A W3C standard
The HTML DOM defines the objects and properties of all HTML elements, and the methods to access them.
In other words:
The HTML DOM is a standard for how to get, change, add, or delete HTML elements.
DOM Nodes
According to the W3C HTML DOM standard, everything in an HTML document is a node:
  • The entire document is a document node
  • Every HTML element is an element node
  • The text inside HTML elements are text nodes
  • Every HTML attribute is an attribute node
  • Comments are comment nodes
The HTML DOM Node Tree
The HTML DOM views HTML documents as tree structures. The structure is called a Node Tree:

Node Parents, Children, and Siblings
The nodes in the node tree have a hierarchical relationship to each other.
The terms parent, child, and sibling are used to describe the relationships. Parent nodes have children. Children on the same level are called siblings (brothers or sisters).
  • In a node tree, the top node is called the root
  • Every node has exactly one parent, except the root (which has no parent)
  • A node can have any number of children
  • Siblings are nodes with the same parent

The following image illustrates a part of the node tree and the relationship between the nodes:

Look at the following HTML fragment:
<html>
  <head>
    <title>DOM Tutorial</title>
  </head>
  <body>
    <h1>DOM Lesson one</h1>
    <p>Hello world!</p>
  </body>
</html>
From the HTML above:
  • The <html> node has no parent node; it is the root node
  • The parent node of the <head> and <body> nodes is the <html> node
  • The parent node of the "Hello world!" text node is the <p> node
and:
  • The <html> node has two child nodes: <head> and <body>
  • The <head> node has one child node: the <title> node
  • The <title> node also has one child node: the text node "DOM Tutorial"
  • The <h1> and <p> nodes are siblings and child nodes of <body>
and:
  • The <head> element is the first child of the <html> element
  • The <body> element is the last child of the <html> element
  • The <h1> element is the first child of the <body> element
  • The <p> element is the last child of the <body> element

JSP TAGS



JSP TAGS:


In this lesson we will learn about the various tags available in JSP with suitable examples. In JSP tags can be devided into 4 different types.
INTRODUCTION TO JSP TAGS
In this lesson we will learn about the various tags available in JSP with suitable examples. In JSP tags can be devided

    Directives

 In the directives we can import packages, define error handling pages or the session information of the JSP page.
General syntax for the page directive is

    <%@ page optional attribute ... %>

    Declarations

 This tag is used for defining the functions and variables to be used in the JSP.
Notation of the Declaration tag is shown below:
    <%!                    %>

     Scriplets

 In this tag we can insert any amount of valid java code and these codes are placed in _jspService method by the JSP engine.
<%!               
     statement1;
     statement2;      //Valid Java Code
     ..........;
%>                          //end of Scriptlet tag

    Expressions

We can use this tag to output any data on the generated page. These data are automatically converted to string and printed on the output stream.
<%!                  //start of declaration tag
     statement
       //Java Expression 
%>
                   //end of declaration tag 

    Action Tag:

Action tag is used to transfer the control between pages and is also used to enable the use of server side JavaBeans. Instead of using Java code, the programmer uses special JSP action tags to either link to a Java Bean set its properties, or get its properties.

General syntax of Action Tag:
    <jsp:action attributes />

<jsp:include page="{relativeURL | <%= expression %>}" flush="true" />

<jsp:include page="{relativeURL | <%= expression %>}" flush="true" />
 <jsp:param name="parameterName" value="{parameterValue | <%= expression %>}" />
 </jsp:include>


JSP Architecture



JSP Architecture


In this JSP tutorial, you will learn about JSP Architecture, page-centric approach, dispatcher approach and steps in execution of a JSP file.

JSP is a high-end technology that helps developers insert java code in HTML pages by making use of special JSP tags.

The JSP are HTML pages but do not automatically have .html as file extension. JSP files have .jsp as extension. The following steps takes place in execution of a JSP file.
  • JSP files are compiled by JSP engine into a servlet. This step creates the .jsp file as a Java servlet source file.
  • Once this is processed, the source file above is compiled into a class file.
  • The engine then makes use of the compiled servlet from the above process and executes requests.
Out of the two processes, the first two take time to produce a compiled servlet. This is performed only once unless modification in the source file is required. Once the compiled servlet is completed, the execution of requests is performed at a faster speed.

There are two methods for using JSP technology:
  • Page-Centric Approach
  • Dispatcher Approach
Page-Centric Approach:
The page-centric approach is also called Client-Server approach. The basic idea of Client-Server approach is that the application lies on the client side and services the requests connecting to the server application. JSP using this approach-processes as follows:
Client makes a request. The JSP page takes the request from client and processes it. The JSP have access to the database by using Java Beans. The requests are processed and the serviced results are sent back to client by JSP.

The above approach has the advantage of simplifying the process but its disadvantage is when the number of clients increases, the process becomes difficult to handle. 

Dispatcher Approach:
This is also called N-tier approach, where the server side of the above architecture is divided into multiple tiers, using JSP as a controller, passing requests to Java Beans.

JSP is popular because of its processing ability. Processing is distinctly divided between Presentation and Front Components. The popular JSP Architecture is the Model View Controller (MVC) model. In this MVC model, the request is sent by the browser to the controller or the servlet. This request is instantiated by the servlet as a Java Bean by JSP. The main aspect is JSP are compiled into servlets at the back end and the front end tasks are not interrupted. The servlet engine takes up the responsibility of compiling JSP Servlet and producing the final JSP servlet class for usage. The front end presentation modules are handled by JSP for viewing and the manipulation of data is handled by Java Bean and passed back to JSP when needed. The Presentation part of the MVC Model has no processing logic. It performs the task of extracting beans or objects that may have been initially created by the controller. It also extracts the dynamic content within for insertion within its static templates. The Application Manager in the MVC Model is the Controller that processes HTTP requests. They are not responsible for presentation tasks. That can be either servlets or JSP. They take the task of managing the application state, security, and presentation uniformity and thus, have a single point of entry.

This explains the approach and the process of execution of a request.

The following steps execute a JSP request from the time the request is received from client until it is processed and sent back to client. 

Step1:
Request from Client:
A JSP page has the extension as .jsp. The client request is made on the web browser by going to the .jsp extension JSP file. 

Step2:
Request Sent To Server:
The request received from client (web browser) is sent to the server side. 

Step3:
JSP Servlet Engine:
Since the extension of request made has .jsp extension, it indicates that it is a JSP file and therefore the web server passes the request received to the JSP Servlet Engine.

Step4:
Process of generating servlet:
JSP files are compiled by the JSP engine into a servlet. This step creates the .jsp file as a Java servlet source file.

Step5:
Process of making class file:
The source file from Step4 is compiled into a class file.

Step6:
Instantiation of Servlet:
The instantiation of servlet is performed using the init and service methods. In these methods, the jspInit() method is defined by the developer and the jspService method is generated by the JSP engine.

Step7:
Output HTML:
The request received from client is executed and the output is sent as HTML.

Step8:
Client Receives the Output:
The Client Receives the Output and thus the result namely the HTML gets displays in the client browser.

Friday, 19 July 2013

TCS New Question Pattern 2013

Recent Question Pattern of TCS Campus Placement 2013. It is the very first version we found.
The answers will be updated soon. And if there is any other questions let us know & if we have we’ll let you know.
  1. 1.   An empty tank be filled with an inlet pipe ‘A’ in 42 minutes. after 12 minutes an outlet pipe ‘B’ is opened which can empty the tank in 30 minutes. After 6 minutes another inlet pipe ‘C’ opened into the same tank, which can fill the tank in 35 minutes and the tank is filled find the time taken to fill the tank?       Ans

  1. 2.   A boy wants to make cuboids of dimension 5m,6m & 7m from small cubes of .03m^3.Later he realized that he can make some cuboids by making it hollow.Then it takes some cubes less.What is the number of cubes to be removed
a)2000 b)5000 c)3000 d)7000       Ans


  1. 3.   Leena cuts small cubes of 3 cubic cm each.She joined it to make a cuboid of length 10 cm,width 3cm, and depth 3 cm.How many more cubes does she need to make a perfect cube?
a)910 b)250 c)750 d)650        Ans


  1. 4.   What is the distance between the z-intercept from x-intercept in the eqn ax+by+cz+d=0       Ans

  1. 5.   10 men and 10 women are there.They dance with each other.Is there possibility that two men are dance with same girl and vice versa?
a)22 b)20 c)10 d)none of these       Ans

  1. 6.   A father purchases dress for his three daughter. The dresses are of same color but of different size .the dress is kept in dark room .What is the probability that all the three will not choose their own dress…
a)    2/3 b) 1/3 c) 1/6 d) 1/9     Ans

  1. 7.   Mr and Mrs smith had invited 9 of their friend and their spouses for party at wiki beachresort.the stand for group photograph if mr smith never stand next to mrs smith then how many way group arrange in row.
(A)20!(B)19!+18!(C)18*19!(D)2*19!  Ans

  1. 8.   Tim and Elan are 90 km from each other, they start to move each other simultaneously, Tim at speed 10 and Elan  5kmph, if every hour they double their speed what is the distance that Tim will pass until he meet Elan?
    (A)45(B)60(C)20(D)80  Ans

  1. 9.   MOTHER +DAUGHTER+INFANT AGE IS 74. MOTHER AGE IS 46 MORE THEN DAUGHTER AND INFANT.
AND INFANT AGE IS 0.4 OF DAUGHTER. FIND DAUGHTERS AGE.   Ans

  1. 10.                     The age of two people is in the ratio 6:8. the sum of their ages is 77. after 2 years the ratio of their ages becomes 5:7. wat is their present age?   

  1. 11.                     A Grocer bought 24 kg coffee beans at price X per kg. After a while one third of stock got spoiled so he sold the rest for $200 per kg and made a total profit of twice the cost. What must be the price of X?
    1. $33 1/3 B. 66 2/3 C.44 4/9 D.50 1/3   

  1. 12.                     Let exp(m,n) = m to the power n. If exp(10, m) = n exp(2, 2) where to and n are integers then n = ………………?   

  1. 13.                     Bhanu spends 30% of his income on petrol on scooter. ? of the remaining on house rent and the balance on food. If he spends Rs.300 on petrol then what is the expenditure on house rent?  

  1. 14.                     Directions for Q. 1 to Q. 5: Refer the data:
J, K, L, M and N collected stamps. They collected a total of 100 stamps. None of them collected less than 10.
No two among them collected the same number.
(i) 3 collected the same number as K and M together.
(ii) L collected 3 more than the cube of an integer
(iii) The no. collected by J was the square of an integer.
(iv) Total no. collected by K was either the square or cube of an integer.
1. The no. collected by J was:
(1) 27 (2) 49 (3) 36 (4) 64
2. The no. collected by K was:
(1) 16 (2) 27 (3) 25 (4) 36
3. The difference of numbers collected by L & M was:
(1) 3 (2) 2 (3) 5 (4) 9     


  1. 15.                     A,B COMMON TO ALL THREE. THEN AT LEAST 1 ELEMENT COMMON TO 2 IE X1,X2,X2,X3,X3,X1.
FIND MINIMUM ELEMENTS IN EACH GROUP.   Ans

  1. 16.                     How many kgs. of wheat costing Rs. 8 per kg must be mixed with 86 kg of rice costing Rs. 6.40 per kg so that 20% gain may be obtained by  Belling the mixture at Rs. 7.20 per kg ?   

  1. 17.                     The diagonal of a square is twice the side of equilateral triangle the ratio of Area of the Triangle to the Area of Square is?
a)    √3:8 b) √2:5 c) √3:6 d) √2:4 

  1. 18.                     Raj tossed 3 dices and there results are noted down then what is the probability that raj gets 10?
a)    1/72 b) 1/9 c) 25/216 d)1/8   

  1. 19.                     16 meters per minute and rest for 2 minutes. If take has to reach the top in exactly two hours. What is the maximum number of rests that he can take?
a)    41 b) 42 c) 40 d) 43   

  1. 20.                     length of minute hand is 5.4 cm, area covered by this in 10 min is ?
a)50.97 b)57.23 c)55.45 d)59.14     Ans


  1. 21.                     The climb from foot to top of a hill 800 meters, Jack can climb at 16 meters per minute and rests for two minutes or 20meters per 2 minutes and rest for one minute. Paul can climb at 10 meters per one minute and rest for one minute or16 meters per minute and rest for 2 minutes. If take has to reach the top in exactly two hours. What is the maximum number of rests that he can take?
a)    41 b) 42 c) 40 d) 43    

  1. 22.                     there r three buckets..of 8,5 n 3 litres…out of which only 8 ltr bucket is fully filled…u hv to fill exact 4-4 ltr liquid in 8 and 5 litre bucket by using only these buckets in minimm num of steps…..     


  1. 23.                     A number has exactly 3 prime factors, 125 factors of this number are perfect squares and 27 factors of this number are perfect cubes. overall how many factors does the number have???     


  1. 24.                      there are two boxes,one containing 39 red balls & the other containing 26 green balls.you are allowed to move the balls b/w the boxes so that when you choose a box random & a ball at random from the chosen box,the probability of getting a red ball is maximized.this maximum probability is
a)60 b)50 c)80 d)30    

  1. 25.                     A dog taken four leaps for every five leaps of hare but three leaps of the dog is equal to four leaps of the hare. Compare speed? 

  1. 26.                     The milk and water in two vessels A and B are in the ratio 4 : 3 and 2: 3 respectively. In what ratio, the liquids in both the vessels be mixed to obtain a new mixture in vessel C containing half milk and half water?    

  1. 27.                     In what ratio must water be mixed with milk to gain 20 % by selling the mixture at cost price?   

  1. 28.                     x=(sin nx/n)=?    

  1. 29.                     How much water must be added to 60 litres of mixture of milk?  1 ½ litres of milk for Rs. 20. So as to have a mixture worth Rs.10? a litre ?  

  1. 30.                     Find the no of zeros in the product of 1^1*2^2*3^3*…..*49^49?  

  1. 31.                     N is an integers and N>2 at most how many integers among N+2,N+4,N+5,N+6 and N+7 are prime integers?
a)    1 ,b)3 ,c)2, d)4    Ans

  1. 32.                     The sequence {A(n)} is defined by A(1)=2 and A(n+1)=A(n)+2n. What is the value of A(100).     Ans

  1. 33.                     n! has 13 zeros than what is the highest and lowest value of n??    Ans