313 31 – Web Technology – Part 2
1. Define assembly. What are the several types of assemblies? Explain them in detail
Assemblies are the fundamental units of deployment, version control, reuse, activation scoping, and
security permissions for . NET-based applications. An assembly is a collection of types and resources that
are built to work together and form a logical unit of functionality
In the .NET framework, there are two types of assemblies: private assemblies and shared assemblies.
These assemblies serve as units of deployment and encapsulate one or more .NET code modules, such
as classes, interfaces, resources, and metadata
2. How many types of rich controls are provided by ASP NET?
ASP.NET provides large set of controls.
These controls are divided into different categories, depends upon their functionalities. The followings
control comes under the rich controls category.
FileUpload control
Calendar control
AdRotator control
MultiView control
Wizard control
FileUpload control
FileUpload control is used to browse and upload files. After the file is uploaded, you can store the file on
any drive or database.
FileUpload control is the combination of a browse button and a text box for entering the filename.
The FileUpload control supports the following important properties.
FileBytes: It returns the contents of uploaded file as a byte array
FileContent: You can get the uploaded file contents as a stream.
FileName: Provides the name of uploaded file.
HasFile: It is a Boolean property that checks whether particular file is available or not.
PostedFile: Gets the uploaded file wrapped in the HttpPostedFile object
Calendar control
Calendar control provides you lots of property and events.
By using these properties and events you can perform the following task with calendar control.
Select date.
Selecting a day, a week or a month.
Customize the calendar's appearance.
AdRotator control
AdRotator control is used to display different advertisements randomly in a page.
The list of advertisements is stored in either an XML file or in a database table.
Lots of websites uses AdRotator control to display the advertisements on the web page.
To create an advertisement list, first add an XML file to your project.
Multi View Control
MultiView control can be used when you want to create a tabbed page.
In many situations, a web form may be very long, and then you can divide a long form into multiple sub
forms.
MultiView control is made up of multiple view controls.
You can put multiple ASP.NET controls inside view controls.
One View control is displayed at a time and it is called as the active view. View control does not work
separately.
It is always used with a Multiview control.
Wizard Control
This control is same as MultiView control but the main difference is that, it has inbuilt navigation
buttons.
The wizard control enables you to design a long form in such a way that you can work in multiple sub
form.
You can perform the task in a step by step process.
It reduces the work of developers to design multiple forms.
It enables you to create multi step user interface. Wizard control provides with built-in previous/next
functionality.
3. Explain about functions of javax.sql package
This package provides the APIs for accessing and processing data which is stored in the database
especially relational database by using the java programming language
It includes a framework where we different drivers can be installed dynamically to access
different databases especially relational databases.
Java.sql package contains the following set of interfaces and classes for easy implementation of
database access
The java.sql package contains API for the following:
1. Making a connection with a database via the DriverManager facility
DriverManager class -- makes a connection with a driver
SQLPermission class -- provides permission when code running within a Security Manager, such
as an applet, attempts to set up a logging stream through the DriverManager
Driver interface -- provides the API for registering and connecting drivers based on JDBC
technology ("JDBC drivers"); generally used only by the DriverManager class
DriverPropertyInfo class -- provides properties for a JDBC driver; not used by the general use
2. Sending SQL statements to a database
Statement -- used to send basic SQL statements
PreparedStatement -- used to send prepared statements or basic SQL statements (derived from
Statement)
CallableStatement -- used to call database stored procedures (derived from
PreparedStatement)
Connection interface -- provides methods for creating statements and managing connections
and their properties
Savepoint -- provides savepoints in a transaction
3. Retrieving and updating the results of a query
ResultSet interface
4. Standard mappings for SQL types to classes and interfaces in the Java programming
language
Array Interface Mapping for SQL Array
Date Class Mapping for Date Class
Time Class Mapping for Time Class
Time stamp class Mapping for SQL timestamp
5. Meta data
Database Meta Data Interface Provides information about the data base
ResultSet Meta Data Interface Provides information about the columns of Result Set Object
Exceptions
SQLException -- thrown by most methods when there is a problem accessing data and by some
methods for other reasons
SQLWarning -- thrown to indicate a warning
DataTruncation -- thrown to indicate that data may have been truncated
Write a JAVA client and server side Socket program to exchange the messages between them.
Example of Java Socket Programming (Read-Write both side)
In this example, client will write first to the server then server will receive and print the text. Then
server will write to the client and client will receive and print the text. The step goes on.
File: MyServer.java
import java.net.*;
import java.io.*;
class MyServer{
public static void main(String args[])throws Exception{
ServerSocket ss=new ServerSocket(3333);
Socket s=ss.accept();
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=din.readUTF();
System.out.println("client says: "+str);
str2=br.readLine();
dout.writeUTF(str2);
dout.flush();
}
din.close();
s.close();
ss.close();
}}
File: MyClient.java
import java.net.*;
import java.io.*;
class MyClient{
public static void main(String args[])throws Exception{
Socket s=new Socket("localhost",3333);
DataInputStream din=new DataInputStream(s.getInputStream());
DataOutputStream dout=new DataOutputStream(s.getOutputStream());
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str="",str2="";
while(!str.equals("stop")){
str=br.readLine();
dout.writeUTF(str);
dout.flush();
str2=din.readUTF();
System.out.println("Server says: "+str2);
}
dout.close();
s.close();
}}
Discuss Java Bean API in detail.
The Java Beans API
The Java Beans functionality is provided by a set of classes and interfaces in the java.beans package. This
section provides a brief overview of its contents. Table 37-1 lists the interfaces in java.beans and
provides a brief description of their functionality. Table 37-2 lists the classes in java.beans.
Class Descriptor
1. BeanDescriptor This class provides information about Bean, It also
allows you to associate a customizer with a bean
2. Encoder Encodes the state of a set of Beans, Can be used to
write this information to stream
3. Event Handler Supports Dynamic Event Listener Creation
4. Introspector This class analyzes a Bean and constructs a BeanInfo
Object that describes the component
5. Method Descriptor Instances of this class Describe a method of Bean
6. Parameter Descriptor Instances of this class describe a Method parameter
7. PersistenceDelegate Handles State information of an object
8. PropertyChangeEvent This event is generated when bound or constrained
properties are changed
9. XML Decoder Used to read a Bean from an XML Document
10. XML Encoder Used to Write a Bean to an XML Document
4. Write the uses of Tomcat web server.
It is mainly used to provide the foundation for hosting Java servlets.
The Apache Tomcat works in the center while Java Server Pages and Servlet produce the dynamic pages.
It is one of the server-side programming languages that facilitate the developer to run and perform
independent dynamic content creation.
Tomcat provides a robust and reliable server environment that ensures the smooth execution of Java-
based applications. It offers features such as automatic memory management, scalability, and support
for multiple web protocols.
What is meant by Package?
A java package is a group of similar types of classes, interfaces and sub-packages.
Package in java can be categorized in two form, built-in package and User Defined Package
Its mechanism to encapsulate a group of classes, sub packages and interfaces
Packages are used for Preventing Name conflicting
Providing Controlled access
Package can be considered as Data Encapsulation
7. State the problem with servlet.
Servlet is persistent until it destroys.
Designing in a servlet is difficult and slows down the application.
You need a JRE(Java Runtime Environment) on the server to run servlets.
For non-java developers, servlet is not suitable as they required to have a broad knowledge of
Java servlet.
HTML code is mixed up with Java code therefore, changes done in one code can affect another
code.
Writing HTML code in servlet programming is very difficult. It also makes servlet looks bulky
8. What is Run Time Error in JSP?
Errors which occur during program execution(run-time) after successful compilation are
called run-time errors.
One of the most common run-time error is division by zero also known as Division error.
These types of error are hard to find as the compiler doesn’t point to the line at which the
error occurs.
What is meant by Database?
A database is an organized collection of structured information, or data, typically stored electronically in
a computer system.
A database is usually controlled by a database management system (DBMS).
10. List out the properties in Java Beans.
Every JavaBeans class contains simple property, boolean property and indexed properties.
A simple property is one in which a method takes and returns elementary or single value (set of
set and get methods are known as simple properties of a JavaBeans class.)
A boolean property is one in which a method takes or return boolean value.
An indexed property is one in which a method takes or return array of values.
Bound Property - A bound property gives a JavaBean the capability of notifying another
JavaBean when there is a change to the value of that property
Write down HTML tags to explain frame within a frame.
The <frameset> tag in HTML is used to define the frameset. The <frameset> element contains one or
more frame elements.
It is used to specify the number of rows and columns in frameset with their pixel of spaces. Each
element can hold a separate document.
What are the various styles in CSS?
The three types of CSS are external, internal, and inline. External CSS is a file that HTML files will link to.
Internal CSS is specified at the beginning of an HTML document. Inline CSS is written for a specific
element in the HTML document.
3. How to declare variables in Javascript?
var geek = "Hello Geek" // Declaration using var
let $ = "Welcome" // Declaration using let
const _example = "Gfg" // Declaration using const
const keyword is used when we assign a value permanently to a variable. So when we try to change
the value of a variable declared with the const keyword it will throw an error. The variables declared
with var and let are mutable that is their value can be changed but variables declared using const are
immutable.
Define Document Object Module (DOM).
Document Object Model: DOM is a platform- and language-neutral interface that provides a standard
model of how the objects in an XML object are put together and a standard interface for accessing and
manipulating these objects and their inter-relationships.
The DOM is an interface that exposes an XML document as a tree structure comprised of nodes
The DOM allows you to programmatically navigate the tree and add, change and delete any of its
elements.
What is meant by Jave Servlet Deveklopment Kit (JSDK)?
Servlets are server-side programs. Servlets are loaded and executed by a web server. The Java Servlet
Development Kit (JSDK) is the reference implementation of the Java servlet API. It can be used for
developing, running, testing, and debugging of Java Servlets
7. Differentiate cookies from Session variables.
The data stored in a session variable is destroyed when the session ends while the data stored in cookies
will stay alive as they are stored on your local machine so the web browser can access them every time
you log in to a website.
A cookie is a small file that the server embeds on the user’s computer. Rather than stored on local
machine a session variable is stored on the server so client doesn’t have access to the details stored on
it
Session helps to maintain user states and information to all over the application. The session is secure
and transparent for the user. Cookies are used to store details in the end- user’s browser, so the web
server can track the end-user. Cookies are used to identify the user’s session identifier on the server
records so they are more secure way of storing user detail
8. Explain the various steps of JSP Compilation.
The compilation process involves three steps:
Parsing the JSP.
Turning the JSP into a servlet.
Compiling the servlet
9. Explain the general form of an URL.
URL stands for Uniform Resource Locator
Most web browsers display the URL of a web page above the page in an address bar. A typical URL could
have the form http://www.example.com/index.html , which indicates a protocol ( http ), a hostname
( www.example.com ), and a file name ( index. html ).
10. Difference between JDBC and ODBC.
ODBC JDBC
1. ODBC Stands for Open Database
1. JDBC Stands for Java database connectivity
Connectivity.
4. We can choose ODBC only Windows
4. We can use JDBC on any platform
platform.
5. Mostly ODBC Driver is developed in native
5. JDBC Stands for Java database connectivity.
languages like C, and C++.
6. For Java applications it is not recommended 6. For Java applications it is highly
to use ODBC because performance will be down recommended to use JDBC because there are
due to internal conversion and applications will no performance & platform dependent
become platform-dependent. problems.
7. ODBC is procedural. 7. JDBC is object-oriented.
Write short note on: Database actions in JSP