Вы находитесь на странице: 1из 12

ASSIGNMENT

DRIVE SPRING 2014


PROGRAM MBA IT (SEM 4)
SUBJECT CODE & NAME MI0041- JAVA AND WEB DESIGN
BK ID B1327
CREDITS 4
MARKS 60

Q. 1 Write down what the following tags will perform
a. <table>
b. <td width>
c. <embed>
d. <a>
e. <object>

Answer: a. <TABLE>
The HTML tables basically consist of three elements rows, columns and cells. These tables are powerful
tools used in creating Web pages for providing precise structure or position to the content that you insert
on the Web page.
The most important function of table is to display text and numeric information in rows and columns.
The next important use of tables is to place Web content for example, text, images and so on in individual
table cells. This enables you to organize the content properly on the Web page. Therefore, by organising
the rows and columns of the Web page you can organize the entire Web page.
It allows you to align text in tables. You can see an example of this on our Support page. How you do this
is start with <Table> and if you want borders, just use the below commands.

<table>
<tr><td>Good</td></tr>
</table>

b. <td width>
To fix the width of the table we use the attribute width. For example:

<table border="1" width=200>

In the above code the entire width of the table is 200 pixels. You can vary the width by changing the
value that you pass to the attribute.

c. <embed>
This HTML tag is used to add multimedia elements like video, audio, images and so on, on the Web page.
Now let us learn how to use this tag to insert a multimedia file. The syntax show below explains how to
use this tag.

<embed src="value"></embed>

In the above syntax you can see that we use the attribute "src" to pass the file name or the URL of the
multimedia file which is mentioned using the term "value" in the syntax. The "value" can be a file name
or URL of the location of the file. If you use that file name you have to make sure that you also provide
the extension of the file. The example code given below shows how to use the <embed> tag to insert an
image with the file name "video.avi" which is a video file.

<embed src="video.avi"></embed>


d. <a>
This is a hyperlink tag. On the Web page if you want to include a hyperlink to a media file you can use
this tag. Example:

<a href="value">Text</a>

The above syntax shows how you can provide hyperlink to a media file. In the above syntax, the "value"
is the Uniform Resource Locator (URL) or file name of the document that you want to link to and the
"Text" can be a single word or sentence which is displayed on the Web page as a hyperlink to the "value".
We need to know that the "value" can be a file of any format such as audio, video, graphic and so on. You
will be able to link to that particular file and open it when you click on the hyperlinked text.

e. <object>
The World Wide Web Consortium (W3C) recommended to use <object> tag instead of <embed> tag to
add multimedia files on to the Web page. This was because, most of the latest versions of the browsers
supported only <object> tag. The object element is created using the opening and closing tags, <object>
and </object>. The below example code helps us to understand how to use the <object> tag to insert the
multimedia file on the Web page.

<object data="audio.mid" type="audio/midi"></object>

You can see in the above code that we are using two attributes namely "data" and "type". These attributes
are used to specify the file type. Where, the attribute "data" specifies the URL or file name that you want
to pass to the object. Similar to the attributes "href" and "src" used with <a> and <embed> tags, here also
we need to provide the file name along with the extension specifying the file format. The "type" attribute
specifies the Multipurpose Internet Mail Extensions (MIME) type of the file that you refer in the "data"
attribute. The MIME is an Internet standard that specifies the format of the data that you want to
transferee. This standard has a collection of various media formats that the Internet supports for data
exchange via Internet. This can be text, images, audio, and video and so on.

Q.2 Write short notes on
a. Web browsers

Answer: The World Wide Web created in 1990 was the first Web browser. However, later this name
was changed to Nexus to avoid confusion with the World Wide Web. Today, there are a number of Web
browsers available in the market for example, the Internet Explores (IE), Firefox, Flock, Web 2.0, Safari,
Opera, and so on.
Let us now study the two main functions of a Web browser:

To make a request for a page from a computer. You can do this by typing the URL of the page in
the address field of the browser. Even when you click on a hyperlink the similar action that of
accessing the Web page associated with the URL is performed by the browser.

To interpret the HTML page sent back by the Web server. This is done because the HTML text
received from the Web server is in the American Standard Code for Information Interchange
(ASCII) form. The Web browser, after receiving this text interprets it and creates the page in its
original form.

A web browser (commonly referred to as a browser) is a software application for retrieving, presenting
and traversing information resources on the World Wide Web. An information resource is identified by a
Uniform Resource Identifier (URI/URL) and may be a web page, image, video or other piece of content.
Hyperlinks present in resources enable users easily to navigate their browsers to related resources.
Although browsers are primarily intended to use the World Wide Web, they can also be used to access
information provided by web servers in private networks or files in file systems.

Figure shows the Microsofts Internet Explorer Web browser. The arrows point to the features that are
available on the Web browser along with the name of the corresponding feature mentioned at the other
end of the arrow.


Address field: This is the area on the browser window where you enter the Web page address or
URL. At the right end of this area, there is a small arrow pointing towards the menu bar, when
you click this arrow you will view a list of some of the Websites that you have visited recently.
When you click on these URLs you will view the respective Website or else you can directly
enter the address in the address field. After you enter the address you can either press "Enter" or
click on the "Go" button (which is present next to the downward facing arrow button in some
browsers).
Back and forward buttons: The back button is used to go back to the previous page that you have
opened in a particular browser window. The forward button allows you to view pages that you
have previously viewed in that browser window. In some browsers, there is a small arrow
pointing towards the menu bar arrow right next to these buttons, when you click this arrow you
will see the list of Websites that you have visited after opening the browser window.
Home button: When you click this button you will be able to view the page that you have set as
home page. A home page is a default page that opens when you open the browser window.
Menu bar: A menu bar is a part of each browser window, it contains menus like File, Edit, View,
Favourites or Bookmarks, Tools and Help.
Refresh or reload: When you click the refresh or reload button, the page is updated. For example,
if you think that the contents of a browser window may have changed since the last time you
viewed it, you can click this button to update the page.
Security indicators: At the left corner of the window, a lock icon appears when you use a
browser and this is called padlock. If the padlock is in a lock position then you can say that your
server connection is secure, i.e. the data being sent and received by the server is encrypted. This
indicates that nobody else can access this data. There is another way to find out whether your
browser is secure or not and that is done by looking at the URL. If the URL of your Website
begins with "https://" for example, you enter an address "www.gofind.com" in the address field
and press enter or click "Go" then automatically the address changes to
"https://www.gofind.com" indicating that your browser connection is secure.

Status bar: This is a bar at the bottom of the browser window which indicates the URL of the
Web page currently being loaded into the browser window. It also displays the URL of the link
on which the cursor of your mouse is placed. While loading, the Web page shows a progress
indicator which shows how much percentage of a file has been downloaded.
Stop button: This button is used to stop the browser from loading the Web page on to the
browsing window.
b. Web development tools:

Web development tools allow web developers to test and debug their code. They are different
from website builders and IDEs in that they do not assist in the direct creation of a webpage,
rather they are tools used for testing the user facing interface of a website or web application.
Moreover Web development tools are software that enables you to design Web pages easily and
efficiently. The Web development tools enable you, as a designer to design the Web page under
controlled conditions within a short span of time. Let us not go for an in depth analysis of these tools but,
we shall learn some of most popular tools that are used by the professional Web designers for creating
Web pages.
You can use Web development tools mainly for editing and viewing the Web page, testing the codes
written using a mark-up language, and previewing the working of codes written before it is actually used
on the platform for which it is designed.

Let us now learn few popular tools that are used by Web designers:
Dreamweaver: This Web development software tool was initially created by
Macromedia and now it is a part of Adobe System. We can see that the initial versions of
this tool comprised of simple HTML based editors. From the last 10 to 15 years
Dreamweaver has been the most popular Web development tool that is used by the Web
developers. It currently holds 80% of the HTML editor market in the world and rated as
the most preferred HTML editor.
Frontpage: This is a product of Microsoft. You can use this tool for designing and
editing Web pages. There is no need for you to learn HTML to use the Frontpage editor.
This is because the editor creates or generates all the HTML tags and other features like
CSS, frames and so on by itself. Using the Frontpage editor's HTML view you can enter
text, edit HTML tags and also use the standard Microsoft Word commands such as Cut,
Paste, Find and Replace, and so on. Therefore, using Frontpage editor for creating your
Web page is as simple as creating a word document using Microsoft Word.

Q.3 Write a programme to create a webpage that prints the name of the STUDENT database in
Wide Latin font and set the subtitle with description of the STUDENT to the screen. Set the page
layout to the webpage. Insert one image after the database with a Thank you note.

Answer: Programme coding

import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class College implements ActionListener
{
Panel p;
Frame f;
Button b1,b2,b3,b4,b5,b6,b7;
TextField tf1,tf2,tf3,tf4,tf5,tf6,tf7;
Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15;
GridLayout gl;
Connection con;
Statement st;
String s1,s2,s3,s4,s5,s6,s7,sr1,sr2;
TextArea ta1;
College()
{
f=new Frame();
p=new Panel();
p.setBackground(Color.cyan);
gl=new GridLayout(31,8,3,3);
p.setLayout(gl);
b1=new Button("Insert");
b1.addActionListener(this);
b2=new Button("Select");
b2.addActionListener(this);
b3=new Button("Select");
b3.addActionListener(this);
b4=new Button("Results");
b4.addActionListener(this);
b5=new Button("Select");
b5.addActionListener(this);
b6=new Button("Exam");
b6.addActionListener(this);
b7=new Button("Submit");
b7.addActionListener(this);
tf1=new TextField(50);
tf1.setBackground(Color.yellow);
tf2=new TextField(10);
tf2.setBackground(Color.yellow);
tf3=new TextField(50);
tf3.setBackground(Color.yellow);
tf4=new TextField(20);
tf4.setBackground(Color.yellow);
tf5=new TextField(6);
tf5.setBackground(Color.yellow);
tf6=new TextField(10);
tf6.setBackground(Color.yellow);
tf7=new TextField(10);
tf7.setBackground(Color.yellow);
tf8=new TextField(10);
tf8.setBackground(Color.yellow);
ta1=new TextArea(10,2);
l1=new Label("Enter student info");
l2=new Label("Update student info");
l3=new Label("View student info");
l4=new Label("View results");
l5=new Label("Delete student info");
l6=new Label("View exam details");
l7=new Label("Name");
l8=new Label("Roll");
l9=new Label("Address");
l10=new Label("Phone");
l11=new Label("E-Mail");
l12=new Label("Gender");
l13=new Label("Date of Birth");
l14=new Label("Result");
l15=new Label("Exam Details");
p.add(l1);p.add(b1);p.add(l2);p.add(b2);p.add(l3);p.add(b3);p.add(l4);p.add(b4);p.add(l5);p.add(b5);p.add
(l6);p.add(b6);
p.add(l7);p.add(tf1);p.add(l8);p.add(tf2);p.add(l9);p.add(tf3);p.add(l10);p.add(tf4);p.add(l11);p.add(tf5);p
.add(l12);p.add(tf6);p.add(l13);p.add(tf7);p.add(b7);p.add(l14);p.add(tf8);p.add(l15);p.add(ta1);
f.add(p);
f.setSize(100,200);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{

if(e.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
s1=tf1.getText();
s2=tf2.getText();
s3=tf3.getText();
s4=tf4.getText();
s5=tf5.getText();
s6=tf6.getText();
s7=tf7.getText();
st=createStatement.executeQuery("insert into Table1 values(?,?,?,?,?,?,?)");
st.setString(1,s1);
st.setString(2,s2);
st.setString(3,s3);
st.setString(4,s4);
st.setString(5,s5);
st.setString(6,s6);
st.setString(7,s7);
st.executeUpdate();
st.execute();
st.close();
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b2)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
s1=tf1.getText();
s2=tf2.getText();
st=createStatement.executeQuery("update Table1 set Name=?"+"where Roll=?");
st.setString(1,s1);
st.setString(2,s2);
st.executeUpdate();
st.execute();
st.close();
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b3)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
ResultSet rs=con.createStatement("Select * from Table1");
while(rs.next())
{
String s1=rs.Name;
String s2=rs.Roll;
String s3=rs.Address;
String s4=rs.Phone;
String s5=rs.E-Mail;
String s6=rs.Gender;
String s7=rs.Date Of Birth;
tf1.setText(s1);
tf2.setText(s2);
tf3.setText(s3);
tf4.setText(s4);
tf5.setText(s5);
tf6.setText(s6);
tf7.setText(s7);
}
rs.close();
}
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b4)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Avishek");
s2=tf2.getText();
ResultSet rs1=con.createStatement("select from Result where SRoll=?");
while(rs.next())
{
if(s2.equals(Roll))
{
String sr1=rs.SRoll;
String sr2=rs.SResult;
tf2.setText(sr1);
tf8.setText(sr2);
}
}
rs.close();
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b5)
{
try
{
s2=tf2.getText();
st=createStatement.executeQuery("delete from Somu where Roll=?");
st.setString(2,Roll);
st.executeUpdate();
st.execute();
st.close();
}
}
catch(Exception i)
{
System.out.println("Error");
}
}
if(e.getSource()==b6)
{
String exam="\nB-Tech 1st sem starts 12.2.2010.\n"+
"\nB-Com 1st sem starts 10.2.2010.\n"+
"\nMBA 1st sem starts 15.2.2010.\n";
ta1.setText(exam);
}
}
public static void main(String args[])
{
College c=new College();
}
}


Q4. a) Give reasons as to why ABC institute decided to choose XYZ Company for the development
of Java application.

Answer: ABC institute decided to choose XYZ for the development of Java application because the
institute understood the importance of e-records. As it had already faced the problems in keeping hard
copy of the records. XYZ organization was well efficient in developing java based software so it was
chosen. Other important reason was maintenance of records. It is very essential to keep records safe. Each
school has a responsibility to maintain its records and record keeping systems. Although schools will
have their own methods of creating and keeping records and sharing information with staff, students,
parents and the general public, they should be aware that, in doing so, they need to take account of
matters such as children names and their details with respective years.

Easy to Start: Since Java programming language is completely based on object-oriented
language, it's easy very simple and easy to learn, especially for programmers already known with
C or C++.
Easy to write code: As compared to program metrics (class counts, method counts, and so on)
tell us that a program written in the Java programming language can be four times smaller as
compare to the same program written in C++.
Write better code: The Java programming language encourages good coding practices, and
manages automatic garbage collection which helps you avoid memory leaks. Based on the
concept of object orientation, its Java Beans

component architecture, and wide-range, easily
extendible, flexibility and API can reuse existing, tested code and introduce fewer bugs.
Develop programs and Time Safer: The Java programming language is easier and simpler than
C++, as such, manages your development time up to twice as fast when writing in it. The
programs will also require fewer lines of code.
Platform Independencies: The program keeps portable and platform independent by avoiding
the use of libraries written in other languages.
Write Once and Used in any Java Platform: Any Source code of Program are written in the
Java programming language, that is compiled into machine-independent byte codes and run
consistently on any platform of java.
Distribute software makes work easy: Using Java Web Start software, users will be able to
launch own applications with a single click on mouse. An automatic version checks
initially weather users are always up to date with the latest version of your software. If an update
is available for it, the Java Web Start software will automatically update their installation.

Hence java application made by XYZ Company is necessary for ABC school for keeping records and
make records secure, Interactive and can be used for various other purposes.

b) Discuss the reasons for using JSP in java application.
The use of JSP program to create dynamic Web pages by considering a simple program that embeds JSP
within HTML program.
The JSP codes are plain text documents that we can create using any text editor such as a notepad. They
are like the HTML documents; however they have additional JSP elements or tags. Some of the most
common JSP elements are as follows:
Action: We use this tag to add more functionality to our program. The syntax of action tag is as
follows:
<jsp:some action/>

Directive: We use this tag to import java packages, to define the error handling pages or to define
the information related to session or JSP page. The syntax of directive tags is as follows:
<@ the directive %>

Declaration: We use this tag to define the functions and variables that need to be used in the JSP
program. The syntax of directive tags is as follows:
<%! declaration %>

Scriplet: We use this tag to add java code. The syntax of scriplet tag is as follows:
<% java code %>

Expression: We use this tag to output any information on the Web page. The expression will be
evaluated and included in the content sent back to the client. The syntax of expression tag is as
follows:
<%= expression %>

Comment: We use this tag to give a brief explanation of the line or lines of code written.
Comments are not visible to the client. The syntax of comment tag is as follows:
<%-- comment --%>

Q.5 For the above case study answer the following questions
a. State the reason for using database connection in the application.

Answer: Database connection is the means by which a database server and its client software
communicate with each other. The term is used whether or not the client and the server are on
different machines. The client uses a database connection to send commands to and receive replies
from the server. A database is stored as a file or a set of files on magnetic disk or tape, optical disk, or
some other secondary storage device. The information in these files may be broken down into records,
each of which consists of one or more fields. Fields are the basic units of data storage, and each field
typically contains information pertaining to one aspect or attribute of the entity described by the
database. Records are also organized into tables that include information about relationships between
its various fields. Although database is applied loosely to any collection of information in computer files,
a database in the strict sense provides cross-referencing capabilities. Connections are a key concept
in data-centric programming. Since some DBMS require considerable time to connect, connection
pooling is used to improve performance. No command can be performed against a database without an
"open and available" connection to it.
Once a connection has been built, it can be opened and closed at will, and properties (such as the
command time-out length, or transaction, if one exists) can be set. The connection string consists of a set
of key/value pairs, dictated by the data access interface of the data provider.

In this application we use database to make a record by storing the student names and details. With the
help of java we make application but to store the complete record we have to make a database to make a
integration of data and make database which is connected to the application and provide the details
whenever application required.

b. Explain the purpose of creating a java application for the ABC institute.

Answer: It is clear from above discussion that java application is important for ABC institute for keeping
and maintaining its record and to collaborate with its other branches. Manual record maintenance is very
tedious job and is not reliable.

1. With the help of this application, staff and students can now take information directly by just
logging into the webpage of the institute.

2. Java is one of the most popular programming languages used to create Web applications and
platforms. It was designed for flexibility, allowing users to work easily. Java has thrown out
many of the complex features of C++ and C resulting in a simpler language (no pointers, no
unions, and no enumerations).

3. Java is a single-root, single-inheritance object oriented language

4. Using Java RMI (remote method invocation) you can access objects on other machines almost as
if they were local
5. Java is simple, easy to design, easy to write, and therefore easy to compile, debug, and learn than
any other programming languages.
6. Java is object-oriented, that is used to build modular programs and reusable code in other
application.

Q.6 How do you handle exception in java? Give with an example.
Answer: A Java exception is nothing but an object that defines an exceptional condition, or an error that
has occurred in a piece of code. In Java, we can handle this exception by creating an object that represents
the exception, and throwing that object into the method that triggered the error. The method may handle
the exception by itself or pass on the exception to another method to handle it. In either of the ways, the
exception is caught and processed at some point.
There are two ways by which exceptions can occur. They are as follows:
Java run-time system: These exceptions relate to the fundamental errors that violate the rules of
the Java programming language or the constraints of the Java execution environment.
Code generated: The code that we write can manually generate exceptions. These are used to
report some error condition to the caller of a method.

Using throw
We can throw an exception explicitly by using the throw statement. The general form of throw is as
follows:
Throwable Instance must be an object, which is of type Throwable or a subclass of Throwable. We
cannot use primitive types, such as int or char, and non-Throwable classes, such as String and Object, as
exceptions. We can obtain a Throwable object in the following two ways:
Using a parameter in a catch clause.
Using the new operator.

The execution of the program stops immediately after the execution of the throw statement. The
subsequent statements are not executed. The program checks for a catch statement that matches
the type of exception in the nearest try block. If a matching catch statement is found, control is
transferred to that statement. If a matching catch statement is not found, the programs checks for
a matching catch statement in the next try block and so on. If a matching catch statement is not
found, the default exception handler halts the program and prints the stack trace.

Using finally
We have discussed the try; catch blocks and how to use throw and throws in the previous
sections. Now let us discuss the use of the finally block. When exceptions are thrown, the
execution of a method is interrupted and this alters the normal flow of the program. Sometimes,
the code is written in such a way that an exception causes a method to return prematurely. This
may create problems in few methods. For example, suppose you have a code for opening a file,
entering data, and closing the file. In such a situation, you will want that part of the code, which
closes the file, to be executed at any cost. It may happen that this part of the code is not executed due to
an exception that occurred when opening the file. Hence, we need a mechanism to handle such cases. The
finally keyword is used to address this issue.
finally is a block of code that is executed:
After the execution of the try/catch block.
Before the execution of the code following the try/catch block.

The finally block of code is executed at any cost. If there is an error in the program, the catch block is
executed, then the finally block is executed. If there are no errors, the try block is executed, then the
finally block is executed.

Вам также может понравиться