CS 802 - ITM Universe

advertisement
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 1
Date of conduction:- batch 1 -27/01/14
batch 2 -30/01/14
Date of submission:- batch 1 -27/01/14
batch 2 -30/01/14
Group no:- all student
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment no:
Name of experiment:
Objective: - To learn how to create a simple web page using html along with the usage of style
sheets, lists, creation or tables with borders, padding and colors.
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Develop and demonstrate a XHTML document that illustrates the use external style sheet, ordered
list, table, borders, padding, color, and the <span> tag
Procedure: 1. Open a new file using Notepad.
2. Rename the file as pgm1.html (Extension for html programs is .html)
3. Create a file (external cascading style sheet) by name Lab1.css where the font, size, colors
etc.. are specified. The style type should be set to
―text/css‖ under the <head> tag.
4. The pgm1.css file should be included in pgm1.html file in the
<link nhref ....> tag
5. In the <body> tag of the html document. Create an Ordered list using
<ol> tag. Also create sublists under the main list as shown below:
1. Dept of CSE
i. I Sem
ii. III Sem iii.
V Sem
iv. VII Sem
2. Dept of ISE
i. I Sem
ii. III Sem iii.
V Sem
iv. VII Sem
6. Create a Table which shows the Room No of the class/section and the strength of the students
in
each class/section of the departments, CSE and ISE.
7. Fill the table using an appropriate colour and specify the thickness of the border for the table.
8. Make the website neat and attractive with relevant text and pictures
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
9. Use suitable tags wherever necessary.
/*
---------------------------------Basics.css
-----------------------------------*/
body { background
color:white; }
table { border: 2px solid; padding: 0px; } th { border:
1px solid blue; padding:8px; } td { border: 1px solid
blue; padding:8px; }
ol { font-size:80%; list-style:lower-roman;
}
span { background-color:#grey; font-size:120%; font-style:italic;
}
p { font-size:90%; }
/* End of File */
<!
------------------------------------ XHTML CODE--------------------------------------->
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link
rel="stylesheet"
type="text/css"
href="
Basics.css" />
<title> CSS Basics </title>
</head>
<body>
<h1> This header is 36 pt </h1>
<h2> This header is black </h2>
<p> This paragraph has a left margin of 50 pixels </p>
<table>
<tr>
<th> Name </th>
<th> Email </th>
<th> Phone number </th>
</tr>
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
<tr>
<td> Xyz </td>
<td> xyz@abc.com </td>
<td> 12345 </td>
</tr>
<tr>
<td> Qwerty </td>
<td> qwerty@poi.com
</td>
<td> 987654 </td>
</tr>
<tr>
<td> Zaqwsx </td>
<td> zaqwsx@mnbv.co.uk </td>
<td> 78563 </td>
</tr>
</table>
<hr />
This is an ordered list.
<ol>
<li>ISE <
/li>
<li>CSE </li>
<li>ECE </li>
</ol>
<p>
<span>This is some span text.</span> This is
some random text.
<span>This is some more span text.</span>
</p>
</body>
</html>
<!--End of file -->
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: -
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :-
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
1.
a)
b)
c)
d)
If you want to start a new line in a certain place within a
paragraph, you need to use which tag?
<p>
<pb>
<br>
<B>
</p>
What are the range of heading tags available using HTML?
<h1> to <h3>
<h1> to <h6>
<h1> to <h8>
<h1> to <h7>
<h1> to <h9>
Which line is incorrect? <body bgcolor="red"> <body
bgcolor=green"> <body bgcolor="black"> <body
bgcolor="blue">
<body bgcolor="red">
<body bgcolor="black">
<body bgcolor="blue">
<body bgcolor=green">
What happens when we have the following program line written
on our notepad file? <p align=right>a
href="page4.html"><b>Next Page</b></a >
Takes you to page 3.
Takes you to page 5
It creates a hyperlink which if you click on you move from page 3 to 4
It creates a hyperlink which if you click on you move from page 4 to 5
5.
a)
b)
c)
d)
e)
What character is used to indicate an end tag?
<
~
/
=
a)
b)
c)
d)
e)
2.
a)
b)
c)
d)
e)
3.
a)
b)
c)
d)
4.
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
6.
a)
b)
c)
d)
e)
7.
a)
b)
c)
d)
e)
8.
What is the last exercise you have to do in HTML for Beginners,
by Russell Boyle?
Getting links in one frame to open up in another frame
Head Tags and title tags
Meta Tags
Creating a form
Using lists
What beginning tag do I use if i want to center a particular
word?
<center/>
<//center>
<center>
<centre>
<"centre">
a)
b)
c)
d)
What type of file do you have to use when you are saving a new
page?
HTML File (*.*)
Web based.doc (*.*)
All Files (*.*)
Web Page, complete (*.htm, *.html)
Text File (*.*)
What does the "wav" indicate in this line: <br><embed
src="splash.wav" autostart=false hidden=false>
Sound file
Video file
Picture file
Animation file
10.
a)
b)
c)
What 2 tags must you include at the start of a new file?
html tags </html> & body tags </body> N
<html> & </body>
html tags <html> & body tags <body>
a)
b)
c)
d)
e)
9.
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
d)
one of the above
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S. Godbole
and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 2
Date of conduction:- batch 1 -03/02/14
batch 2 -06/02/14
Date of submission:- batch 1 -03/02/14
batch 2 -06/02/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Objective: To get acquainted with JavaScript and how to embed
JavaScript in html code. Procedure.
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Develop and demonstrate a XHTML file that includes JavaScript script for the
following problems:
b) Input: A number n obtained using prompt Output: A table of numbers from 1 to n and their
squares using alert
Procedure: 1. Declare the script tag as text/JavaScript in the beginning of the <body> of html
program
2. Get the number till which the squares have to be generated using prompt ()
3. Validate input given and alert the user for invalid input using alert ()
4. For all the numbers from 1 to n, generate their squares and print them.
<!-------------------------------------------------------------- XHTML
CODE
---------------------------------------------------->
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Squares of numbers</title> </head>
<body>
<h1>
Printing numbers & calculating their squares
</h1>
<script type="text/javascript">
var n,i;
n=prompt("Enter a number","");
if(n>0)
{
c="Number | Square"
for(i=1;i<=n;i++) c=(c+"\n"+i+" -----> "+i*i);
alert(c)
}
else alert("Enter a number greater than 1.")
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
</script>
</body>
</html>
<!--End of File -->
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: -
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Lab Quiz :-
1. Which tag will produce what you see in this picture?
a) <head>HTML Quiz </head>
b) <title>HTML Quiz </title>
c) <H1> HTML Quiz </H1>
d) <top>HTML Quiz </top>
2. Which tag makes the largest headline?
a) H1
b) H2
c) H3
d) H4
3. The line below is called a _______________.
a) Heavy Rule
b) Horizontal Rule
c) Hard Return
Hypertext Return
4. Between which set of tags does most of the content of your web page need to
be placed?
a) <text></text>
b) <body></body>
c) <title></title>
d) <head></head>
5. Which set of tags looks like this?
·Dogs
·Cats
·Birds
a) <ul></ul>
b) <u></u>
c) <ol></ol>
d) <dl></dl>
6. Gif is a __________
a) the language of the Web
b) . common graphic format on the Web.
c) a company that provides access to the Internet.
7. FAQ is used to represent ________
a) common graphic format on the Web
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
b) a company that provides access to the Internet
c) common questions and answers.
d) the language of the Web
8. HTML is ___________
a) common graphic format on the Web
b) a company that provides access to the Internet
c) common questions and answers.
d) the language of the Web
9. ISP is __________
a) common graphic format on the Web
b) a company that provides access to the Internet
c) common questions and answers.
d) the language of the Web
10.
HTTP is a ________________
a) the transfer method used on the Web.
b) file format used to transfer files from one word processor to another
c) a Web Address.
d) file format that retains format on the Web.
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S. Godbole
and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 3
Date of conduction:- batch 1 -10/02/14
batch 2 -14/02/14
Date of submission:- batch 1 -10/02/14
batch 2 -14/02/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment no:
Name of experiment:
Objective: To get acquainted with JavaScript procedures and usage of regular expressions in
JavaScript
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Develop and demonstrate a XHTML file that
includes JavaScript script that uses functions for the following Problems:
b) Parameter: A number
Output: The number with its digits in the reverse order
Procedure: ! -1. Declare the script tag as text/javascript in the beginning of the <body>
of html program
2. Get the number to be reversed from the user using prompt()
3. Validate input number (should be a positive number between 0 to 9) using the regular expression ―
/^[0-9]+$/ ― and alert the user for invalid input using alert()
4. Reverse the number using modulus operation.
5. Use math.floor(number/10) to get the floor of number after division(used for
reversing)
6. Display the reversed string using alert()
<!
-------------------------------------------------------------- XHTML CODE-------------------------------------------------->
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Number reversal</title> </head>
<body>
<h1>Printing digits in reverse order</h1>
<script type="text/javascript">
function disp(str)
{
var n=0,r=0,res=0
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
n=str.value
if( n>0 || n==0 )
{
while(n!=0)
{ r=n%10
n=Math.floor(n/10)
res=res*10+r
}
alert("The reverse of the number is: "+res)
}
else alert("Enter a valid number")
}
</script>
<form>
<p>
Number: <input type= "text"
name="str" />
<input type="button" value="Find" onclick="disp(str)" />
</p>
</form>
</body>
</html>
<!
-End of file
->
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: -
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :-
1.
a)
b)
c)
d)
A URL is ________
the transfer method used on the Web.
file format used to transfer files from one word processor to another
a Web Address.
file format that retains format on the Web.
2. RTF is a __________
a) the transfer method used on the Web.
b) file format used to transfer files from one word processor to another
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
c) a Web Address.
d) file format that retains format on the Web.
3. What is the HTML feature that divides a web page into two or more
scrollable parts?
a) Split Page
b) Frame
c) Form
d) Table
4. TCP/IP is a _______
a) communicating real time on the Internet.
b) program that enhances a browser's capability.
protocol used on the Internet that sends packets of information
c) a perfomance matrix used for authentic assessment
5.
a)
b)
c)
d)
Plug-in is a _________
communicating real time on the Internet.
program that enhances a browser's capability.
protocol used on the Internet that sends packets of information
a perfomance matrix used for authentic assessment
6.
a)
b)
c)
d)
Chat is ______
communicating real time on the Internet.
program that enhances a browser's capability.
protocol used on the Internet that sends packets of information
a perfomance matrix used for authentic assessment
7.
a)
b)
c)
d)
A rubric is a _________
communicating real time on the Internet.
program that enhances a browser's capability.
protocol used on the Internet that sends packets of information
a perfomance matrix used for authentic assessment
8. A table is a _____
a) ARPAnet.
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
b) input area on a web page
c) an interent activity that involves synthesis of information.
d) method used to keep web pages formatted correctly.
9.
a)
b)
c)
d)
A form is an _____
an interent activity that involves synthesis of information.
method used to keep web pages formatted correctly.
input area on a web page.
ARPAnet.
10. A WebQuest is _______
a) an interent activity that involves synthesis of information.
b) method used to keep web pages formatted correctly.
c) input area on a web page.
d) ARPAnet.
.
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S. Godbole
and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 4
Date of conduction:- batch 1 -17/02/14
batch 2 -20/02/14
Date of submission:- batch 1 -17/02/14
batch 2 -20/02/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Objective: To get acquainted with JavaScript procedures and usage of regular expressions in
JavaScript
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Develop and demonstrate, using JavaScript script, a XHTML document that collects the USN (
the valid format is: A digit from 1 to 4 followed by two upper-case characters followed by two
digits followed by two upper-case characters followed by three digits; no embedded spaces
allowed) of the user. Event handler must be included
for the form element that collects this information to validate the input. Messages in the alert
windows must be produced when errors are
detected.
Procedure: 1. Declare the script tag as text/javascript in the beginning of the <body>
of html program
2. Get the USN from the user using prompt()
3. Validate USN input by the user using the regular expression : /[14][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/
4. If the USN format is correct, alert the user with a message, else alert the user with the format
DAADDAADDD (for eg: 1PE09CS001)
<!
-----------------------------------------------------XHTML CODE--------------------------------------------------------.—
>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title> USN Validation </title> </head>
<body>
<script type="text/javascript">
function func(usn)
{
var pattern1=/^[1-4][A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{3}$/
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
if(!usn.value.match(pattern1)||usn.value.length==0)
{
alert("Invalid USN!
\
nEnter a valid USN")
return false
}
else alert("USN valid!")
}
</script>
<form action="">
<p>
USN: <input type="text" name="us n" />
<br/>
<input type="button" value="Validate" onclick="func(usn)" />
</p>
</form>
</body>
</html>
<!--End of file -->
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: -
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :-
1.
a)
b)
c)
d)
The original creator of the Internet is ____________
an interent activity that involves synthesis of information.
method used to keep web pages formatted correctly.
input area on a web page.
ARPAnet.
2. The original creator of the Internet is ____________
a) input area on a web page
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
b) method used to keep web pages formatted correctly.
c) an interent activity that involves synthesis of information
d) ARPAnet.
Why are GIF and JPG the most common graphics formats on the web?
Because they are the only ones that can display on both Macs and PCs
Because they are Microsoft formats
Because they are the only ones that can display more than 216 colors
Because they are the only ones that the browsers recognize
The term used for an Internet access is:
URL
HTTP
HTML
FTP
3.
a)
b)
c)
d)
4.
a)
b)
c)
d)
5.
6. The language used for creating Web pages
a) DSL
b) GUI
c) HTML
d) FTP
7. A high-speed connection to the Internet over standard lines.
a) DSL
b) GUI
c) HTML
d) FTP
8. A utility for transferring files on the Internet.
a) DSL
b) GUI
c) HTML
d) FTP
9. A program that has a graphical interface.
a) DSL
b) GUI
c) HTML
d) FTP
10. When saving a file to your folder using flash, what file extension would it
save as?
a) Wav
b) Swf
c) htm
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
d) png
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S. Godbole
and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 5
Date of conduction:- batch 1 -24/02/14
batch 2 -27/02/14
Date of submission:- batch 1 -24/02/14
batch 2 -27/02/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Objective: To get acquainted with JavaScript procedures and usage of regular expressions in
JavaScript
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Modify the above program to get the current semester also (restricted to be a number from 1 to
8)
Procedure: 1. Declare the script tag as text/javascript in the beginning of the <body>
of html program
2. Get the USN and Semester from the user using prompt()
3. Validate USN input by the user using the regular expression : /[14][A- Z][A-Z][0-9][0-9][AZ][A-Z][0-9][0-9][0-9]$/
4. If the USN format is correct, alert the user with a message, else alert the user with the format
DAADDAADDD (for eg: 1PE09CS001)
5. Validate Semester by the user using the regular expression : /[1-8]$/
6. If the Semester is correct, alert the user with a message, else alert the user with the valid
semester number (1 –8).
<!
------------------------------------------------------------XHTML CODE
---------------------------------------------------
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>USN and Semester Validation</title> </head>
<body>
<script type="text/javascript">
function disp(usn,sem)
{
var pattern1=/^[1-4][A-Z]{2}[0-9]{2}[A-Z]{2}[0-9]{3}$/
if(!usn.value.match(pattern1)||usn.value.length==0)
{
alert("Invalid USN!\nEnter a valid USN")
return false
}
else alert("USN valid!")
var pattern2=/^[1-8]$/
if(!sem.value.match(pattern2)||sem.value.length==0)
{
alert("Invalid Semester!\nEnter a valid Semester")
return false
}
else alert("Semester valid!")
}
</script>
<form action="">
<p>
USN: <input type="text" name="usn" /> <br/> Semester: <input
type="text" name="sem" /> <br/>
<input type="button" value="Validate" onclick="disp(usn,sem)" />
</p>
</form>
</body>
</html>
<!--End of file -->
Observation Table:- Not Applicable
Calculation:- Not Applicable
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Results: -
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :-
1When saving a file to your folder using fireworks, what file extension would it
save as?
a) Wav
b) Swf
c) htm
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
d) png
2When saveing a dreamweaver file, what file extension would it save as?
a)
b)
c)
d)
Wav
Swf
htm
png
3When saving a sound file to your folder, what is one of the file extension it
could save as?
a)
b)
c)
d)
Wav
Swf
htm
png
4Table cells are represented by:
a)
b)
c)
d)
<TD></TD>
<TCELL></TCELL>
< TC></TC>
< CELL></CELL>
5Target=_blank specifies that a
a) the page will shut down.
the page is defined as a target and will be found by the arrow command.
window will open blank.
when clicking a link, it will open in a new window.
6An HTML _____ helps you create an HTML file by inserting HTML codes for
you as you work (like dreamweaver).
a)
b)
c)
d)
Editor
Builder
coach
monitor
7HTML has a set of rules under which it operates. What is it called?
a) Syntax
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
b) Tags
c) Dialog
d) Laws
8______ are additional information placed within HTML brackets that control
how the tab is used.
a)
b)
c)
d)
Properties
Adjectives
Narratives
Descriptors
9Which part of the HTML document would you find you META tag
information?
a)
b)
c)
d)
Body
Title
Form
Head
10To begin a new line without starting a new paragraph, which code would you
use?
a)
b)
c)
d)
<l>
<newline>
<line>
<br>
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S. Godbole
and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 6
Date of conduction:- batch 1 -24/03/14
batch 2 -27/03/14
Date of submission:- batch 1 -24/03/14
batch 2 -27/03/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Objective: Develop and demonstrate, using JavaScript script, a XHTML
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Develop and demonstrate, using JavaScript script, a XHTML
document that contains three short paragraphs of text, stacked on top of each other, with only
enough of each showing so that the mouse cursor
can be placed over some part of them. When the cursor is placed over the exposed part of any
paragraph, it should rise to the top to become completely visible
Procedure: 1. Declare the script tag as text/javascript in the beginning of the <body>
of html program
2. Get the USN and Semester from the user using prompt()
3. Validate USN input by the user using the regular expression : /[14][A- Z][A-Z][0-9][0-9][AZ][A-Z][0-9][0-9][0-9]$/
4. If the USN format is correct, alert the user with a message, else alert the user with the format
DAADDAADDD (for eg: 1PE09CS001)
5. Validate Semester by the user using the regular expression : /[1-8]$/
6. If the Semester is correct, alert the user with a message, else alert the user with the valid
semester number (1 –8).
<!
------------------------------------------------------------XHTML CODE
---------------------------------------------------
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Stack</title>
<script type="text/javascript">var top='p3'function toTop(newTop)
{ domTop=document.getElementById(top).style
domNew=document.getElementById(newTop).style
domTop.zIndex="0"
domNew.zIndex="10"
top=newTop
}
</script>
<style type="text/css">.para1{position:absolute;top:10;left:120;z-index:0;
border:solid;padding:80; width:300;background-color:aqua;}
.para2{position:absolute;top:50;left:150;z-index:0;border:solid;padding:80;
width:300;background-color:yellow; }.para3{position:absolute;top:100;left:180;z
index:0;border:solid;padding:80; width:300;background-color:red; }
</style>
</head>
<body>
<p class="para1" id="p1" onmouseover="toTop('p1')"> Frame One </p>
<p class="para2" id="p2" onmouseover="toTop('p2')"> Frame Three </p>
<p class="para3" id="p3" onmouseover="toTop('p3')"> Frame Two </p>
</body></html><!--End of fil
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: -
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :-
11. (To creating a link in a document to a section in the same document, you
would use an ________.
a) suspender
b) extra rollover
c) bookmark
d) anchor
12. To insert an image on your Web page, what tag would you use?
a) PICTURE
PIC SRC
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
b) IMG SRC
c) IMAGE
13. To center, right or left justify text or an image, what code would I use?
a) justify
b) align
c) push
d) send
14. To create a drop down list for a form, which syntax would you use?
a) The general <SELECT> and <DROPDOWM> tags.
b) The general <SELECT> and <OPTION> tags.
c) The general <OPTION> and <TEXT> tags.
d) The general <DROPDOWM> and <TEXT> tags.
15. To link your Web page to a style sheet, you must use the _____ tag.
a) <STYLESHEET>
b) <STYLE>
c) <LINK>
d) <WEB>
6 When you place a JavaScript on a Web page, which tag would you use?
a)
b)
c)
d)
<JS></JS>
<JSCRIPT></JSCRIPT>
<JAVA></JAVA>
<SCRIPT></SCRIPT>
7 WAV and MIDI are file extensions that represent __________
a)
b)
c)
d)
background colors
sounds
color charts
large pictures
8. onBlur, onClick, and onFocus are all ______ handlers
a)
b)
c)
d)
Elements
Properties
methods
events
9. Enable, form, name, type, and value are all ________.
a) Events
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
b) Methods
c) Properties
d) elements
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S. Godbole
and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Experiment 7
Date of conduction:- batch 1 -31/03/14
batch 2 -03/04/14
Date of submission:- batch 1 -31/03/14
batch 2 -03/04/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
NAME OF LABORATORY:
VSB LAB 2
LAB SUBJECT CODE: CS 802
NAME OF DEPARTMENT: CSE
Objective: Develop and demonstrate, using JavaScript script, a XHTML
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: Develop and demonstrate, using JavaScript script, a XHTML
document that contains three short paragraphs of text, stacked on top of each other, with only
enough of each showing so that the mouse cursor
can be placed over some part of them. When the cursor is placed over the exposed part of any
paragraph, it should rise to the top to become completely visible
Procedure: 1. Declare the script tag as text/javascript in the beginning of the <body>
of html program
2. Get the USN and Semester from the user using prompt()
3. Validate USN input by the user using the regular expression : /[14][A- Z][A-Z][0-9][0-9][AZ][A-Z][0-9][0-9][0-9]$/
4. If the USN format is correct, alert the user with a message, else alert the user with the format
DAADDAADDD (for eg: 1PE09CS001)
5. Validate Semester by the user using the regular expression : /[1-8]$/
6. If the Semester is correct, alert the user with a message, else alert the user with the valid
semester number (1 –8).
<!
------------------------------------------------------------XHTML CODE
---------------------------------------------------
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Stack</title>
<script type="text/javascript">var top='p3'function toTop(newTop)
{ domTop=document.getElementById(top).style
domNew=document.getElementById(newTop).style
domTop.zIndex="0"
domNew.zIndex="10"
top=newTop
}
</script>
<style type="text/css">.para1{position:absolute;top:10;left:120;z-index:0;
border:solid;padding:80; width:300;background-color:aqua;}
.para2{position:absolute;top:50;left:150;z-index:0;border:solid;padding:80;
width:300;background-color:yellow; }.para3{position:absolute;top:100;left:180;z
index:0;border:solid;padding:80; width:300;background-color:red; }
</style>
</head>
<body>
<p class="para1" id="p1" onmouseover="toTop('p1')"> Frame One </p>
<p class="para2" id="p2" onmouseover="toTop('p2')"> Frame Three </p>
<p class="para3" id="p3" onmouseover="toTop('p3')"> Frame Two </p>
</body></html><!--End of fil
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: -
Page 41 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :(10 Objective type questions related with experiment / software program executed working
principle & application.)
Page 42 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S.
Godbole and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
Page 43 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Experiment 8
Date of conduction:- batch 1 -07/04/14
batch 2 -10/04/14
Date of submission:- batch 1 -07/04/14
batch 2 -10/04/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
Page 44 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Objective: Write Servlet Hello World
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: As we know that the our servlet extends the HttpServlet and overrides the doGet() method which
it inherits from the HttpServlet class. The server invokes doGet() method whenever web server
recieves the GET request from the servlet. The doGet() method takes two arguments first is
HttpServletRequest object and the second one is HttpServletResponse object and this method
throws the ServletException.
Whenever the user sends the request to the server then server generates two obects, first is
HttpServletRequest object and the second one is HttpServletResponse object.
HttpServletRequest object represents the client's request and the HttpServletResponse represents
the servlet's response.
Inside the doGet(() method our servlet has first used the setContentType() method of the
response object which sets the content type of the response to text/html. It is the standard MIME
content type for the Html pages. After that it has used the method getWriter() of the response
object to retrieve a PrintWriter object. To display the output on the browser we use the println()
method of the PrintWriter class.
Procedure: import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("<html>");
pw.println("<head><title>Hello World</title></title>");
pw.println("<body>");
pw.println("<h1>Hello World</h1>");
pw.println("</body></html>");
}
}
web.xml file for this program:
Page 45 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: - Console output
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :(10 Objective type questions related with experiment / software program executed working
principle & application.)
Page 46 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S.
Godbole and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
Page 47 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Experiment 9
Date of conduction:- batch 1 14/04/14
Date of submission:- batch 1 -14/04/14
batch 2 -17/04/14
batch 2 -17/04/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
Page 48 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Objective: Displaying Date in Servlet
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: As we know that the our servlet extends the HttpServlet and overrides the doGet() method which
it inherits from the HttpServlet class. The server invokes doGet() method whenever web server
recieves the GET request from the servlet. The doGet() method takes two arguments first is
HttpServletRequest object and the second one is HttpServletResponse object and this method
throws the ServletException.
Whenever the user sends the request to the server then server generates two obects, first is
HttpServletRequest object and the second one is HttpServletResponse object.
HttpServletRequest object represents the client's request and the HttpServletResponse represents
the servlet's response.
Inside the doGet(() method our servlet has first used the setContentType() method of the
response object which sets the content type of the response to text/html. It is the standard MIME
content type for the Html pages. The MIME type tells the browser what kind of data the browser
is about to receive. After that it has used the method getWriter() of the response object to retrieve
a PrintWriter object. To display the output on the browser we use the println() method of the
PrintWriter class.
Procedure: import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayingDate extends HttpServlet{
public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException{
PrintWriter pw = response.getWriter();
Date today = new Date();
pw.println("<html>"+"<body><h1>Today Date is</h1>");
pw.println("<b>"+ today+"</b></body>"+ "</html>");
}
}
XML File for this program
<?xml version="1.0" encoding="ISO-8859-1"?>
Page 49 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>DateDisplay</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/DateDisplay</url-pattern>
</servlet-mapping>
</web-app>
Page 50 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: - Console output
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :(10 Objective type questions related with experiment / software program executed working
principle & application.)
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S.
Godbole and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
Page 51 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Experiment10
Date of conduction:- batch 1 21/04/14
Date of submission:- batch 1 -21/04/14
batch 2 24/04/14
batch 2 -24/04/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
Page 52 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Objective: Create Form in JSP
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: - simple JSP page
Procedure: Create Form in JSP
Here is the code of the form (cookieform.jsp) which prompts the user to enter his/her name.
<%@ page language="java" %>
<html>
<head>
<title>Cookie Input Form</title>
</head>
<body>
<form method="post" action="setcookie.jsp">
<p><b>Enter Your Name: </b><input type="text" name="username"><br>
<input type="submit" value="Submit">
</form>
</body>
Above form prompts the user to enter the user name. User input are posted to the setcookie.jsp
file, which sets the cookie. Here is the
code of setcookie.jsp file:
<%@ page language="java" import="java.util.*"%>
<%
String username=request.getParameter("username");
if(username==null) username="";
Date now = new Date();
String timestamp = now.toString();
Cookie cookie = new Cookie ("username",username);
cookie.setMaxAge(365 * 24 * 60 * 60);
response.addCookie(cookie);
%>
Page 53 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
<html>
<head>
<title>Cookie Saved</title>
</head>
<body>
<p><a href="showcookievalue.jsp">Next Page to view the cookie value</a><p>
</body>
Above code sets the cookie and then displays a link to view cookie page. Here is the code of
display cookie page (showcookievalue.jsp):
<%@ page language="java" %>
<%
String cookieName = "username";
Cookie cookies [] = request.getCookies ();
Cookie myCookie = null;
if (cookies != null)
{
for (int i = 0; i < cookies.length; i++)
{
if (cookies [i].getName().equals (cookieName))
{
myCookie = cookies[i];
break;
}
}
}
%>
<html>
<head>
<title>Show Saved Cookie</title>
</head>
<body>
<%
if (myCookie == null) {
%>
No Cookie found with the name <%=cookieName%>
<%
} else {
Page 54 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
%>
<p>Welcome: <%=myCookie.getValue()%>.
<%
}
%>
</body>
When user navigates to the above the page, cookie value is displayed.
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: - Console output
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :(10 Objective type questions related with experiment / software program executed working
principle & application.)
Further reading resources:
Book: Lab experiment related theory available in following books:
1.
Web Technologies- Jeffrey C. Jackson
Page 55 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
2.
3.
4.
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S.
Godbole and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
Page 56 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Experiment11
Date of conduction:- batch 1 28/04/14
Date of submission:- batch 1 -28/04/14
batch 2 01/05/14
batch 2 -01/05/14
Group no:- all student
Signature
Name of faculty incharge: Nikesh kumar sharma
Name of Technical Assistant: Mr. Pradeep Sharma
Page 57 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Objective: how to retrieve the data posted from a HTML file in a JSP page
Appratus:- Computer, Mozilla Firefox, Google Chrome, Java J2EE, Oracle
Theory: - how to retrieve the data posted from a HTML file in a JSP page. Consider an html
page that prompts the user to enter
his/her name, let's call it getname.htm. Here is the code of the html file:
Procedure: Retrieving the data posted to a JSP file from HTML file
<html>
<head>
<title>Enter your name</title>
</head>
<body>
<p> </p>
<form method="POST" action="showname.jsp">
<p><font color="#800000" size="5">Enter your name:</font><input type
="text" name="username" size="20"></p>
<p><input type="submit" value="Submit" name="B1"></p>
</form>
</body>
</html>
The target of form is "showname.jsp", which displays the name entered by the user. To retrieve
the value entered by the user we uses the
request.getParameter("username");
Here is the code of "showname.jsp" file:
Page 58 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
<%@page contentType="text/html" %>
<!-http://www.roseindia.net/jsp
-->
<html>
<body>
<p><font size="6">Welcome :  <%=request.getParameter("username")%></font></p>
</body>
</html>
Accessing database from JSP
JSP Code
The following code contains html for user interface & the JSP backend<%@ page language="java" import="java.sql.*" %>
<%
String driver = "org.gjt.mm.mysql.Driver";
Class.forName(driver).newInstance();
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
try{
String url="jdbc:mysql://localhost/books?user=
<user>&password=<password>";
con=DriverManager.getConnection(url);
stmt=con.createStatement();
}
catch(Exception e){
System.out.println(e.getMessage());
}
if(request.getParameter("action") != null){
String bookname=request.getParameter("bookname");
String author=request.getParameter("author");
stmt.executeUpdate("insert into books_details(book_name,
Page 59 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
author) values('"+bookname+"','"+author+"')");
rst=stmt.executeQuery("select * from books_details");
%>
<html>
<body>
<center>
<h2>Books List</h2>
<table border="1" cellspacing="0" cellpadding
="0">
<tr>
<td><b>S.No</b></td>
<td><b>Book Name</b></td>
<td><b>Author</.b></td>
</tr>
<%
int no=1;
while(rst.next()){
%>
<tr>
<td><%=no%></td>
<td><%=rst.getString("book_name")%></td>
<td> <%=rst.getString("author")
%> </td>
</tr>
<%
no++;
}
rst.close();
stmt.close();
con.close();
%>
</table>
</center>
</body>
</html>
<%}else{%>
<html>
<head>
<title>Book Entry FormDocument</title>
<script language="javascript">
function validate(objForm){
if(objForm.bookname.value.length==0){
Page 60 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
alert("Please enter Book Name!");
objForm.bookname.focus();
return false;
}
if(objForm.author.value.length==0){
alert("Please enter Author name!");
objForm.author.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<center>
<form action="BookEntryForm.jsp" method="post"
name="entry" onSubmit="return
validate(this)">
<input type="hidden" value="list" name="action">
<table border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
<table>
<tr>
<td colspan="2" align="center">
<h2>Book Entry Form</h2></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td>Book Name:</td>
<td><input name="bookname" type=
"text" size="50"></td>
</tr>
<tr>
<td>Author:</td><td><input name=
"author" type="text" size="50"></td>
</tr>
<tr>
Page 61 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
<td colspan="2" align="center">
<input type="submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
<%}%>
Observation Table:- Not Applicable
Calculation:- Not Applicable
Results: - Console output
Conclusion:- Not Applicable
Precautions:- Not Applicable
Suggestions:- Not Applicable
Lab Quiz :(10 Objective type questions related with experiment / software program executed working
principle & application.)
Further reading resources:
Page 62 of 63
NAME OF LABORATORY:
VSB LAB 4
LAB SUBJECT CODE: IT 604
NAME OF DEPARTMENT: IT
Book: Lab experiment related theory available in following books:
1.
2.
3.
4.
Web Technologies- Jeffrey C. Jackson
Web Technologies-TCP/IP Architecture, and Java Programming Achyut S.
Godbole and Atul Kahate
An introduction to Web Design+Programming Paul S. Wang Sanda, S Katila,
Web Technology- A developer’s Perspective by N.P.Gopalan, J.Akilandeswari ,
Page 63 of 63
Download