Menu bar

Showing posts with label WTPMATERIAL. Show all posts
Showing posts with label WTPMATERIAL. Show all posts

Friday, May 16, 2014

CGI INTRODUCTION

Dear Students,
Here is a brief introduction about CGI. If you want to understand more about perl click here

What is CGI ?

  • The Common Gateway Interface, or CGI, is a set of standards that define how information is exchanged between the web server and a custom script.
  • The CGI specs are currently maintained by the NCSA and NCSA defines CGI is as follows:
  • The Common Gateway Interface, or CGI, is a standard for external gateway programs to interface with information servers such as HTTP servers.
  • The current version is CGI/1.1 and CGI/1.2 is under progress.

Web Browsing

To understand the concept of CGI, lets see what happens when we click a hyper link to browse a particular web page or URL.
  • Your browser contacts the HTTP web server and demand for the URL ie. filename.
  • Web Server will parse the URL and will look for the filename in if it finds that file then sends back to the browser otherwise sends an error message indicating that you have requested a wrong file.
  • Web browser takes response from web server and displays either the received file or error message.
However, it is possible to set up the HTTP server so that whenever a file in a certain directory is requested that file is not sent back; instead it is executed as a program, and whatever that program outputs is sent back for your browser to display. This function is called the Common Gateway Interface or CGI and the programs are called CGI scripts. These CGI programs can be a PERL Script, Shell Script, C or C++ program etc.

CGI Architecture Diagram

CGI Architecture

Web Server Support & Configuration

Before you proceed with CGI Programming, make sure that your Web Server supports CGI and it is configured to handle CGI Programs. All the CGI Programs be executed by the HTTP server are kept in a pre-configured directory. This directory is called CGI Directory and by convention it is named as /cgi-bin. By convention PERL CGI files will have extention as .cgi.

First CGI Program

Here is a simple link which is linked to a CGI script called hello.cgi. This file is being kept in /cgi-bin/ directory and it has following content. Before running your CGI program make sure you have chage mode of file using chmod 755 hello.cgi UNIX command.
#!/usr/bin/perl

print "Content-type:text/html\r\n\r\n";
print '<html>';
print '<head>';
print '<title>Hello Word - First CGI Program</title>';
print '</head>';
print '<body>';
print '<h2>Hello Word! This is my first CGI program</h2>';
print '</body>';
print '</html>';

1;

If you click hello.cgi then this produces following output:

Hello Word! This is my first CGI program

This hello.cgi script is a simple PERL script which is writing its output on STDOUT file ie. screen. There is one important and extra feature available which is first line to be printed Content-type:text/html\r\n\r\n. This line is sent back to the browser and specifiy the content type to be displayed on the browser screen. Now you must have undertood basic concept of CGI and you can write many complicated CGI programs using PERL. This script can interact with any other exertnal system also to exchange information such as RDBMS.

HTTP Header

The line Content-type:text/html\r\n\r\n is part of HTTP header which is sent to the browser to understand the content. All the HTTP header will be in the following form
HTTP Field Name: Field Content

For Example
Content-type:text/html\r\n\r\n
There are few other important HTTP headers which you will use frequently in your CGI Programming.


HeaderDescription
Content-type: StringA MIME string defining the format of the file being returned. Example is Content-type:text/html
Expires: Date StringThe date the information becomes invalid. This should be used by the browser to decide when a page needs to be refreshed. A valid date string should be in the format 01 Jan 1998 12:00:00 GMT.
Location: URL StringThe URL that should be returned instead of the URL requested. You can use this filed to redirect a request to any file.
Last-modified: StringThe date of last modification of the resource.
Content-length: StringThe length, in bytes, of the data being returned. The browser uses this value to report the estimated download time for a file.
Set-Cookie: StringSet the cookie passed through the string

CGI Environment Variables

All the CGI program will have access to the following environment variables. These variables play an important role while writing any CGI program.
Variable NameDescription
CONTENT_TYPEThe data type of the content. Used when the client is sending attached content to the server. For example file upload etc.
CONTENT_LENGTHThe length of the query information. It's available only for POST requests
HTTP_COOKIEReturn the set cookies in the form of key & value pair.
HTTP_USER_AGENTThe User-Agent request-header field contains information about the user agent originating the request. Its name of the web browser.
PATH_INFOThe path for the CGI script.
QUERY_STRINGThe URL-encoded information that is sent with GET method request.
REMOTE_ADDRThe IP address of the remote host making the request. This can be useful for logging or for authentication purpose.
REMOTE_HOSTThe fully qualified name of the host making the request. If this information is not available then REMOTE_ADDR can be used to get IR address.
REQUEST_METHODThe method used to make the request. The most common methods are GET and POST.
SCRIPT_FILENAMEThe full path to the CGI script.
SCRIPT_NAMEThe name of the CGI script.
SERVER_NAMEThe server's hostname or IP Address
SERVER_SOFTWAREThe name and version of the software the server is running.


Here is small CGI program to list out all the CGI variables. Click this link to see the result Get Environment


#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "<font size=+1>Environment</font>\n";
foreach (sort keys %ENV)
{
  print "<b>$_</b>: $ENV{$_}<br>\n";
}

1;

How To Raise a "File Download" Dialog Box ?

Sometime it is desired that you want to give option where a use will click a link and it will pop up a "File Download" dialogue box to the user in stead of displaying actual content. This is very easy and will be achived through HTTP header.
This HTTP header will be different from the header mentioned in previous section.
For example,if you want make a FileName file downloadable from a given link then its syntax will be as follows.
#!/usr/bin/perl

# HTTP Header
print "Content-Type:application/octet-stream; name=\"FileName\"\r\n";
print "Content-Disposition: attachment; filename=\"FileName\"\r\n\n";

# Actual File Content will go hear.
open( FILE, "<FileName" );
while(read(FILE, $buffer, 100) )
{
   print("$buffer");
}

GET and POST Methods

You must have come across many situations when you need to pass some information from your browser to web server and ultimately to your CGI Program. Most frequently browser uses two methods two pass this information to web server. These methods are GET Method and POST Method.

Passing Information using GET method:

The GET method sends the encoded user information appended to the page request. The page and the encoded information are separated by the ? character as follows:
http://www.test.com/cgi-bin/hello.cgi?key1=value1&key2=value2
The GET method is the defualt method to pass information from browser to web server and it produces a long string that appears in your browser's Location:box. Never use the GET method if you have password or other sensitive information to pass to the server. The GET method has size limtation: only 1024 characters can be in a request string.
This information is passed using QUERY_STRING header and will be accessible in your CGI Program through QUERY_STRING environment variable
You can pass information by simply concatenating key and value pairs alongwith any URL or you can use HTML <FORM> tags to pass information using GET method.

Simple URL Example : Get Method

Here is a simple URL which will pass two values to hello_get.cgi program using GET method.
http://www.tutorialspoint.com/cgi-bin/hello_get.cgi?first_name=ZARA&last_name=ALI
Below is hello_get.cgi script to handle input given by web browser.
#!/usr/bin/perl

    local ($buffer, @pairs, $pair, $name, $value, %FORM);
    # Read in text
    $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "GET")
    {
 $buffer = $ENV{'QUERY_STRING'};
    }
    # Split information into name/value pairs
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%(..)/pack("C", hex($1))/eg;
 $FORM{$name} = $value;
    }
    $first_name = $FORM{first_name};
    $last_name  = $FORM{last_name};

print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>Hello - Second CGI Program</title>";
print "</head>";
print "<body>";
print "<h2>Hello $first_name $last_name - Second CGI Program</h2>";
print "</body>";
print "</html>";

1;

Simple FORM Example: GET Method

Here is a simple example which passes two values using HTML FORM and submit button. We are going to use same CGI script hello_get.cgi to handle this imput.
<FORM action="/cgi-bin/hello_get.cgi" method="GET">
First Name: <input type="text" name="first_name">  <br>

Last Name: <input type="text" name="last_name">
<input type="submit" value="Submit">
</FORM>
Here is the actual output of the above form, You enter First and Last Name and then click submit button to see the result.


First Name:

Last Name:


Passing Information using POST method:

A generally more reliable method of passing information to a CGI program is the POST method. This packages the information in exactly the same way as GET methods, but instead of sending it as a text string after a ? in the URL it sends it as a separate message. This message comes into the CGI script in the form of the standard input.
Below is hello_post.cgi script to handle input given by web browser. This script will handle GET as well as POST method.
#!/usr/bin/perl

    local ($buffer, @pairs, $pair, $name, $value, %FORM);
    # Read in text
    $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "POST")
    {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    }else {
 $buffer = $ENV{'QUERY_STRING'};
    }
    # Split information into name/value pairs
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%(..)/pack("C", hex($1))/eg;
 $FORM{$name} = $value;
    }
    $first_name = $FORM{first_name};
    $last_name  = $FORM{last_name};

print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>Hello - Second CGI Program</title>";
print "</head>";
print "<body>";
print "<h2>Hello $first_name $last_name - Second CGI Program</h2>";
print "</body>";
print "</html>";

1;
Let us take again same examle as above, which passes two values using HTML FORM and submit button. We are going to use CGI script hello_post.cgi to handle this imput.
<FORM action="/cgi-bin/hello_post.cgi" method="POST">
First Name: <input type="text" name="first_name">  <br>

Last Name: <input type="text" name="last_name">

<input type="submit" value="Submit">
</FORM>
Here is the actual output of the above form, You enter First and Last Name and then click submit button to see the result.


First Name:

Last Name:


Passing Checkbox Data to CGI Program

Checkboxes are used when more than one option is required to be selected.
Here is example HTML code for a form with two checkboxes
<form action="/cgi-bin/checkbox.cgi" method="POST" target="_blank">
<input type="checkbox" name="maths" value="on"> Maths
<input type="checkbox" name="physics" value="on"> Physics
<input type="submit" value="Select Subject">
</form>
The result of this code is the following form
Maths Physics
Below is checkbox.cgi script to handle input given by web browser for radio button.
#!/usr/bin/perl

    local ($buffer, @pairs, $pair, $name, $value, %FORM);
    # Read in text
    $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "POST")
    {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    }else {
 $buffer = $ENV{'QUERY_STRING'};
    }
    # Split information into name/value pairs
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%(..)/pack("C", hex($1))/eg;
 $FORM{$name} = $value;
    }
    if( $FORM{maths} ){
        $maths_flag ="ON";
    }else{
        $maths_flag ="OFF";
    }
    if( $FORM{physics} ){
        $physics_flag ="ON";
    }else{
        $physics_flag ="OFF";
    }

print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>Checkbox - Third CGI Program</title>";
print "</head>";
print "<body>";
print "<h2> CheckBox Maths is : $maths_flag</h2>";
print "<h2> CheckBox Physics is : $physics_flag</h2>";
print "</body>";
print "</html>";

1;

Passing Radio Button Data to CGI Program

Radio Buttons are used when only one option is required to be selected.
Here is example HTML code for a form with two radio button:
<form action="/cgi-bin/radiobutton.cgi" method="POST" target="_blank">
<input type="radio" name="subject" value="maths"> Maths
<input type="radio" name="subject" value="physics"> Physics
<input type="submit" value="Select Subject">
</form>
The result of this code is the following form
Maths Physics 
Below is radiobutton.cgi script to handle input given by web browser for radio button.
#!/usr/bin/perl

    local ($buffer, @pairs, $pair, $name, $value, %FORM);
    # Read in text
    $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "POST")
    {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    }else {
 $buffer = $ENV{'QUERY_STRING'};
    }
    # Split information into name/value pairs
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%(..)/pack("C", hex($1))/eg;
 $FORM{$name} = $value;
    }
    $subject = $FORM{subject};

print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>Radio - Fourth CGI Program</title>";
print "</head>";
print "<body>";
print "<h2> Selected Subject is $subject</h2>";
print "</body>";
print "</html>";

1;

Passing Text Area Data to CGI Program

TEXTAREA element is used when multiline text has to be passed to the CGI Program.
Here is example HTML code for a form with a TEXTAREA box:
<form action="/cgi-bin/textarea.cgi" method="POST" target="_blank">
<textarea name="textcontent" cols=40 rows=4>
Type your text here...
</textarea>
<input type="submit" value="Submit">
</form>
The result of this code is the following form
Below is textarea.cgi script to handle input given by web browser.
#!/usr/bin/perl

    local ($buffer, @pairs, $pair, $name, $value, %FORM);
    # Read in text
    $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "POST")
    {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    }else {
 $buffer = $ENV{'QUERY_STRING'};
    }
    # Split information into name/value pairs
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%(..)/pack("C", hex($1))/eg;
 $FORM{$name} = $value;
    }
    $text_content = $FORM{textcontent};

print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>Text Area - Fifth CGI Program</title>";
print "</head>";
print "<body>";
print "<h2> Entered Text Content is $text_content</h2>";
print "</body>";
print "</html>";

1;

Passing Drop Down Box Data to CGI Program

Drop Down Box is used when we have many options available but only one or two will be selected.
Here is example HTML code for a form with one drop down box
<form action="/cgi-bin/dropdown.cgi" method="POST" target="_blank">
<select name="dropdown">
<option value="Maths" selected>Maths</option>
<option value="Physics">Physics</option>
</select>
<input type="submit" value="Submit">
</form>
The result of this code is the following form
Below is dropdown.cgi script to handle input given by web browser.
#!/usr/bin/perl

    local ($buffer, @pairs, $pair, $name, $value, %FORM);
    # Read in text
    $ENV{'REQUEST_METHOD'} =~ tr/a-z/A-Z/;
    if ($ENV{'REQUEST_METHOD'} eq "POST")
    {
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    }else {
 $buffer = $ENV{'QUERY_STRING'};
    }
    # Split information into name/value pairs
    @pairs = split(/&/, $buffer);
    foreach $pair (@pairs)
    {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%(..)/pack("C", hex($1))/eg;
 $FORM{$name} = $value;
    }
    $subject = $FORM{dropdown};

print "Content-type:text/html\r\n\r\n";
print "<html>";
print "<head>";
print "<title>Dropdown Box - Sixth CGI Program</title>";
print "</head>";
print "<body>";
print "<h2> Selected Subject is $subject</h2>";
print "</body>";
print "</html>";

1;

Using Cookies in CGI

HTTP protocol is a stateless protocol. But for a commercial website it is required to maintain session information among different pages. For example one user registration ends after completing many pages. But how to maintain user's session information across all the web pages.
In many situations, using cookies is the most efficient method of remembering and tracking preferences, purchases, commissions, and other information required for better visitor experience or site statistics.

How It Works

Your server sends some data to the visitor's browser in the form of a cookie. The browser may accept the cookie. If it does, it is stored as a plain text record on the visitor's hard drive. Now, when the visitor arrives at another page on your site, the cookie is available for retrieval. Once retrieved, your server knows/remembers what was stored.
Cookies are a plain text data record of 5 variable-length fields:
  • Expires : The date the cookie will expire. If this is blank, the cookie will expire when the visitor quits the browser.
  • Domain : The domain name of your site.
  • Path : The path to the directory or web page that set the cookie. This may be blank if you want to retrieve the cookie from any directory or page.
  • Secure : If this field contains the word "secure" then the cookie may only be retrieved with a secure server. If this field is blank, no such restriction exists.
  • Name=Value : Cookies are set and retrviewed in the form of key and value pairs.

Setting up Cookies

This is very easy to send cookies to browser. These cookies will be sent along with HTTP Header. Assuming you want to set UserID and Password as cookies. So it will be done as follows
#!/usr/bin/perl

print "Set-Cookie:UserID=XYZ;\n";
print "Set-Cookie:Password=XYZ123;\n";
print "Set-Cookie:Expires=Tuesday, 31-Dec-2007 23:12:40 GMT";\n";
print "Set-Cookie:Domain=www.tutorialspoint.com;\n";
print "Set-Cookie:Path=/perl;\n";
print "Content-type:text/html\r\n\r\n";
...........Rest of the HTML Content....
From this example you must have understood how to set cookies. We use Set-Cookie HTTP header to set cookies.
Here it is optional to set cookies attributes like Expires, Domain, and Path. It is notable that cookies are set before sending magic line "Content-type:text/html\r\n\r\n.

Retrieving Cookies

This is very easy to retrieve all the set cookies. Cookies are stored in CGI environment variable HTTP_COOKIE and they will have following form.
key1=value1;key2=value2;key3=value3....
Here is an example of how to retrieving cookies.
#!/usr/bin/perl
  $rcvd_cookies = $ENV{'HTTP_COOKIE'};
  @cookies = split /;/, $rcvd_cookies;
  foreach $cookie ( @cookies ){
     ($key, $val) = split(/=/, $cookie); # splits on the first =.
     $key =~ s/^\s+//;
     $val =~ s/^\s+//;
     $key =~ s/\s+$//;
     $val =~ s/\s+$//;
     if( $key eq "UserID" ){
        $user_id = $val;
     }elsif($key eq "Password"){
        $password = $val;
     }
  }
print "User ID  = $user_id\n";
print "Password = $password\n";

This will produce following result
User ID = XYZ
Password = XYZ123

CGI Modules and Libraries

You will find many built-in modules over the internet which provide you direct functions to use in your CGI program. Following are the important once.

Thursday, April 24, 2014

WTP Question Bank

Sample questions for WTP and WAD**


HTML

  • Explain the following HTTP command
    GET /index.html HTTP/1.0 (4 Marks)
  • Write HTML tags to generate the following output. (3 Marks)
    Position
    Name
    CIty
    Sales
    Manager
    I. Hawthron Shield
    II. Green Sheild
    A. UK
    B. Netherland
  • How can a browser be stopped from caching a page? (2 Marks)
  • How Divide and Pound symbol can be put on HTML document? (2 Marks)
  • Show the use of inline frame in XHTML document. (3 Marks)
  • Explain the following HTML tags. (4 Marks)
    a. <dl> </dl>
    b. <input type=”file”/>
  • Answer the following with respect to web design. (7 Marks)
    1. Bowser compatibility issue and its possible solution.
    2. What is navigation? Discuss the characteristics of effective navigation.
  • What is an HTML form? Discuss the different form attributes and design
    a simple form to register for new semester. (7 Marks)
  • Explain following terms with example. (4 Marks)
    <optgroup>, <span>

CSS

  • Write the following styles in separate CSS file and also show how to link this CSS file in HTML file and show use of styles. (7 Marks)
    (i) The headings should have normal font style and font’s size should be 120%
    (ii) Define a class arial for paragraph which defines font family
    arial and font style bold.
    (iii) Apply a background color yellow and apply a
    background image “browntile.jpg”
  • What is the difference between class and id? How can a style rule be defined with an id redheading that gives red color to heading h1
    with text of heading right aligned? What would be the output of
    the following code in relation tostyle defined in this problem? (7 Marks)
    <h2 id=”redheading”> This is red heading</h2>
    <p id=”redheading”> This is red heading</p>
    <h1 id=”redheading”> This is red heading</h1>
  • What is CSS? Explain different ways to write the CSS and show the
    importance of “id” and “class” in CSS. (7 Marks)
  • Define CSS. Enlist and explain methods of using CSS in web page.
    Specify the CSS to provide; link: after visited blue color and before
    visited red color, table with odd rows white and even rows blue color. (7 Marks)
  • Explain CSS with all types. Explain BOX MODEL. (7 Marks)
  • Write down HTML/CSS code to create table with 5 rows and 3 columns. Even no. of rows display in green color and odd no.of rows display in
    yellow color. (7 Marks)

JavaScript

  • Write a JAVAScript to print characters of a string at odd positions.(for example for the string India, I, d and a should get printed). (4 Marks)
  • Write a JAVAScript to take2 digit number and then separate these 2 digits, then multiply first digit by itself for second digit times.( for example, 23 should be separated as 2 and 3. 2 should multiply with itself 3 times). (3 Marks)
  • Explain document object in JavaScript. (3 Marks)
  • How user defined objects are created in JAVAScript? How a
    constructor can be used to populate data in the object? (7 Marks)
  • Show the use of events to change background color with DHTML. If mouse button is pressed, background color
    should be red. If mouse button is released up, background color should be yellow (3 Marks)
  • Design an login form using HTML and JavaScript with following
    validations on password field : minimum length 8 characters, it should
    have some special character (7 Marks)
  • Why do you need validation? Show the use of regular expression in
    JavaScript to validate the email address with example. (7 Marks)
  • What are JavaScript objects? List the important built-in objects. How can
    you write your own object? (7 Marks)
  • Explain the event handling in JavaScript with simple example. (3 Marks)
  • Differentiate between HTML and XHTML. Write XHTML to generate table having following structure: (3 Marks)
    First
    Second
    Third
    Computer
    Civil

    Result
    :
  • Explain DOM structure of HTML. Write using JavaScript: how to know which mouse button was clicked, number of elements in form, and write
    hello world. (7 Marks)
  • Define DHTML. Explain onLoad, onBlur, image preloading, change
    image size, mouse curser position (7 Marks)
  • Differentiate between server side and client side scripting languages.
    Write HTML and JavaScript to take input for loginname, password,
    birthdate, email address, phone no. and validate them. (7 Marks)
  • What are differences between client side and server side scripting
    language? Write down java script code to check mobile number ( mobile
    number should start with 9 or 8) and mail id(check @ and .). (7 Marks)
  • Write down java script code to validate user name and password
    (password length must in between 6 to 12 characters. User name should
    not start with _, @, or any number, both are not blank). (7 Marks)

XML, XSLT, XSL, XHTML

  • Explain the document structure of XHTML document (4 Marks)
  • Explain the use of XSL Elements value-of, for-each, sort with example. (7 Marks)
  • Explain the two ways in which XML parser checks whether a
    document follows the expected order and structure. (7 Marks)
  • Give the document structure for the XHML document and give the
    characteristics which differentiate it from HTML (7 Marks)
  • What is DTD? Give and explain the sample DTD. (4 Marks)
  • XSL transformation (7 Marks)
  • Compare and contrast between HTML and XML. Write any XML
    document and DTD to describe itsstructure including elements,
    attributes and entities. (7 Marks)
  • Explain XSL and XSLT using example. (7 Marks)
  • Explain importance of DOCUMENT_ROOT and specify the same for
    apache web server. Specify the name and path for configuration file,
    error log file, access log file of apache. How to change the default file
    type being responded by web server. Define dynamic IP. Consider all in
    the question w.r.to Unix/Linux. (7 Marks)
  • Generate XML file from below code: (4 Marks)
    <!DOCTYPE NEWSPAPER [
    <!ELEMENT NEWS(ARTICLE+)>
    <!ELEMENT ARTICLE(HEADLINE, BODY, NOTES)>
    <!ELEMENT HEADLINE(#PCDATA)>
    <!ELEMENT BODY(#PCDATA)>
    <!ELEMENT NOTES(#PCDATA)>
    <!ATTLIST ARTICLE AUTHOR CDATA #REQUIRED>
    <!ATTLIST ARTICLE EDITOR CDATA #IMPLIED>
  • Explain following terms: <xs: sequence>, <value-of>, <for-each> (3 Marks)
  • What is XML ELEMENT and XML Schema? Explain CDATA and PCDATA with example. (7 Marks)

PHP

  • Write modules using HTML and PHP to store information of employee (employee id, job title, years of experience) in an array.
    And output the data to a web page by arranging the employees in
    ascending order of experience. (7 Marks)
  • Create a database called country and create table called city having fields (cityname, area, population)using PHP commands. Create an HTML form to get the city data and write a script to insert that data into the table. (7 Marks)
  • Write PHP programs to (7 Marks)
    1. To print whether current year is leap year or not.
    2. To print whether given number is odd or even.
  • Write PHP program to print first 10 Fibonacci numbers.
  • What are the different types of arrays in PHP? Explain with example to
    process the arrays in PHP. (7 Marks)
  • What are cookies? Explain the cookies handling in PHP with proper example. (7 Marks)
  • Explain the following with respect to PHP. (7 Marks)
    1. Sending an email
    2. String processing
  • How can you connect to database in PHP? Show the simple database
    operation using PHP with proper example. (7 Marks)
  • Explain different ways to pass information from one web page to other(s). Write a PHP program to explain any two ways. (7 Marks)
  • Write a note on server side include. Write a PHP program to
    demonstrate the same. (7 Marks)
  • Write a PHP program to parse and validate XML file using DTD (7 Marks)
  • Write a PHP program to create MySQL database and table; insert,
    retrieve data from table, alter the table to add a column and add data in
    that new column (7 Marks)
  • Explain need of URL redirection. Write the same in PHP, HTML and JavaScript. (7 Marks)
  • Explain variable function and magic methods using PHP program. (7 Marks)
  • How do you create cookie in PHP? Give difference between session and cookie with example. (7 Marks)
  • What’s myadmin and database bug. What’s function in PHP? Explain types of function with example. (7 Marks)
  • What’s PHP? Write down source code to create database and retrieve data with connection of PHP. (7 Marks)
  • How do you connect to server with PHP? Explain withexample. (7 Marks)
  • What are basic commands of PHP? Explain with example. (7 Marks)

Other

  • Explain the architecture of the browser. (3 Marks)
  • What role does the following parameter play in web site design issues? (4 Marks)
    a. Bandwidth and cache
    b. sitemap
  • Explain RSS <item> elements with example. (7 Marks)
  • What is a blog? (4 Marks)
  • What are Web feeds? (3 Marks)
  • Explain elements of SOAP with XML (7 Marks)
  • What is stored in Content-Type header for a SOAP request and response? (4 Marks)
  • What is the need for web service? (3 Marks)
  • What do you mean by planning a website? Discuss about the objectives
    and goals, and target audience in detail with proper example. (7 Marks)
  • How do you identify the contents for your website? How do you organize
    them for easy and quick access? Discuss with some real example. (7 Marks)
  • Web feeds (3 Marks)
  • Enlist and explain the website design principles. (7 Marks)
  • Specify port numbers for httpd and mysqld services. (1 Mark)
  • Explain need and working of web services with diagram. (7 Marks)
  • Explain web feed and blogs with their importance and in specific
    situation where they should be used. (7 Marks)
  • Explain the settings required for apache web server and PHP to run PHP programs. Mention how to do the following: consider all the questions
    w.r.to Unix/Linux. (7 Marks)
    – Start mysql and apache services and how to check status.
    – Take backup of mysql database tables and how to restore them.
    – How logging of web server users.
  • Explain following terms: URI, Web browser, HTTP (3 Marks)
  • Give the answer of following question. (7 Marks)
    i) Justify it:” HTTP is called as stateless protocol”.
    ii) How can you open a link in a new browser window?
    iii) What’s the correct syntax for referring to an external script called
    “abs.js”?
    1) <script href=”abc.js”>
    2) <script src=”abc.js”>
    3) <script target=”abc.js”>
    iv) What is difference between Java script and JAVA?
    v) Give difference between DTD and XML schema.
    vi) Justify it: “Java script is used in validation techniques”.
    vii) Which file can be configured for Apache Web Server?
  • What’s contribution of SOAP, Web feeds and BLOGS toweb services? What is aggregation in web services? (7 Marks)
  • What’s SOAP? Explain structure of SOAP. (7 Marks)
  • Explain Web server. Give difference between IIS and Apache Web Server? Write down only steps of UNIX/LINUX web server. (7 Marks)
    What is the relation ship among SOAP, XML, and HTTP? Explain with example (7 Marks)
**These questions are solely for your reference purpose and further understanding it may or may not be asked in the GTU Examination. First solve your textbook questions and university papers and then try to solve these questions.