You are on page 1of 17

WEB PROGRAMMING PART A 5x5 - 25 Marks 1) What is Web? Explain GET and POST methods.

. A:- WEB:- The web is a complex, international, cross platform, cross language, cross cultural mesh of servers, clients, users, databases, and quite a few artificial intelligences all talking, working, searching, viewing, accessing, downloading, and who knows what else. Web is not a thing, but as a process, an action, a medium of communication (fig on page 2). GET method:- The foundation of HTTP/0.9 (the first implementation of the HTTP protocol) was thee defination of the GET method that was used by a web browser to request a specific document. POST method:- The POST method allows web browsers to send an unlimited amoount of data to a web server by allowing them to tag it on an HTTP request after the request headers as the message body. 2) What is HTML? List the different classification of HTML tags. A:- HTML (Hyper Text Markup Language) is simply a markup language, which is used to describe the logical structure of a document. Classification of HTML:3) What is CSS? Why it is required? A:- CSS stands for Cascading style sheets. CSS is the part of DHTML that controls the look and placement of the elements on a page. With CSS we can basically set any style property of any element on a HTML page. One of the biggest advantages with CSS instead of the regular way of changing the look of elements is that we split content from design. If we want to change like the font size of our main text we just change it in the CSS file and all pages are updated. In CSS program always place the style tag inside the head of document. The syntax for CSS code is basically like this: <style type=text/css> ELEMENT{property1:value1; property:value2} </style> 4) List the steps in implementing a servlet. A:- Following are the steps used in implementing a servlet for HTTP communication: 1. Import required servlet packages in the class. 2. Make the class extend HttpServlet. 3. Override methods doGet(), doPost(), or doService() as required by problem in hand. 4. Make an entry for the above servlet in deployment descriptor. 5. Configure any extra options or filters, which are required by the server to function. 5) a)What is SSL? Why do we require SSL. A:- SSL stands for Secure Scokets Layer. SSL is a protocol. It is developed by Netscape, has become the universal standrad on the Web for authenticating Web sites to Web browser users, and for encrypting communications between browser user and Web servers. We required SSl is to provide security for Web traffic. Security includes confidentiality, message integrity, and autentication. SSL is built into all major n\browsers and Web servers, simply installing a digital certificate, or Server ID, enables SSL capabilites.

b) List the differences between HTML and DHTML. A:- HTML:- HTML stands for Hyper Text Markup Language. It is a language. HTML cant be done after the page loads. HTML can be or not used with JavaScript. DHTML:- DHTML stands for Dynamic Hyper Text Madrkup Language. DHTML isnt really a language or a thing in itself its just a mix of those technologies. Dynamic HTML is simply HTML that can changes even after a page has been loaded into a browser. DHTML can be used with JavaScript. 6) What are all the building elements of web ? A:- There are two most important building blocks of web: 1) HTML and 2) HTTP. HTML: - HTML stands for Hyper Text Markup Language. HTML is a very simple language used to describe the logical structure of a document. Actually, HTML is often called programming language it is really not. Programming languages are Turing-complete, or computable. That is, programming languages can be used to compute something such as the square root of pi or some other such task. Typically programming languages use conditional branches and loops and operate on data contained in abstract data structures. HTML is much easier than all of that. HTML is simply a markup language used to define a logical structure rather than compute anything. HTTP: - HTTP is a request-response type protocol. It is a language spoken between web browser (client software) and a web server (server software) so that can communicate with each other and exchange files. Now let us understand how client/server system works using HTTP. A client/server system works something like this: A big piece of computer (called a server) sits in some office somewhere with a bunch of files that people might want access to. This computer runs a software package that listens all day long to requests over the wires. 7) What are CGI environment variables? A:- Most of the information about the client, server, and user input is placed and made available through globally accessible variables known as CGI environment variables. Some of the commonly used environment variables are: QUERY_STRING: The query information passed to the program. It is appended to the URL with a ? when the browser sends it to the server. The name value pairs are then stored in this environment variable. SERVER_PROTOCOL: The name of and revision of the information protocol that the request came in with. REQUEST_METHOD: The method with which the information request was issued. HTTP_USER_AGENT: The browser used by the client to issue the request. CONTENT_LENGTH: The length of the data in bytes passed to the CGI program through the standard input. 8) What are Cookies ? List any 6 Javax. Servlet. http Cookie methods. A:- This is probably the most common way of tracking users on the Internet. You can store information in a users computer using cookies, and retrieve it when you need it. You can also specify how long the cookie should exist before being deleted by the browser. Following are the methods of the Cookie class: java.lang.String getName(): Returns the name of the cookie java.lang.String getValue(): Returns the value of the cookie

void setValue(java.lang.String value): Assigns a new value to a cookie after it has been created void setPath(java.lang.String uri): Sets the path for the cookie by which the browser will send the cookie void setMaxAge(int expiry): Set the maximum age of the cookie in seconds int getMaxAge(): Returns the maximum age of the cookie in second 9) Explain with example query string. A:- One way to send form data to a CGI program is by appending the form information to the URL, after a question mark. You may have seen URLs like the following:http://some.machine/cgi-bin/name.pl?fortune Up to the question mark (?), the URL should look familiar. It is merely a CGI script being called, by the name name.pl. Whats new here is the part after the ?. The information after the ? character is known as a query string. When the server is passed a URL with a query string, it calls the CGI program identified in the first part of the URL (before the ?) and then stores the part after the ? in the environment variable QUERY_STRING. The following is a CGI program called name.pl that uses QUERY_STRING to print the information passed. #!/usr/local/bin/perl print Content-type: text/plain, \n\n; $query_string = $ENV{QUERY_STRING}; if ($query_string eq fortune) { print query string is fortune; } elsif ($query_string eq finger) { print query string is finger; } else { print invalid query string; } exit (0); You can execute this script as either: http://some.machine/cgi-bin/name.pl?fortune http://some.machine/cgi-bin/name.pl?finger or http://some.machine/cgi-bin/name.pl and you will get different output. 10) What is JSP? How it is different from CGI programming? A: JSP stands for Java Server Pages. It is a technology for developing web pages that include dynamic content. A JSP page can change its content based on any number of variable items, including the identity of the user, the users browser type, information provided by the user, and selections made by the user. A JSP page contains standard markup language elements, such as HTML tags, just like a regular web page. JSP also contains special JSP elements that allow the server to insert dynamic content in the page. JSP elements can be used for a variety of purposes, such as retrieving information from a database or registering user preferences. JSP defines a number of standard elements that are useful for any web application. 11) Explain with example the meaning of servlet.

12) What is Java Script? List out uses of Java Script.

A:- Java script is a scripting language( like a simple programming language). JavaScript is a language that can be used for client-side scripting. JavaScript is only used inside of HTML documents. With JavaScript, we can make text scroll across the screen like ticker tape. The uses of JavaScript :I. II. III. IV. V. VI. VII. Control document Appearance and Content Control the browser Interact with Document control Interact with User Read and Write Client State with Cookies Interact with Applets JavaScript is only used inside of HTML documents

Disadvantages:I. II. III. IV. JavaScript do not have any graphics capabilities. For security reasons, client-side JavaScript does not allow the reading or writing of files. JavaScript does not support any kind of networking. JavaScript doesnt have any multithreading capabilities.

13) What are text nodes ? A:- Text nodes represent content, or character data. They will have a parent node and possibly sibling nodes, but they cannot have child nodes. 14) What is CGI ? Give examples of CGI application. A:- CGI or Common Gateway Interface is a specification which allows web users to run programs from their computer. CGI is the part of the Web server that can communicate with other programs running on the server. The Web server can call up a program, while passing user-specific data to the program. The program then processes that data and the server passes the programs response back to the Web browser. Some of the possible applications of CGI are: 1) Forms: - One of the most prominent uses of CGI is in processing forms are subsets of HTML that allow the user to supply information forms. The forms interface makes Web browsing an interactive process for the user and the provider. 2) Gateways:- CGI provides a solution to the problem in the form of a gateway. We can use a language such as oraperl or a DBI extension to Perl to form SQL queries to read the information contained within the database. Once we have the information, we can format and send it to the client. In this case, the CGI program servers as a gateway to the Oracle database. 3) Virtual Documents:- Virtual, or dynamic documents creation is at the heart of CGI. They are created on the fly in response to a users information request. We can create virtual HTML, plain text, image, and even audio documents. 15) What is Query String ? A:- In the Worldwide Web, a query string is the part of a Uniform Resource Locator (URL) that contains data to be passed to web applications such as CGI programs. When a web page is requested via the Hypertext Transfer Protocol, the server locates a file in its file system based on the requested URL. This file may be a regular file or a program. In the second case, the

server may (depending on its configuration) run the program, sending its output as the required page. The query string is a part of the URL which is passed to the program. Its use permits data to be passed from the HTTP client (often a web browser) to the program which generates the web page. 16) What is Extra Path Information ? A:- Besides passing query information to a CGI script, you can also pass additional data known as extra path information as part of the URL. The server gauges where the CGI program name ends; anything following that is deemed as extra path information and stored in the PATH_INFO environment variable. For example the following line calls a script with extra path information: http://some.machine/cgi0bin/display.pl/cgi_doc.txt 17) What is a web server? What is a application server? A:- Web server: Web server is the software responsible for accepting browser requests, retrieving its content & returning its content. By default, Web browsers use port 80 for their requests. Web servers are often called httpd, using a UNIX convention in which daemons are named with the name of the service followed by the letter d. Web servers first retrieve the request using Berkeley sockets. Most web servers on Internet today run on UNIX machines. Application server: An application server commonly includes a web server so perhaps we can see an application server as an extension of a web server. In application server you can deploy a java components ranging from simple java application to server side business components. Usually when we want to deploy EJBs we will go for App servers like web-logic or web-sphere. In application server, ejbjar. xml or application.xml file is used as deployment descriptor. 18) List out differences between web server and application server. A:- same of the above. (q17). 19) Describe role of deployment descripters. A:- This is an XML file describing the servlet and other components that make up your application, along with any initialization parameters and container-managed security constraints that we want the server to enforce for us. The ejb-jar.xml or application.xml file is used as deployment descriptor. 20) What is a war file? Give its importance. A:- WAR or Web Application Archive file is packaged servlet Web application. Servlet applications are usually distributed as a WAR files. 21) How to specify session time out in Web.XML? A:- You can specify session timeout in the <session-timeout> attribute of the <session-config> element. For example, to specify a session timeout of 30 minutes use: <session-config> <session-timeout>30</session-timeout> </session-config> 22) What are the advantages of JSP ? A:- 1). JSP supports both scripting and element-based dynamic content and allows programmers to develop custom tag libraries to satisfy application-specific needs. 2). JSP pages are compiled for efficient server processing. 3) JSP pages can be used in combination with servlets that handle the business logic, the model supported by Java servlet template engines. 23) What are servlets ? Describe with example./ Give the Basic servlet structure. A:- Servlets are programs that run on a Web server and build Web pages.

The outline of a basic servlet that handles GET requests. GET requests, are requests made by browsers when the user types in a URL on the address line, follows a link from a Web page, or makes an HTML from that does not specify a METHOD. Servelts can also very easily handle post requests, which are generated when someone creates an HTML form that specifies METHOD=POST. A class should extend HttpServlet and override doGet or doPost, depending extend HttpServlet and override doGet or doPost,

depending on whether the data is being sent by GET or by POST. These methods take two arguments: HttpServletRequest and HttpServletResponse. HttpServletRequest has methods that find out about incoming information such as FORM data, HTTP request headers. HttpServletResponse has methods that specify the HTTP response line response, PrintWriter used to headers and most importantly, obtain a send output back to the client. For simple servlets, most of the effort is spent in println statements that generate the desired page. We have to import classes in java.io , javax.servlet , and javax.servlet.http. DoGet and doPost are called by the service method, and sometimes we want to override service directly. 24) Which two packages implement the servelet API ? A:- The two packages are: javax.servlet 6. javax.servlet.http 25) What are the several ways of tracking users? A:- The several Ways of tracking users are followings: Hidden text: It is easier way to associating information which is not directly associated to user. Cookies: - This is probably the most common way of tracking users on the Internet. We can store information in a users computer using cookies, and retrieve it when we need it. We can also specify how long the cookie should exist before being deleted by the browser.

Sessions: - Sessions are something the server offers us to support user tracking, and heyre great, although they can take up a lot of resources on the server. Preserve data between accesses to a Web page by the same user. Application:- Data can be shard using application can be used to track multiple users at same time. 26) What are the disadvantages of hidden controls? A:- Storing data in hidden controls works, it is not very secure, and the data stored in those controls is visible if the user views the pages HTML source. We cant store data between sessions. 27) What is sessions? A:- Sessions are something the server offers us to support user tracking, and theyre great, although they can take up a lot of resources on the server. Sessions preserve data between accesses to a Web page by the same user. 28) a) Give an overview about EJBs. A:- Enterprise Java Beans (EJB) is a server-side component that executes specific business logic on a server when invoked by a local or remote client. EJB is actually a framework for writing distributed programs. It involves a standardization agreement that enables a component to run within any application server. The agreement is accomplished by implementing a set of Java interfaces from the EJB API. Note that EJBs are not GUI components. b)What are the advantages and disadvantages of EJBs. A:- Following are the advantages of EJBs: Many vendor application server conform to the J2EE specification allowing you to select a best-of- breed solution To handle fluctuations in resource demand server-side resource can easily be scaled by adding or removing servers. Application servers provide access to complex services, such as transaction and security management, resource pooling, JNDI (Java Naming and Directiory Interface), and component lifecycle management. Following are the disadvantages of EJBs: EJB has a large and complicated specification. EJBs take time to develop. Also, they are difficult to debug. Occasionally, the bug may not be in your code but in the application server itself. Frequently released newer versions of EJB specifications render application obsolete quickly. 29) Describe in briefly the entity beans and session beans. A:- There are two kinds of Enterprise Java Beans, Entity Beans and Session Beans. Entity Bean: An entity bean is an object with special properties: a) It is permanent: an entity bean stays around until it is deleted. A program can create an entity bean then the program can be stopped and restarted. b) It is network based: an entity bean can be used by any program on the network. It is executed remotely: an entity bean run on a server machine. It is identified by a primary key: The primary key is unique; each entity bean is uniquely identified by its primary key. Session Beans: Session beans are different from of entity beans in that they are not permanent objects. Session beans can be used to distribute and isolate processing tasks. Session bean can be used to perform a certain task on behalf of its client. The tasks can be distributed on different machines. Session bean may perform a task of remote location. Session beans do not have a primary key. 30) What is DTD ?

A:- DTD or Document Type Definitions is a document that contains grammar rules for validating an XML document. It is a schema specification method for XML.

PART B 5x 15 =75 Marks 1) a) Why do we require Java script and DHTML. 7 Marks A:- JavaScript and DHTML make Web pages more interactive. HTML can be used to only present information. It cannot process data and is therefore not interactive. JavaScript can be used to write programs for creating interactive Web pages. For example, if a user leaves out a field in an online form, JavaScript can be used to prompt the user to enter a value in that field. DHTML can be used to make the pages more interactive by allowing you set properties of Web pages and their look and feel. b) What is CGI? Explain the role of CGI programming in web. 8 Marks A:- CGI stands for Common Gateway Interface. CGI is the part of the Web server that can communicate with other programs runining on the server. CGI provides a gateway between a human user with unexpected and complex needs, and a powerful, comand/logic oriented srever. All CGI appliations must translate the needs of clients into server requests, and translate server replies into meaningful well-presented answer. The CGI script will be responsible for processing the form data, which is filled by user and responding to the client in the form of dynamically generated HTML. With CGI, the web server can call up a program, while passing user-specific data to the program ( such as what host the user is connecting from, or input the user has supplied using HTML from syntax). The program then processes that data and the server passes the programs response back to the WEB browser. 2) a) Write an HTML program to demonstrate text characteristics tags. 7 Marks A: - The following code demonstrates some of the important text characteristics tags in HTML: <html> <head> <title>Text Characteristics</title> </head> <body> <p><b> <font color = "#0000FF" face ="Arial" size = "5"> Text Characteristics in </font> <font color = "#0000FF" face ="Arial" size = "8"> <s>HTML</s> </b> </p> </font> <i>HTML</i> is a <em>formatting language</em> for Web pages. Below is an example of <u>HTML code</u><br> <code> &lt;HTML&gt;<br> &lt;HEAD&gt;<br> &lt;/HEAD&gt;<br> &lt;/HTML&gt;<br> </code> <p><kbd>&</kbd> followed by <kbd>gt</kbd> represents the greater than sign. </body>

b) Explain how you can embed an image in HTML page? Give an example. 8 Marks A:- To embed an image in an HTML page, you can use the <IMG> tag. The <IMG> tag includes various attributes, for embedding and formatting images in an HTML page. The most common attributes of the <IMG> tag are: SRC: Absolute or relative path of the image to be embedded LOWSRC: The path of the low resolution version the image ALT: Alternate text to be displayed in case the image cannot be loaded. ALIGN : Alignment of the image in the page HEIGHT: Height of the image WIDTH: Width of the image You can use the above tags to load an image from a URL or a relative path. For example, if the image (suppose image_filename.gif) that you want to embed resides in the same folder as the HTML page, you can embed it as: <IMG SRC="image_filename.gif" ALT = "this is an image loaded from a relative path"> The above will display the image in the file image_filename.gif. In case this image cannot be loaded, the text "this is an image loaded from a relative path" will be displayed. Similarly, to load an image from a URL, you can specify the URL in the SRC attribute. 3) a) What is Java script? Explain the usage of script tags. 7 Marks A:- Java script:- JavaScript is a scripting language (like a simple programming language). JavaScript is a language that can be used for client-side scripting. JavaScript is only used inside of HTML documents. With JavaScript, we can make text scroll across the screen like ticker tape. The script tag marks the beginning and end of JavaScript in a web page. You can specify the scripting language in the script tags' Language attribute. In addition, you can also specify where the script is expected to run using the runat attribute. For example, when JavaScript is used as a server side scripting language, you can use the script tag as: <SCRIPT Language = "JavaScript" runat = "server"> </SCRIPT> b) Write a program to display text in status bar on click of a button. 8 Marks A:- <html> <head> <title>Pop up</title> </head> <body onclick = "window.status = 'You have clicked!!!'"> <h1>Changing Status Bar Text</h1> </body> </html> 4) a) Write a CGI application which accepts 3 numbers and display biggest number. 7 A:- chapter 4 of book. b) With the help of an example explain extra path information. 8 Marks A:- (page 90-91 of book) 5) a) What is Web Server? Explain briefly the mechanism of web server. 7 Marks A:- The Web server is the software responsible for accepting browsers' requests, retrieving the specified file or executing the script, and returning its content to the browser. Popular Web servers

include Tomcat, Apache, and IIS.

Mechanism of web server:- A Web server first retrieves a client request using Berkley sockets, which is a mechanism used for communicating over a network. The Web server listens for request on a particular port on the server machine. For HTTP request, this port is by default set to 80. When the server receives the request, it locates the document being requested. It looks for the file under the document root directory. For example, if the document root is /usr/local/httpd/htdocs and the client requests the document /staff/matthew.html, then the server retrieves /usr/local/httpd/htdocs/staff/matthew.html. If the URL does not specify a file but just a directory, the server returns the directory index file, generally called index.html or welcome.html. The server sends the contents of the file back to the client, along with some HTTP response headers. b) What is war file? Give its importance. 8 Marks 6) a) What is JSP? Explain the various JSP directives. 7 Marks A:- JSP is stands for Java server Page. JSP is a technology for developing web page that include dynamic content. JSP is use for change The various JSP directives:- JSP directives are JSP elements that provide global information about a JSP page. The various JSP directives are: page directive: Defines information that will globally affect the JSP containing the directive. The syntax of a page directive is: <%@ page {attribute = "value"}%>. The various possible attributes are language, extends, import, session, buffer, autoFlush, isThreadSafe, info, errorPage, isErrorPage, and contentType. include directive: Used to insert text and/or code at the JSP translation time. Its syntax is: <%@ include file = "relativeURLspec" %>. The file attribute can reference a normal HTML file or a JSP file, which must be local to the Web application that contains the directive. taglib directive: States that the including page uses a custom tag library, uniquely identified by a URO and associated with a prefix that will distinguish each set of custom tags to be used in the page. Its syntax is: <%@ taglib uri = "tagLibraryURI" prefix = "tagPrefix"%>. b) Explain implicit objects out, request, response in a JSP Directives. 8 Marks A:- Following are the implicit objects in a JSP page: out: This implicit object represents a JspWriter that provides a stream back to the requesting client. The most common method of this object is out.println(),which prints text that will be displayed in the client's browser.

request: This implicit object represents the javax.servlet.HttpServletRequest interface. The request bject is associated with every HTTP request. One common use of the request object is to access request parameters. You can do this by calling the request object's getParameter() method with the parameter name you are seeking. It will return a string with the values matching the named parameter. response: This implicit object represents the javax.servlet.HttpServletRequest object. The response bject is used to pass data back to the requesting client. A common use of this object is writing HTML output back to the client browser. 7) a) Explain in detail servlet cycle. 7 Marks b) Draw and explain the class diagram to show the relationships between the major classes in the servlet API. 8 Marks A:-

A servlet is a Java program, which runs in a servlet container and is written according to servlet API specification. Servlet API is a set of classes and interfaces, which outlines all necessary operations, restrictions, and behaviour for a servlet. A servlet container is software, which provides network services over which requests, responses are sent. It should provide abstraction in obtaining requests and formatting responses and at least support communication over HTTP. For example, Tomcat is a servlet container. 8) a) Explain how HTTP is used in client/server system. 7 A: - HTTP is a request-response type protocol that specifies that a client will open a connection to a server then send a request using a very specific format. HTTP is a language spoken between our web browser (client s/w) and a web server (server software) so that they can communicate with each other and exchange files. Client/server system is a very eager way of distributing information across information systems like LAN, WAN, or the Internet. A client/server system works something like this: A server sits in some office somewhere with a bunch of files that people might want access to. This computer runs a software package that listens all day long to requests over the wires. The server software will then accesses the server hardware, find the requested file, send it back over the wires to the client who

requested it, and then wait for another request from the same or another client. HTML is a simply markup language used to define a logic structure rather than computer. The beauty of HTML of route is that it is generic enough that it can be read and interpreted by a web browser running on any machine or o/s. It only focuses on describing is responsible for adding style. So that HTML is the language of the web. b) What are the differences between static and dynamic web pages ? 8 A:- a) The great numbers of web pages on the internet are static HTML pages but visitors find dynamically generated web pages because they are provide instant access to highly relevant information. b) Static pages are easily read by search engine spider, Dynamic sites are also easy to update. c) Static web pages are simple text files that are displayed by your browser upon request, Dynamic Web pages, contain little actual text. They are created each time they are requested, retrieving information from a database. 9) a) Write an example HTML page containing a table 4x3 and each row colored differently. 7 A:- The following is an HTML page containing a table 4 X 3 and each row colored differently: <html> <head> <title>Colored Table</title> </head> <body> <table border="1" width="100%"> <tr bgcolor="#0000FF"> <td width="33%">&nbsp;</td> <td width="33%">&nbsp;</td> <td width="34%">&nbsp;</td> </tr> <tr bgcolor="#00A0FF"> <td width="33%">&nbsp;</td> <td width="33%">&nbsp;</td> <td width="34%">&nbsp;</td> </tr> <tr bgcolor="#AB00FF"> <td width="33%">&nbsp;</td> <td width="33%">&nbsp;</td> <td width="34%">&nbsp;</td> </tr> <tr bgcolor="#FB2CFF"> <td width="33%">&nbsp;</td> <td width="33%">&nbsp;</td> <td width="34%">&nbsp;</td> </tr> </table> </body> </html> b) Create a simple HTML page to demonstrate the usage of Anchor tags. 8 A:- The following HTML page, demonstrates the usage of anchor tags: <html> <head> <title>Anchor Tag Characteristics</title>

</head> <body> <h1 align="center">All in One</h1> <p align="left">In <A HREF= "#sec1">section 1</a> you can search. In <A HREF= "#sec2">section 2</a> you can shop.</p> <A NAME= "sec1">Section 1: </a> <p> <a href="http://google.co.in" target= "_blank"> Search on Google</a>&nbsp;</p> <p><a href="http://yahoo.com">Search on Yahoo</a></p> <p>&nbsp;</p> <p> <A NAME= "sec2">Section 2: </a> </p> <p><a href="http://ebay.com"> Shop on ebay&nbsp;</a></p> <p><a href="http://wallpapers.com">Download wallpapers</a>&nbsp;</p> <p><a href="http://t-shirts.com"> Order Custom T-Shirts News</a></p> </body> </html> 10) a) Explain document object model. 7 A:- The Document Object Model, or DOM, is the interface that allows programmatically accessing and manipulating the contents of a web page or document. It provides a structured, objectoriented representation of the individual elements and content in a page with methods for retrieving and setting the properties of those objects. It also provides methods for adding and removing such objects, allowing us to create dynamic content The DOM also provides an interface for dealing with events, allowing to capture and respond to user or browser actions. The Document Object Model is the real core of dynamic HTML. It makes HTML changeable. The DOM is the hierarchy of elements that are present in the browser at any given time.DOM. b) Explain the methods to access nodes in a document tree. 8 A:- Methods for accessing and creating other nodes in the document tree. Some methods are: getElementById(), getElementsByTagName(), createElement(), createAttribute(), createTextNode(). All of the above methods (except getElementsByTagName()) can only be used against the document object, i.e., using the syntax : document.methodName(). 11) a) What is PEARL ? Explain different types of PEARL variables. 8 A:- PEARL:PERL variables are of the following three types:Scalars: A scalar variable stores a single value of any type. Scalar variables are prefixed with a $. These variables need not be declared before using them. You can define or use a variable as: $var =1; $var_noval; $str = "This is a scalar string variable"; Arrays: Arrays store an ordered list of values. Arrays can be declared as: @emptyarr =(); @arr = ("1", "2","3");

Each individual item of an array is referred to by its index number as: print "$arr[0]"; You can use the push() and pop() functions to insert or delete an element from an array. Hashes: A Hash is a special kind of an array - an associative array or paired list of elements. Each pair in a Hash consists of a string key and data value. A hash is defined as: %emptyhs = (); %hs = ("key1", "val1", "key2", "val2"); or%hs = (key1 => "val1", key2=> "val2"); An individual item of a Hash is referred to as $hs{"key1"}; The my function can be used with each of the above type of variables to declare and limit the scope of the variable to the enclosing block as: my $var; b) With the help of an example, explain CGI.pm module. 7 A:- Perl offers a powerful feature to programmers: add-on modules. These are collections of pre-written code that can use to do all kinds of tasks. We can save the time and trouble of reinventing the wheel by using these modules. Some modules are included as part of the Perl distribution; these are called standard library modules and dont have to be installed. Were not doing use CGI.pm but rather use CGI. The .pm is implied in the use statement. The qw(:standard) part of this line indicates that we are importing the standard set of function from CGI.pm. #!/usr/bin/perl wT -use CGI qw(:standard);-print header;-print start_html(Hello World);-print <h2>Hello, world!</h2>\n;-print end_html; CGI.pm also has a number of functions that serve as HTML shortcuts. 12) a) Explain the role of Deployment descriptors. 7 A:- This is an XML file describing the servlet and other components that make up your application, along with any initialization parameters and container-managed security constraints that we want the server to enforce for us. The ejb-jar.xml or application.xml file is used as deployment descriptor. b) List out the differences between Webserver and application server. 8 A:- Web server:- is the software responsible for accepting browser requests, retrieving its content & returning its content. By default, Web browser use port 80 for their requests. Web servers are often called httpd, using a UNIX convention in which daemons are named with the name of the service followed by the letter d. Web servers first retrieve the request using Berkeley sockets. Most web servers on internet today run on UNIX machines. Application server: commonly includes a web server so perhaps we can see an application server as an extension of a web server. In application server you can deploy java components ranging from simple java application to sever side business components. Usually when we want to deploy EJBs we will go for App server like web logic or web-sphere. In application server, ejb-jar.xml or application.xml file is used as deployment descriptor. 13) a) Explain the semantics of the HTML FORM element. " 7 A:- The HTML form element represents a form in which users can input data and submit it to the server for processing. The HTML form tag is as follows: <FORM NAME="name" ACTION = "action.jsp" METHOD = "POST/GET"> The name attribute specified the name for a form. The action attribute specified the URL of the document or the name of the file to which the form data is submitted for action and the method attribute specified the HTTP method through which the data is sent to the server. The action attribute can be a simple static Web page or a servlet. The method can be POST or GET. A form includes various other <INPUT> elements such as textbox, list, buttons, or checkboxes.

b) Describe the request handling cycle and the methods invoked on the servlet by the servlet container. 8 A:- Following are the operations done on a servlet by servlet container when a servlet is requested: 1. If servlet instance does not exist in memory, the container: a. Loads the servlet class and thus creates its instance b. Calls the init() method on the above class and passes ServletConfig as parameter 2. On any further request service() method of servlet class is called and HttpServletRequest and HttpServletResponse are passed as parameters to it. 14) a) With the help of an example explain GET and POST Methods. 8 A: - When a client sends a request to the server, the clients can also additional information with URL to describe what exactly is required as output from the server by using the GET method. The additional sequence of characters that are appended to URL is called a query string. However, the length of the query string is limited to 240 characters. Moreover, the query string is visible on the browser and can therefore be a security risk. To overcome these disadvantages, the POST method can be used. The POST method sends the data as packets through a separate socket connection. The complete transaction is invisible because to the client. The disadvantage of POST method is that is slower compared to the GET method because data is sent to the server as separate packets. b) HTML is the language of Web. Explain 7 15) Explain CSS with the help of an example. 7 A:- CSS stands for Cascading style sheets. CSS is the part of DHTML that controls the look and placement of the elements on a page. With CSS we can basically set any style property of any element on a HTML page. One of the biggest advantages with CSS instead of the regular way of changing the look of elements is that we split content from design. If we want to change like the font size of our main text we just change it in the CSS file and all pages are updated. In CSS program always place the style tag inside the head of document. The syntax for CSS code is: <style type=text/css>Element{property1:value;property:value2} </style> 16). a) Explain various JSP directives. 7 A:- JSP directives are JSP elements that provide global information about a JSP page. The various JSP directives are: page directive: Defines information that will globally affect the JSP containing the directive. The syntax of a page directive is: <%@ page {attribute = "value"}%>. The various possible attributes are language, extends, import, session, buffer, autoFlush, isThreadSafe, info, errorPage, isErrorPage, and contentType. include directive: Used to insert text and/or code at the JSP translation time. Its syntax is: <%@ include file = "relativeURLspec" %>. The file attribute can reference a normal HTML file or a JSP file, which must be local to the Web application that contains the directive. taglib directive: States that the including page uses a custom tag library, uniquely identified by a URO and associated with a prefix that will distinguish each set of custom tags to be used in the page. Its syntax is: <%@ taglib uri = "tagLibraryURI" prefix = "tagPrefix"%>. b) Explain implicit object out, request response in a JSP page. 8 A:- Following are the implicit objects in a JSP page: out: This implicit object represents a JspWriter that provides a stream back to the requesting client. The most common method of this object is out.println(),which prints text that will be displayed in the client's browser. request: This implicit object represents the javax.servlet.HttpServletRequest interface. The request object is associated with every HTTP request. One common use of the request object is to access

request parameters. You can do this by calling the request object's getParameter() method with the parameter name you are seeking. It will return a string with the values matching the named parameter. response: This implicit object represents the javax.servlet.HttpServletRequest object. The response object is used to pass data back to the requesting client. A common use of this object is writing HTML output back to the client browser. 17) Which two packages implement the servlet APL ? 7 A:18) a) What is SSL? What is the necessity of it? Explain the working of SSL. 7 A:- SSL stands for Secure Sockets Layer. SSL is a protocol. It is developed by Netscape, has become the universal standard on the Web for authenticating Web sites to Web browser users, and for encrypting communications between browser users and Web servers. The main role of SSL is to provide security for Web traffic. Security includes onfidentiality, message integrity, and authentication. The working of SSL is: SSL has two distinct entities, server and client. The client is the entity that initiates the transaction, whereas the server is the entity that responds to the client and negotiates which cipher suites are used for encryption. In SSL, the Web browser is the client and the Web-site server is the server. Three protocols lie within SSL, the Handshake Protocol, the Record Protocol, and the Alert Protocol. The client authenticates the server during the Handshake Protocol. When the session is initiated and the handshake is complete, the data transfer is encrypted during the Record Protocol phase. If there are any alarms at any point during the session, the alert is attached to the questionable packet and handled according to the Alert Protocol.

b) What is EJB ? Briefly describe the roles of remote and home interfaces in EJB. 8 A:- EJB:- Enterprise Java Beans (EJB) is a server-side component that executes specific business logic on a server when invoked by a local or remote client. EJB is actually a framework for writing distributed programs. It involves a standardization agreement that enables a component to run within any application server. The agreement is accomplished by implementing a set of Java interfaces from the EJB API. Note that EJBs are not GUI components. The roles of remote and home interfaces in EJB: - A remote interface is the business end of EJB. It is the set of services provided by EJB. The home interface is the book-keeping interface. It helps clients to create a new instance of an EJB, or to find an existing instance of an EJB. The methods used to find existing EJBs are shown as finder methods. Since session beans are not designed to be shareable, there are no session bean finder methods. 19) How are JSPs are better than servlets? A:a) Java programming knowledge is needed to develop and maintain all aspects of the applicationb. Since the processing code and the HTML elements are lumped together.

b) Changing the look and feel of the application, or adding support for a new type of client, requires then servlet code to be update and recompiled. c) Its hard to take advantage of webpage development tools when designing the applicaton interface. If such tools are used to devlop the web page layout, the generated HTML must then br manually embedded into the servlet code, a process which is time consuming, error prone and extremely boring. Adding JSP to the puzzel we solve therse problem. So jsp better than servlets 20) Write short note on the following 3x5= 15 Marks A)XML A:- Extensible markup language is a text-based markup language that enables to store data in a structured format by using meaningful tags. XML is a cross-platform, h/w & s/w independent markup language. XML allows computers to store data in a format that can be interpreted by any other computer system. XML can be used to transfer structured data between various systems. Xml is used as a common data interchanges format in a number of applications. XML is extremely simple. XML represents information as text using tags to add structure. A tag begins with a name sandwiched between less-than (<) and greater-than (>) characters. Advantages of XML: a) it provides a way of creating domain-specific vocabulary. b) It enables smart searches. c) It provides user-selected view of data. B)EJB . \ A:- EJB:- Enterprise Java Beans (EJB) is a server-side component that executes specific business logic on a server when invoked by a local or remote client. EJB is actually a framework for writing distributed programs. It involves a standardization agreement that enables a component to run within any application server. The agreement is accomplished by implementing a set of Java interfaces from the EJB API. Note that EJBs are not GUI components. c) SSL A:- SSL stands for Secure Scokets Layer. SSL is a protocol. It is developed by Netscape, has become the universal standrad on the Web for authenticating Web sites to Web browser users, and for encrypting communications between browser user and Web servers. We required SSl is to provide security for Web traffic. Security includes confidentiality, message integrity, and autentication. SSL is built into all major n\browsers and Web servers, simply installing a digital certificate, or Server ID, enables SSL capabilites. d)Sessions A:- Sessions are something the server offers us to support user tracking, and theyre great, although they can take up a lot of resources on the server. Preserve data between accesses to a Web page by the same user.

You might also like