Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

CCS375 WT QB

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

8154-Sri Ramakrishna College of Engineering CCS375-Web Technologies

CCS375 – WEB TECHNOLOGIES

UNIT III - SERVER SIDE PROGRAMMING

PART-A

1. Write down the methods of servlet interface.


 void destroy()–called when the servlet is unloaded.
 ServletConfig getServletConfig() –returns a Servlet Config object that Contains any initialization
parameters.
 String getServletInfo()–returns a string describing the servlet.
 Void init(ServletConfig sc) throws ServletException–called when the servlet is initialized.
 Void Service(ServletRequest req,ServletResponse res) throws Servlet Exception,

2. What is the difference between CGI and servlets?


 Performance is significantly better, servlet execute within the address space of a web server.
 Servlets are platform independent
 The java security manager on the server enforces a set of restrictions to protect the resources on a server
machine.
 The full functionality of java class libraries is available to a servlet.

3. Define Servlet Life Cycle?


 init() method-invoked when the servlet is first loaded into memory
 service()-called for each HTTP request(for processing)
 destroy() –unloads the servlet from its memory.

4. What is JSP?
Java Server Pages (JSP) is a technology for developing web pages that support dynamic content
which helps developers insert java code in HTML pages by making use of special JSP tags, most of which
start with <% and end with %>.
5. What are advantages of using JSP?
a. Performance is significantly better because JSP allows embedding Dynamic Elements in HTML
Pages itself.
b. JSP are always compiled before it's processed by the server unlike CGI/Perl which requires the
server to load an interpreter and the target script each time the page is requested.
6. What are servlets?
Servlets are simple java programs that run on the server. The servlets are used along with the http
protocol. Hence sometimes they are also refered as http servlets. Servlets make use of standard packages
such as javax.servlet and javax.servlet.http.
7. What are the two commonly used Request methods? Differentiate it.
The two most common request methods used are GET and POST. The request methods tell the script how
it was invoked. Based on this information, the script decides how to act. The request method is passed to the
script using environment variable called REQUEST- METHOD.
Parameters GET POST

Data transmission limit Limited by URL length No limit

Mrs.C.Surya-AP/CSE
8154-Sri Ramakrishna College of Engineering CCS375-Web Technologies

Bookmarking and caching Possible Not possible

Effect on server state No changes Can modify server state

Usage Loading web pages, downloading files Form submissions, uploading files

8. Explain cookies.
Cookies are some little information that can be left on your computer by the other computer when we
access an internet. The information is stored in the cookies using the name value pair.
9. What is JDBC?
The JDBC stands for Java Database Connectivity. JDBC is nothing but an API. It consists of various classes,
interfaces, exceptions using which java application can send SQL statements to a database. JDBC is specially used
for the connectivity of java with RDBMS packages.
10. Write a note on Environment variables.
In CGI, the server prepares the environment variables before it launches the CGI script. These represent
the current state of the server that is asking for the information. The environment variables are not set from the
command line but are created on the fly, and lasts only until that particular script is finished. Each script gets its
own unique set of variables and multiple scripts can be executed at once, each in its own environment.
11. Explain about Session tracking.
A session is basically a conversation between a browser and a server. All the above technologies can
save information for the current session for a particular user visiting a site. The session is important, as H1TPis a
stateless protocol. This means that the connection between web server and a web browser is not automatically
maintained, and that the state of a web session is not saved.
PART-B

1. Describe in detail about Java Servlet Architecture (or) Servlets (or) Servlet Life cycle.
2. Discuss in detail about the classes and interfaces of Servlet API.
3. What is the difference between HTTP-GET and HTTP-POST request? Write a servlet which accepts two
numbers using POST methods and display the maximum of them. (or) any other sample programs.
4. Explain in detail about Servlet Database Connectivity with an example of student database.
5. Explain in detail about session tracking system.
6. Write a servlet to illustrate the principles of cookies and explain.

Mrs.C.Surya-AP/CSE
8154-Sri Ramakrishna College of Engineering CCS375-Web Technologies
CCS375 – WEB TECHNOLOGIES

UNIT IV – PHP AND XML

PART-A

1. What is PHP?
PHP - Hypertext Preprocessor -one of the most popular server-side
scripting languages for creating dynamic Web pages.
- an open-source technology
- platform independent
2. List the data types used in PHP.
Data types Description
Integer Whole numbers (i.e., numbers without a decimal point)
Double Real numbers (i.e., numbers containing a decimal point)
String Text enclosed in either single ('') or double ("") quotes.
Boolean True or false
Array Group of elements of the same type
Object Group of associated data and methods
Resource An external data source

3. How type conversion is done in PHP?


In PHP, data-type conversion can be performed by passing the data type as an argument to function
settype. Function settype takes two arguments: The variable whose data type is to be changed and the
variable’s new data type.
E.g., settype( $testString, "double" );
4. How to include PHP in a Web Page?
There are 4 ways of including PHP in a web page

1. <?php echo("Helloworld"); ?>


2. <script language = "php">echo("Hello world"); </script>
3. <? echo("Hello world"); ?>
4. <% echo("Hello world"); %>
we can also use print instead of echo
• Method (1) is clear and unambiguous
• Method (2) is useful in environments supporting mixed scripting
languages in the same HTML file
• Methods (3) and (4) depend on the server configuration
5. Write a simple PHP Script.
Here is PHP script which is embedded in HTML using level one headerwith the PHP
outputtext. The name of this file is called hello.php.
<html>
<head>
</head>
<body>
<h1><?php echo("Hello world"); ?></h1>
<h1><?php print("This
prints thesame
thing!");?></h1> </body>
<html>

Mrs.C.Surya-AP/CSE
8154-Sri Ramakrishna College of Engineering CCS375-Web Technologies

6. How do you include comments in PHP?

PHP supports three types of comments:


1. Shell style comments - denoted #THIS IS A COMMENT
2. C++ style comments - denoted THIS IS A COMMENT—
3. C style comments - denoted /* ALL THIS COMMENTED! */
7. Write a PHP script to set the background colour to blue on Tuesday in agiven date. <?php
if(date("D") =="Tue") $colour = "blue"; else $colour ="red";?>
<html>
<head>
<title>Welcome</title>
</head>
<body bgcolor = <?php echo($colour) ?>>
<h1>Welcome</h1>
</body>
</html>
8. What is XML namespace? (NOV/DEC 2012)
XML allows document authors to create custom elements. This extensibility can result in naming
collisions (i.e. different elements that have the same name) among elements in an XML document.
An XML namespace is a collection of element and attribute names. Each namespace has a unique name that
provides a means for document authors to unambiguously refer to elements with the same name (i.e. prevent
collisions).
9.Differentiate HTML and XML.
HTML XML

HTML stands for Hyper Text Markup Language. XML stands for Extensible Markup Language.

HTML is static in nature. XML is dynamic in nature.

HTML is a markup language. XML provides a framework to define markup languages.

HTML can ignore small errors. XML does not allow errors.

It has an extension of .html and .htm It has an extension of .xml

HTML is not Case sensitive. XML is Case sensitive.

HTML tags are predefined tags. XML tags are user-defined tags.

In HTML, closing tags are not necessary. In XML, closing tags are necessary.

10. What are variables in PHP?

Variables start with the $ symbol. E.g.:


$myInteger = 3;
$myString =”Hello World”;
$myFloat=3.145;

Mrs.C.Surya-AP/CSE
8154-Sri Ramakrishna College of Engineering CCS375-Web Technologies
11. How do you declare a variable using PHP data types?
Data types are not explicitly defined:
• Variable type is determined by assignment
• Strings can be defined with single ( ’ ) and double ( ") quotes.
• PHP has a Boolean type:Defined as false
– An integer or float value of 0 or
– The keyword false
– The empty string ‘‘’’ or the string ‘‘0’’
– An empty array or object
– The NULL valueDefined as true
– Any non-zero integer or float value
– The keyword true
• Standard operators with standard syntax applied to variables

12. How do you declare and initialize an array in PHP

Two ways of declaring and initializing an array:


a) Individual element initialization in an array
$myArray[0]= "Apples";
$myArray[1]= "Bananas";
b) Arrays can be constructed using the array() keyword
$person = array("Dave", "Adam", "Ralph");
PART-B

1. Describe in detail about basic fundamentals of PHP.


2. Write a PHP script to compute the sum and average of N numbers.
3. Write a PHP script to compute factorial of a number.
4. Write a PHP script to find whether the number is odd or even.
5. Form validation (2 programs)
6. XML schema / DTD
7. DOM with XML
8. XML parsers.

Mrs.C.Surya-AP/CSE

You might also like