+ All Categories
Home > Documents > B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

Date post: 30-May-2018
Category:
Upload: ramkipsvr123
View: 221 times
Download: 0 times
Share this document with a friend

of 23

Transcript
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    1/23

    B.E/B.Tech DEGREE EXAMINATION Nov/Dec 2007

    Seventh semester

    Computer Science and Engineering

    CS 1401 - Internet Programming(Regulation 2004)

    Time: 3 hours Maximum marks: 100

    Answer ALL questions

    PART A (10 x 2 =20 marks)

    1.What is the primary function of an HTTP server?

    HTTP servers provide function that monitors a URL that is part of the web site

    (for example, your home page) and will take recovery action if the web server isno longer serving the web content. For example, the monitor function will try toend and start the web server or may initiate a switch-over to move the HTTPserver function to the backup node in the cluster.

    2.What is the difference between an absolute pathname and a realative pathname?

    Absolute pathnames are similar to file references, but rather than referring to a file on yourcomputer, they refer to a file on the web server. Absolute references will always start with asingle slash/or http://. Whereas the relative pathnames are relative to the location of thefile that contains them. Relative pathnames are typically shorter than the other two types.Example:

    /group51/Smith/images/aliens.jpg is an absolute pathname.images/aliens.jpg is a relative pathname.

    3. For each of the following, write down the value that will be stored in resultdouble result;int num1=5,num2=12,num3=2;

    double val1=5.0,val2=12.0,val3=2.0;

    (a).result=num1*num3*4%num2/val3;

    (b).result=num1+++++num2;

    The value of double result=12.0;

    4.What is an important difference between writing a Java application and a JavaApplet?

    1. An applet runs under the control of a browser, whereas an application runs stand-alone,with the support of a virtual machine. As such, an applet is subjected to more stringentsecurity restrictions in terms of file and network access, whereas an application can have freereign over these resources.

    2. Applets are great for creating dynamic and interactive web applications, butthe true power of Java lies in writing full blown applications. With the limitation ofdisk and network access, it would be difficult to write commercial applications(though through the user of server based file systems, not impossible). However,a Java application has full network and local file system access, and its potentialis limited only by the creativity of its developers.

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/1.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/2.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3_1.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3_1.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/4.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/4.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/2.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/3_1.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/4.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/4.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/1.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    2/23

    5. What is the benefit of using Java script code in an HTML document?

    Benefit of using Java script code in an HTML document

    Clean, lightweight and extremely fast loading.

    Familiar interface allows to jumpstart

    Easy to learn and use.

    All essential code editing features are right at their place.

    Fully customizable text editor, menus, toolbars, shortcut keys.

    Efficiently reuse common code fragments.

    6. For the following form, write down the Javascript code to swap the contents of the twotext boxes

    Code to swap the contents of the two textboxes

    function swap (A, B) {alert ("swap");var temp=document.DAForm.A.value;alert ("A"+temp);document.DAForm.A.value=document.DAForm.B.value;document.DAForm.B.value=temp;}

    Input text1 :< INPUT TYPE="TEXT" NAME="A">Input text2 :< INPUT TYPE="TEXT" NAME="B">

    7. Which function can be used to create an alert popup dialog box? Write an

    example to create an Alert popup box.

    alert () function can be used to create an alert popup dialog box.Example

    function compute (){alert ("Enter the phone no");

    }

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/5.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/7.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/7.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/5.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/6.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/7.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/7.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    3/23

    Enter the Text

    8. State the commands in cascading style sheet used for grouping of elements.

    Style1:H1, H2, H4 {color: purple ;}Style: H2, H3 {background: green ;}Style: H1 {background: white ;}The first two style shows that the same style can be applied to more than one element.Combining all the styles it clearly shows that there are possibilities to apply more than onestyle to an element or group of elements.

    9. What is servlet? How do you compare servlet and traditional CGI programs?

    Servlet

    A Servlet is a Java object that is based on Servlet framework and extends the functionality ofa web server basically being responsible for creating dynamic contents. A Servlet is mappedto a corresponding URL and its life-cycle is managed by the container. The URL is theaddress to which a client send HTTP request.

    CGI versus Servlet

    Written in C, C++, Visual

    CGI Servlet

    1. Written in C, C++, Visual Basic and Perl Written in Java

    2. Platform and application specific Platform independent and portable

    10. How can you create JDBC statement?

    Statement object is created from the Connection object. This Statement object can be used toexecute queries and updates on the database.

    Statement s = c.createStatement (); Two methods of JDBC statement Createa Statement object, and then uses that Statement object's executeQuerymethod to execute the query SELECT * FROM books. The executeUpdate methodis to insert a new row into the books table.

    PART B (5 x 16 = 80)

    11 .( a) List the five layers used by the Internet. For each layer you list, give the

    general purpose of each layer as well as a current implementation (16)

    5 Layers of the InternetComputers on the Internet are connected by various networks. The complexity of networkingis addressed by dividing the Internet into many layers. The International Organization forStandardization (ISO) developed a 7 layer network model (Application, Presentation,Session, Transport, Network, Data Link and Physical layers) long before the Internet hasgained popularity. The 7 layer model has been revised to a 5 layer TCP/IP based InternetModel (Application, Transport, Internet, Network, and Physical layers).Application Layer Application layer defines generic available network applications orservices the Internet can support. See the table below for widely used network applications

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/8.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/9.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/9.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/10.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/10.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/11_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/11_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/8.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/9.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_a/10.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/11_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/11_a.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    4/23

    and the corresponding network protocols.

    ApplicationProtocol

    Web HTTP

    Email SMTP

    File Transfer FTP

    Application layer is the top layer of the OSI (Open System Interconnectivity) server layermodel. This layer handles issues like network transparency, resource allocation and problem

    partitioning. The application layer is concerned with the user's view of network (e.g.formatting electronic mail messages). The presentation layer provides the application layerwith a familiar local representation of data independent of the format used on the network.The application layer provides the interface to the communications environment which isused by the application process. It is responsible for communicating application process

    parameters.Application layer falls under the "host layers" in the OSI topologies used in networkcommunication and it is also the top layer in the Internet model. The host layer also providefor accurate delivery of data between computers in the network.

    Transmission Control Protocol (TCP) Layer This layer concerns how data can be reliablytransferred over the network. UDP (User Datagram Protocol) is used when speed of datatransmission is more important than reliability.The Transport Layer provides transparent transfer of data between end users, providingreliable data transfer services to the upper layers. The transport layer controls the reliabilityof a given link through flow control, segmentation/desegmentation, and error control. Some

    protocols are state and connection oriented. This means that the transport layer can keep

    track of the segments and retransmit those that fail.

    Internet Protocol (IP) Layer This layer handles address and routing of the network. TheNetwork Layer provides the functional and procedural means of transferring variable lengthdata sequences from a source to a destination via one or more networks, while maintainingthe quality of service requested by the Transport Layer. The Network Layer performsnetwork routing functions, and might also perform fragmentation and reassembly, and reportdelivery errors. Routers operate at this layersending data throughout the extended networkand making the Internet possible. This is a logical addressing scheme values are chosen bythe network engineer. The addressing scheme is hierarchical.The best-known example of a Layer 3 protocol is the Internet Protocol (IP). It manages theconnectionless transfer of data one hop at a time, from end system to ingress router, to routerto router, and from egress router to destination end system. It is not responsible for reliabledelivery to a next hop, but only for the detection of errored packets so they may be discarded.When the medium of the next hop cannot accept a packet in its current length, IP isresponsible forfragmenting into sufficiently small packets that the medium can accept it.

    Local Network Access Protocol (NAP) Layer This is the part of your system that isconcerned with how you communicate with your local network, whether is Ethernet or tokenring. The Data Link Layer provides the functional and procedural means to transfer data

    between network entities and to detect and possibly correct errors that may occur in thePhysical Layer. Originally, this layer was intended for point-to-point and point-to-multipointmedia, characteristic of wide area media in the telephone system. Local area network

    architecture, which included broadcast-capable multiaccess media, was developedindependently of the ISO work, in IEEE Project 802. IEEE work assumed sublayering and

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    5/23

    management functions not required for WAN use. In modern practice, only error detection,not flow control using sliding window, is present in modern data link protocols such asPoint-to-Point Protocol (PPP), and, on local area networks, the IEEE 802.2 LLC layer is notused for most protocols on Ethernet, and, on other local area networks, its flow control andacknowledgment mechanisms are rarely used. Sliding window flow control and

    acknowledgment is used at the transport layers by protocols such as TCP, but is still used inniches where X.25 offers performance advantages.

    Physical Layer This is the physical connection whether using a Network Interface Card(NIC) or with a modem to connect to the local network. The Physical Layer defines all theelectrical and physical specifications for devices. In particular, it defines the relationship

    between a device and a physical medium. This includes the layout of pins, voltages, cablespecifications, Hubs, repeaters, network adapters, Host Bus Adapters (HBAs used in StorageArea Networks) and more.To understand the function of the Physical Layer in contrast to the functions of the Data LinkLayer, think of the Physical Layer as concerned primarily with the interaction of a singledevice with a medium, where the Data Link Layer is concerned more with the interactions ofmultiple devices (i.e., at least two) with a shared medium. The Physical Layer will tell onedevice how to transmit to the medium, and another device how to receive from it (in mostcases it does not tell the device how to connect to the medium). Obsolescent Physical Layerstandards such as RS-232 do use physical wires to control access to the medium.The major functions and services performed by the Physical Layer are:

    Establishment and termination of a connection to a communications medium.

    Participation in the process whereby the communication resources are effectivelyshared among multiple users. For example, contention resolution and flow control.

    Modulation, or conversion between the representation of digital data in user equipment andthe corresponding signals transmitted over a communications channel. These are signalsoperating over the physical cabling (such as copper and optical fiber) or over a radio link.

    (or)

    (b) Explain the concept of TCP data transmission (16)

    TCP data transmissionConnection Establishment and Termination

    TCP provides a connection-oriented service over packet switched networks. Connection-oriented implies that there is a virtual connection between two endpoints.3 There are three

    phases in any virtual connection. These are the connection establishment, data transfer and

    connection termination phases.2.1 Three-Way HandshakeConnection EstablishmentIn order for two hosts to communicate using TCP they must first establish a connection byexchanging messages in what is known as the three-way handshake. The diagram belowdepicts the process of the three-way handshake.

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/11_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/11_b.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    6/23

    Host A initiates the connection by sending a TCP segment with the SYN controlbit set and an initial sequence number (ISN) we represent as the variable x inthe sequence number field.At some moment later in time, Host B receives this SYN segment, processes itand responds with a TCP segment of its own. The response from Host B containsthe SYN control bit set and its own ISN represented as variable y. Host B alsosets the ACK control bit to indicate the next expected byte from Host A should

    contain data starting with sequence number x+1.When Host A receives Host B's ISN and ACK, it finishes the connectionestablishment phase by sending a final acknowledgement segment to Host B. Inthis case, Host A sets the ACK control bit and indicates the next expected bytefrom Host B by placing acknowledgement number y+1 in the acknowledgementfield.Data TransferOnce ISNs have been exchanged, communicating applications can transmit databetween each other. A simple TCP implementation will place segments into thenetwork for a receiver as long as there is data to send and as long as the senderdoes not exceed the window advertised by the receiver. As the receiver acceptsand processes TCP segments, it sends back positive acknowledgements,

    indicating where in the byte stream it is. These acknowledgements also containthe "window" which determines how many bytes the receiver is currently willingto accept. If data is duplicated or lost, a "hole" may exist in the byte stream. Areceiver will continue to acknowledge the most current contiguous place in thebyte stream it has accepted.If there is no data to send, the sending TCP will simply sit idly by waiting for theapplication to put data into the byte stream or to receive data from the otherend of the connection.If data queued by the sender reaches a point where data sent will exceed thereceiver's advertised window size, the sender must halt transmission and waitfor further acknowledgements and an advertised window size that is greaterthan zero before resuming.

    Timers are used to avoid deadlock and unresponsive connections. Delayedtransmissions are used to make more efficient use of network bandwidth by

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    7/23

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    8/23

    String str;int digit, no;int odd=0, even=0, zero=0;str = br.readLine ();System.out.println (str);

    no=Integer.parseInt (str);while (no > 0){

    digit=no % 10;no=no/10;System.out.println ("DIGIT"+digit);

    if(digit==0){zero++;

    }if (digit%2==0 && digit!=0){

    even++;}if (digit%2==1){

    odd++;}

    }System.out.println ("Number of Zero digits: zero);System.out.println ("Number of odd digits: odd);System.out.println ("Number of even digits: even);

    }}

    (or)

    (b) What is the use of the applet? Explain its lifecycle with an example (16)

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/12_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/12_b.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    9/23

    The Applet states areInitialization State

    Applet enters the initialization state when it is first loaded. This is achieved bycalling the init() method of Applet class. The applet is born. At this stage, do the following

    things, if required1. Create objects needed by the Applet.

    2. Setup initial values.

    3. Load images or fonts.

    4. Set up colors.

    5. The initialization occurs only once in the applets life cycle.

    Running State

    Applet enters the running state when the system calls the start() method of Appletclass. This occurs automatically after the applet is initialized. Starting can also occur if the

    applet is already in stopped (idle) state.Idle or Stopped State

    An apple becomes idle when it is stopped from running. Stopping occursautomatically when the page leaves the currently running applet. By calling the stop()method explicitly a thread of an applet can be stopped.

    Dead State

    An applet is said to be dead when it is removed from memory. This occursautomatically by invoking the destroy() method. Like initialization, destroying stage occursonly once in the applets life cycle. If the applet has created any resources, like threads, thedestroy() method may be overridden to clean up these resources.

    Display StateApplet moves to the display state whenever it has to perform some output

    operations on the screen. This happens immediately after the applet enters into the runningstate. The paint() method is called to accomplish this task.Almost every applet will have a

    paint() method. Like other methods in the life cycle, the default version of paint() methoddoes absolutely nothing. The programmer must override the method to display anything onthe screen.

    The paint() method is not considered as the part of the applets life cycle. The paint() methodis defined in the Applet class. It is inherited from the Component class, a super class ofApplet.

    Example program

    import java.awt.*;import java.applet.*;

    public class HelloJavaProgram extends Applet{String str;Public void init(){

    str=getParameter (String);if(str==null)

    str=Java;str=Hello + str;

    }

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    10/23

    public void paint(Graphics g){

    g.drawString (str,10,100);}}

    Compile this program and the .class file will be generated.HTML file for HelloJavaProgram applet

    Welcome to Java Applet

    Save this file as HelloJavaParam.html and then run applet using the appletviewer as follows:

    appletviewer HelloJavaProgram.html

    13 .( a) Write a java script function named draw stripes that will draw a number ofcolored stripes generating an HTML table in which each row has a (possibly)different color. Your function must accept three parameters

    width, the width of each stripe

    height, the height of each stripe

    colors , an array in which each element is the name of a color. Each colorname is a valid HTML, color (can be used as the value of a BGCOLOR

    attribute or CSS color property). (16)

    a.

    function asd(form){var asd=form.A.value;var dsa=form.B.value;self.location='table.html?text1=&'asd+'text2=&'dsa;}

    Input text1:Input text2:

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_a.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    11/23

    This is a TD cell This is a TH cellText aligned topImage in TH cell with default alignments --->

    Text aligned bottom

    1.

    function asd(form)

    {var asd=form.A.value;var dsa=form.B.value;self.location='table.html?text1=&'asd+'text2=&'dsa;}

    Input text1:

    Input text2:

    This is a TD cell This is a TH cell

    Text aligned topImage in TH cell with default alignments --->

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    12/23

    Text aligned bottom

    2.

    function asd(form){var asd=form.A.value;var dsa=form.B.value;self.location='table.html?text1=&'asd+'text2=&'dsa;}

    Input text1:Input text2:

    This is a TD cell This is a TH cellText aligned topImage in TH cell with default alignments --->

    Text aligned bottom

    3.

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    13/23

    function asd(form){var asd=form.A.value;var dsa=form.B.value;

    self.location='table.html?text1=&'asd+'text2=&'dsa;}

    Input text1:Input text2:

    This is a TD cell This is a TH cellText aligned topImage in TH cell with default alignments --->

    Text aligned bottom

    (or)

    (b)Explain how you could use HTML frames to provide a website that includes anadvertisement for your company along with the content from any other webpage.

    Show that HTML you would need to do this, as you that for your example the otherwebpage is WWW.yahoo.com. Make sure that you explain how this work.

    Main Page with the advertisementRefer Our Web

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/13_b.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    14/23

    Design of Yahoo webpage

    Yahoo Page

    a:link{color:#0000ff}a:visited{color:#0000ff}a:active{color:#0000ff}a:hover{color:#a0aeff}

    Yahoo..

    &nbs

    p;

    DataImageWeb



    &nbsp

    ;

    Search:

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    15/23

    14(a) Write a program using Cascading Style Sheet (CSS) to display the backgroundimage repeatedly in a file. (16)

    Program to display the image repeatedly in a fileUntitled Document

    CSS code to display the image repeatedly

    .t1 { position: relative; text-shadow:#CC33FF; text-align: center;font-family: Arial, Helvetica, sans-serif; width:100px;

    text-transform: capitalize; text-decoration: blink; background-color:#CCCCFF;background-position: center; table-layout: fixed; border: medium;}.t2{background-repeat:repeat;}

    .ts{ width:100% ; margin-left:50px; margin-right:50px; margin-bottom:50px;margin-top:50px;

    (or)

    (b) Describe the use of data binding and data control in DHTML (16)

    Data Binding in Dynamic HTML

    Accessing data on the Internet using current technology is slow. Pages are slow to renderbecause they are being built by server processes. The processes building these pages areslowing down the server because the server is generating HTML rather than transmitting

    files. Since, on the client, the data in a page is indistinguishable from the page that containsit, additional requests are made to the server to manipulate the data.

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/14_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/14_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/14_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/14_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/14_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/14_b.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    16/23

    Data binding is a new feature of Microsoft Internet Explorer 4.0 (IE 4.0) that enablesauthors to create Web pages that are faster to render, more interactive, easier to author, andthat require fewer server resources. It does this by using the Dynamic HTML support builtinto IE 4.0.Dynamic HTML allows all the elements on a Web page to be manipulated through scripting

    languages. Data binding uses Dynamic HTML in conjunction with a simple declarativesyntax to display data using standard HTML elements without resorting to complex scripting.Instead of the traditional method of merging the data with the HTML through server-sidetemplates or CGI scripts before its sent to the browser, data binding performs this operationon the client after a page is received.

    Data binding in DHTML

    BODY { font-size: 9pt; font-family: verdana, tahoma, sans serif, helvetica; }TH A { color: white }TH A:Hover { color: yellow }

    Name:

    All

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    17/23

    CarNameRespemail

    doc

    DataControlTabular Data Control is a Microsoft ActiveX control that comes pre-installed with allversions of IE4+. This useful control allows to access, display, and even sort ASCIIinformation stored on the server end, such as a .txt file. In other words, it creates a simple

    database function without the need for server side scripting such as PHP and mySQL. Aclient side language such as JavaScript handles the more sophisticated features of TabularData Control.

    Implementation:

    The ActiveX control is initialized using the tag. The CLASSID (uniqueidentifier) for the tabular data control isCLSID:333C7BC4-460F-11D0-BC04-0080C7055A83Initialization of the Control

    ...

    ...

    ...

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    18/23

    Any object, like applet, has a number of parameters. Parameters of the object are specifiedusing the tag. The tabular data control has around 8 parameters.

    DataURL: The path of the file that contains the data. For eg "data.txt".

    UseHeader: Specifies whether the first line of the data file should beused as reference names for their respective fields below. If specified tofalse, use "Column1", "Column2" etc instead. The default value is false.

    TextQualifier: Specifies the optional character that surrounds a field.

    FieldDelim: Specifies the character that is used to separate each field inthe data file. The default character is the comma (,). For eg, consider adata file where we have the fields data: *SomeName*|*SomeAge*|*SomeSex*. Here, the field delimiter used is '|' and '*' is the text qualifier.

    RowDelim: Specifies the character used to mark the end of each row ofdata. The default character is the newline (NL) character.

    Thus, an example complete initialization will look as follows :

    The parameter names are not case sensitive. The Text Qualifierparameter ispurely optional, though can be useful in helping you more easily distinguishbetween each data entry.

    15. (a).Explain Java servlet life cycle and interfaces in detail (16)

    Servletlife-cycle

    A client of a servlet-based application does not usually communicate directly with a servlet,but requests the servlets services through a Web server or application server that invokes theservlet through the Java Servlet API. The servers role is to manage the loading andinitialization of the servlet, the servicing of the request, and the unloading or destroying ofthe servlet. This is generally provided by a servlet manager function of the application server.

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_a.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_a.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    19/23

    The only hard and fast rule is that a servlet engine must conform to the following life cyclecontract:1. Create and initialize the servlet.2. Handle zero or more service calls from clients.3. Destroy the servlet and then garbage collects it.

    The life cycle of a servlet is expressed in the Java Servlet API in the init,service (doGetordoPost), and destroy methods of the Servlet interface.

    Servlet Initialization: init method

    Servlets can be dynamically loaded and instantiated when their services are first requested, orthe Web server can be configured so that specific servlets are loaded and instantiated whenthe Web server initializes. In either case, the initmethod of the servlet performs anynecessary servlet initialization, and is guaranteed to be called once for each servlet instance,

    before any requests to the servlet are handled. An example of a task which may be performedin the initmethod is the loading of default data parameters or database connections.

    The most common form of the initmethod of the servlet accepts a ServletConfigobjectparameter. This interface object allows the servlet to access name/value pairs of initializationparameters that are specific to that servlet. The ServletConfigobject also gives us access tothe SevletContextobject that describes information about our servlet environment.

    Servlet request handling

    Once the servlet has been properly initialized, it may handle requests (although it is possiblethat a loaded servlet may get no requests). Each request is represented by a ServletRequestobject and the corresponding response by a ServletResponse object in the Java Servlet API.

    TheHttpServletRequestobject encapsulates information about the client request, including

    information about the clients environment and any data that may have been sent from theclient to the servlet. TheHttpServletRequestclass contains methods for extracting this

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    20/23

    information from the request object.

    TheHttpServletResponse is often the dynamically generated response, for instance, anHTML page which is sent back to the client. It is often built with data from the

    HttpServletRequestobject. In addition to an HTML page, a response object may also be an

    HTTP error response, or a redirection to another URL, servlet, or JavaServer Page.Each time a client request is made, a new servlet thread is spawned which services therequest. In this way, the server can handle multiple concurrent requests to the same servlet.For each request, usually theservice,doGet, ordoPostmethods will be called. Thesemethods are passed theHttpServletRequestandHttpServletResponse parameter objects.doPost: Invoked whenever an HTTP POST request is issued through an HTML form. The

    parameters associated with the POST request are communicated from the browser to theserver as a separate HTTP request. The doPostmethod should be used whenevermodifications on the server will take place.

    doGet: Invoked whenever an HTTP GET method from a URL request is issued, or an HTMLform. An HTTP GET method is the default when a URL is specified in a Web browser. In

    contrast to the doPostmethod, doGetshould be used when no modifications will be made onthe server, or when the parameters are not sensitive data. The parameters associated with aGET request are appended to the end of the URL, and are passed into the Query String

    property of theHttpServletRequest.

    DestroyThe destroy method is called when the Web server unloads the servlet. A subclass of

    HttpServletonly needs to implement this method if it needs to perform cleanup operations,such as releasing database connections or closing files.Interfaces used in Servlet Life Cycle are

    1. Servlet

    The Servletinterface class is the central abstraction of the Java Servlet API.This class defines the methods which servlets must implement, including aservice () methodfor the handling of requests. The GenericServletclass implements this interface, and definesa generic, protocol-independent servlet.

    2. HttpServlet

    HttpServletprovides additional methods for the processing of HTTP requests such as GET(doGetmethod) and POST (doPostmethod).

    3. ServletConfig The most common form of the initmethod of the servlet accepts a ServletConfigobject parameter. This interface object allows the servlet to access name/value pairs ofinitialization parameters that are specific to that servlet. The ServletConfigobject also givesus access to the SevletContextobject that describes information about our servletenvironment. A method of the ServletConfig object allows to extract the parameterinformation from this object.

    4.ServletContext

    The ServletContextobject defines a servlets view of the Web application

    within which the servlet is running, and gives the servlet the ability to access resources thatare explicitly available to it. Using such an object, a servlet can log events, obtain URL

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    21/23

    references to resources, and get and set attributes at the application level that are available toother servlets in the same context, in much the same way as the set attributes at the requestand session level.

    5.ServletResponse

    Each request is represented by a ServletRequestobject and the corresponding response by aServletResponse object in the Java Servlet API.The ServletRequest interface to indicatewhether or not the request was transmitted via a secure transport such as HTTPS.

    6. ServletResponseThe output from the JSP is written directly to the ServletResponse Print Writerobject.

    (or)

    (b).Describe the operation of retrieval of a webpage with its associated messages

    using HTTP. (16)

    Retrieving data from Internet

    Internet Search Engines are used to locate resources in specific applicationcontent area and thus download text and graphics from the Internet. Also download audioand video resources from the Internet.Search Engines are used to find materials and research related information. Search Enginesare accessed by pointing the www browser to the address of the search engine. The searchengine will provide a blank text field into which, we type one or more keywords indicatingwhat we want.

    Retrieving Pictures, Sounds and MoviesAlta Vista not only download text but it can download images, video, audio based

    on searching given by the user. The quickest way to download text from the Internet is tocopy the text on to the window clipboard, from which user can paste the text into any otherwindow on the screen.

    The quickest way to download a graphic from the Internet is to use, webbrowsers option for saving the image to a file.Downloading Audio and Video from the Internet

    If the web browser supports the option to download links, download any audio orvideo file that has been linked to a webpage.HTTP Protocol:

    The Hyper Text Transfer Protocol (HTTP) is an application-level protocol withlightness and speed necessary for distributed, collaborative, Hyper-media informationsystems. HTTP has been in used by the World Wide Web global information.

    HTTP is also used as a generic protocol for communication between user agents

    and proxies/Gateways to other Internet protocols, such as SMTP, NNTP, FTP, Gopher andWAIS, allowing basic hypermedia access to resources available from diverse application andsimplifying the implementation of user Agents.Overall Operation

    The HTTP protocol is based on a request/response paradigm. A client establish a connectionwith a server and sends a request to the server in the form a request method, URI and

    protocol version, followed by a MIME-like message containing request modifiers, clientinformation and possible body content. The server response with a status line, including themessages protocol version and a success or error code, followed by a MIME like messagecontaining server information, Entity meta information and possible body content.

    Most HTTP communication is initiated by the user agent and consists of a requestto be applied to a resource on some origin server. In the simplest case, this may beaccomplished via a single connection (v) between the user agent (UA) and the origin

    http://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_b.htmlhttp://www.enggedu.com/tamilnadu/university_questions/question_answer/be_nd_2007/7th_sem/cse/cs1401/part_b/15_b.html
  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    22/23

    Server (O).

    HTTP Request Response Chain

    A more complicated situation occurs when one or more intermediaries are present inthe request/response chain. The are three common forms of intermediary: proxy, gateway,and tunnel.

    A proxy is a forwarding agent; receiving requests for a URI in its absolute form,rewriting all are parts of the message, and forwarding the reformatted request toward theserver identified by the URI.

    A gateway is a receiving agent, acting as layer above some other servers and, ifnecessary, translating the requests to the underlying servers protocol.

    A tunnel acts as a relay point between two connections without changing themessages; Tunnels are used when the communication needs to pass through an intermediary(such as firewall) even when the intermediary cannot understand the contents of themessages.

    Uniform Resource Identifiers

    URIs have been known by many names: WWW addresses, Universal DocumentIdentifiers, Universal Resource Identifiers and finally the combination of Uniform ResourceLocators(URL) and Names(URN).As far as HTTP is concerned, Uniform ResourceIdentifiers are simply formatted strings which identifyvia name, location, or any othercharacteristic a network resource.

    HTTP URLThe http scheme is used to locate network resources via the HTTP protocol. This

    sections defines the scheme-specific syntax and semantics for HTTP URLs.http_URL=http: // host [: port ] [abs_path ]host=port=*DIGIT

  • 8/14/2019 B.E/B.tech DEGREE EXAMINATION Nov/Dec 2007 Seventh Semester Computer Science And

    23/23

    If the port is empty or not given, port 80 is assumed.

    Request-URIThe Request URI is a Uniform Resource Identifier and identifies the resource upon

    which to apply the request.

    Request-URI=absolute URI|abs_pathThe two options for Request-URI are dependent on the nature of the request.The absolute URI form is only allowed when the request is being made to aproxy. The proxy is requested to forward the request and return the response. Ifthe request is GET or HEAD and a prior response is catched, the proxy may usethe catched message if it process any restrictions in the Expires header fields.

    The proxy may forward the request on to another proxy or directly to the serverspecified by the absolute URI. In order to avoid request loops, a proxy must beable to recognize all of its server names, including any aliases, local variationsand the numeric IP address. An example request line would be:

    GET http://www.w3.org/pub/www/theproject.html HTTP/1.10

    Request Header FieldsThe request header fields allow the client to pass additional informationabout a request, and about the client itself, to the server. These fields act asrequest modifiers, with semantics equivalent to the parameters on aprogramming language method (Procedure) invocation.Response

    After receiving and interpreting a request message, a server response inthe form of an HTTP response message.


Recommended