SlideShare a Scribd company logo
1 of 56
Download to read offline
1
EX. NO: 1
DATE: IMAGE MAPPING USING HTML
AIM
To write the html code to perform the Image Mapping.
ALGORITHM
1. Start.
2. Write the code for tnmap.html.
3. Perform mapping using <MAP> tag.
4. Insert Hyperlink using <A href>.
5. Display Results.
6. Stop.
Required files to run:
1. maptn.jpg
2. salem.gif
3. erode.gif
4. covai.gif
5. tnmap.html
6. erode.html
7. salem.html
8. covai.html
PROGRAM:
File Name: tnmap.html
<!-- tnmap.html -->
<html> <head> <title>TamilNadu</title> </head>
2
<body> <map name="tamilnadu">
<area href="salem.html" shape="circle" coords="78,78,10">
<area href="erode.html" shape="circle" coords="60,90,10">
<area href="covai.html" shape="circle" coords="50,120,10">
</map>
<img src="maptn.jpg" border="1" usemap="#tamilnadu"> </body> </html>
2. File Name: salem.html
<html><head><title>salem page </title></head>
<body> This is the Salem district in Tamilnadu. <br>
<img src="salem.gif"> <br>
Salem is surrounded by hills and is known for mango cultivation.<br>
There were eleven taluks in the district. They are:
<ol>
<li>Attur
<li>Edappadi
<li>Gangavalli
<li>Mettur
<li>Omalur
<li>Salem
<li>Salem South
<li>Salem West
<li>Sangagiri
<li>Valapady
<li>Yercaud
</ol>
<a href="tnmap.html">home </a> </body></html>
3
3. File Name: erode.html
<html><head><title>erode page </title></head>
<body> This is the Erode district in Tamilnadu. <br>
<img src="erode.gif"> <br>
Erode was the largest district by area in the state before the Formation of Tirupur District.<br>
There were six taluks in the district. They are:
<ol>
<li>Andiyur
<li>Bhavani
<li>Erode
<li>Gobichetipalayam
<li>Perundurai
<li>Sathyamangalam
</ol> <a href="tnmap.html">home </a> </body></html>
4. File Name: covai.html
<html><head><title>covai page </title></head>
<body> This is the coimbatore district in Tamilnadu.<br>
<br>
<img src="covai.gif">
<br> Coimbatore is the second largest city in Tamilnadu. There were ten taluks in the district. They are:
<ol>
<li>Annur
<li>Coimbatore (North)
<li>Coimbatore (South)
4
<li>Kinathukadavu
<li>Madukkarai
<li>Mettupalayam
<li>Perur
<li>Pollachi
<li>Sulur
<li>Valparai
</ol>
<a href="tnmap.html">home </a> </body></html>
OUTPUT
5
6

RESULT
Thus image mapping has been performed using HTML.
7
EX NO: 2
DATE: APPLYING INLINE CASCADING STYLE SHEETS TO A WEB PAGE
AIM
To demonstrate the use of style sheets in HTML.
ALGORITHM
1. Create a simple HTML page.
2. Write internal CSS using <style> tag in the same page become internal CSS.
3. Create another CSS file using <style> tag with extension .css file for external CSS file.
4. Include the external CSS file in HTML file.
5. Find the style changes on the page.
Required files to run
1. parliament.jpg
2. bharat.jpg
3. odissi.jpg
4. kathakali.jpg
5. mohini.jpg
6. liststyle.css
7. style1.html
Program
Filename: style1.html
<html> <head> <title>Inline Style Sheet</title>
<!-- External style sheet starts -->
<link rel="stylesheet" type="text/css" href="liststyle.css">
<!-- External style sheet ends -->
8
<!-- Internal style sheet starts -->
<style>
p.ex1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 46;
color: purple;
}
</style>
<!-- Internal style sheet ends -->
</head> <body bgcolor=gold> <center> <p class="ex1"> All About INDIA </p> </center>
<p> <ul class="a">
<li>India never invaded any country in her last 100000 years of history.
<li>When many cultures were only nomadic forest dwellers over 5000 years ago, Indians established
Harappan culture in Sindhu Valley (Indus Valley Civilization)
<li>The name 'India' is derived from the River Indus, the valleys around which were the home of the
early settlers. The Aryan worshippers referred to the river Indus as the Sindhu.
<li>The Persian invaders converted it into Hindu. The name `Hindustan' combines Sindhu and Hindu
and thus refers to the land of the Hindus.
<li>Chess was invented in India. </ul>
<!-- inline styles starts -->
<p style="color:blue;text-align:center;"> The Parliament <br><img src="parliament.jpg" width=200
height=200> </p>
<!-- inline style ends -->
<font size="36px" face="Times New Roman" color=red> Culture Of India</font>
<p> <ul class="b">
<li> The culture of India has been shaped by the long history of India, its unique geography and the
absorption of customs, traditions and ideas from some of its neighbors as well as by preserving its
ancient heritages, which were formed during the Indus Valley Civilization and evolved further during
the Vedic age, rise and decline of Buddhism, Golden age, Muslim conquests and European colonization.
9
<li>India's great diversity of cultural practices, languages, customs, and traditions are examples of this
unique co-mingling over the past five millennia.
</ul> </p> <font size="36px" face="Times New Roman" color=red>Indian Classical
Dances</font></br>
<font size="4px" face="Times New Roman" color=blue>
The various dance forms of India are
<ol class="d">
<li> Bharatanatyam<img src="bharat.jpg" height=200 width=200>
<li>Odissi<img src="odissi.jpg" height=200 width=200>
<li>Kathakali<img src="kathakali.jpg" height=200 width=200>
<li> MohiniAttam<img src="mohini.jpg" height=200 width=200>
</ol>
</font> </body> </html>
2. File name: liststyle.css
<style>
ul.a {list-style-type: circle;}
ul.b {list-style-type: square; }
ul.c {list-style-type: disc; }
ol.d {list-style-type: decimal;}
ol.e {list-style-type: lower-alpha;}
ol.f {list-style-type: lower-roman;}
</style>
10
OUT PUT
RESULT
Thus inline and external styles are applied to the html file and the program was executed
successfully.
11
EX NO:3 CLIENT SIDE SCRIPTS FOR VALIDATING WEB FORM
DATE: CONTROLS USING DHTML
AIM
To create a web form with client side validation using Java script.
ALGORITHM
1. Insert a <form> element in the HTML document with the following attributes:
Name – to identify the form element.
Action – specifies the target of the form data to be submitted.
Onsubmit – to call the Java script validation function when the submit button is pressed.
2. Insert all the necessary form elements such as <input>, <textarea>, <select>, and <fieldset>.
3. Insert various types of input fields (such as text, radio, checkbox, and submit) by using „type‟ attribute
of <input> element.
4. Embed the form validation function within the head section of the HTML document by using <script>
element as follows: <script type="text/javascript">.
5. Add the necessary elements in formvalid.html file.
6. Create register.html file for displaying “register successful”.
7. Execute formvalid.html file in any of the web browsers that support javascript.
Required files to run:
1. formvalid.html
2. register.html
PROGRAM
File Name:formvalid.html
<html> <head>
<title>Form Validation Using Java Script</title>
<script type="text/javascript">
12
function validation()
{
if(document.f1.name.value=="")
{
window.alert("Plz Enter Your Name");
return false;
}
else if(document.f1.email.value=="")
{
window.alert("Plz Enter Your E-mail:");
return false;
}
else if(document.f1.email.value.indexOf('@gmail.com')==-1)
{
window.alert("Plz Enter Your Valid E-mail");
return false;
}
else if(document.f1.addr.value=="")
{
window.alert("Plz Enter Your Address");
return false;
}
else if(document.f1.country.selectedIndex==0)
{
window.alert("Plz Select Your Country");
return false;
}
else if((document.f1.rdo[0].checked==false)&&(document.f1.rdo[1].checked==false))
13
{
window.alert("Plz Choose Your Gender");
return false;
}
else if((document.f1.chk[0].checked==false)&&(document.f1.chk[1].checked==false))
{
window.alert("Plz Select Your Qualification");
return false;
}
else
return true;
}
</script> </head>
<body bgcolor="lightgreen">
<h3 style="text-align:center">Web Form Validation Using Java Script</h3>
<form name="f1" action="Register.html" onsubmit="return validation()">
<fieldset>
<legend>Registration Form</legend> <br/>
<table border="1">
<tr> <td>Name:</td> <td><input type="text" name="name"></td> </tr>
<tr> <td>E-mail:</td> <td><input type="text" name="email"></td> </tr>
<tr> <td>Address:</td> <td><Textarea name="addr" rows="5" cols="20"></Textarea></td> </tr>
<tr> <td>Country:</td> <td> <select name="country">
<option>---Select Your Country---</option>
<option>India</option>
<option>USA</option>
<option>AUS</option>
<option>UK</option>
</select> </td> </tr>
<tr> <td>Gender:</td>
<td> <input type="radio" name="rdo">Male <input type="radio" name="rdo">Female </td> </tr>
14
<tr> <td>Qualification:</td> <td>
<input type="checkbox" name="chk">B.E
<input type="checkbox" name="chk">M.E
</td> </tr> </table> <br/>
<input type="submit" value="Register"> </fieldset> </form> </body> </html>
File Name: register.html
<html> <head> <title>Registration Successful</title> </head>
<body> <h3>Registered Successfully.......!</h3>
</body> </html>
OUTPUT
15
RESULT
Thus the form validation program is executed successfully and the output is verified.
16
EX. NO:4
DATE: COLOR PALETTE USING JAVA
AIM
To write the java program to create applets incorporating the following features:
1. Create a color palette with matrix of buttons.
2. Set background and Foreground of the control text area by selecting a color from color palette.
3. In order to select Foreground or background use check box control as radio buttons.
ALGORITHM
1. Import all necessary packages and classes.
2. Define a class CPalette that extends Applet and implements the interfaces ActionListener and
ItemListener.
3. Define the objects for the controls such as Button, CheckboxGroup, Checkbox and TextArea.
4. Add all the controls by using the init() method of Applet class.
5. Arrange all the controls by using the method setBounds().
6. Set the background color for each buttons by using the method setBackground().
7. Make the controls to listen the action by using the method addActionListener().
8. Make the frame visible by using the method setVisible().
9. If the item state value s=1, change the background of the control TextArea.
10. If the item state value s=2, change the foreground of the control TextArea.
11. Compile the java file CPalette.java using java compiler as: javac CPalette.java
12. Create the <applet> code and save it as “ColorPalette.html”.
13. Run the HTML file ColorPalette.html in Internet Explorer.
Required files to run:
1. CPalette.java
2. ColorPalette.html
17
PROGRAM
File Name :CPalette.java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class CPalette extends Applet implements ActionListener,ItemListener
{
Button b1,b2,b3,b4;
CheckboxGroup cg;
Checkbox c1,c2;
TextArea ta;
int s;
public void init()
{
setLayout(null);
b1=new Button();
add(b1);
b1.setBounds(50,50,50,25);
b1.addActionListener(this);
b1.setBackground(Color.blue);
b2=new Button();
add(b2);
b2.setBounds(120,50,50,25);
b2.addActionListener(this);
b2.setBackground(Color.black);
b3=new Button();
add(b3);
18
b3.setBounds(50,95,50,25);
b3.addActionListener(this);
b3.setBackground(Color.red);
b4=new Button();
add(b4);
b4.setBounds(120,95,50,25);
b4.addActionListener(this);
b4.setBackground(Color.cyan);
cg=new CheckboxGroup();
c1=new Checkbox("Background",cg,false);
add(c1);
c1.setBounds(50,200,100,25);
c1.addItemListener(this);
c2=new Checkbox("Foreground",cg,false);
add(c2);
c2.setBounds(50,250,100,25);
c2.addItemListener(this);
ta=new TextArea();
add(ta);
ta.setBounds(150,150,120,120);
setVisible(true);
}
public void itemStateChanged(ItemEvent ie)
{
if(c1.getState()==true)
s=1;
if(c2.getState()==true)
19
s=2;
}
public void actionPerformed(ActionEvent ae)
{
if(s==1)
{
if(ae.getSource()==b1)
ta.setBackground(Color.blue);
else if(ae.getSource()==b2)
ta.setBackground(Color.black);
else if(ae.getSource()==b3)
ta.setBackground(Color.red);
else
ta.setBackground(Color.cyan);
}
if(s==2)
{
if(ae.getSource()==b1)
ta.setForeground(Color.blue);
else if(ae.getSource()==b2)
ta.setForeground(Color.black);
else if(ae.getSource()==b3)
ta.setForeground(Color.red);
else
ta.setForeground(Color.cyan);
}
}
20
}
/* <applet code=”CPalette.class” width=”200” height=”200”> </applet> */
File Name: ColorPalette.html
<html>
<head>
<title>Color Palette Demonstration</title>
</head>
<body bgcolor="lightblue">
<applet code="CPalette.class" width="300" height="400">
</applet>
</body>
</html>
How to run
1. Select Start - > Search for cmd. Now a black screen is displayed.
2. Go to the folder where we are having jdk bin.
D:Program FilesJavajdk1.6.0bin>
3. Create the file named CPalette.java in ..bin folder.
4. Create the file named ColorPalette.html in the same folder.
5. Compile the java file using the command: javac CPalette.java.
6. Verify the CPalette.class file is generated or not using the command dir C*.*.
7. Open the ColorPalette.html using Internet Explorer browser.
8. Select the foreground and background color. Now you can see the change in the text box for color
changing.
21
OUTPUT
RESULT
Thus the colour palette is created and executed using Java applets.
22
EX NO: 5 INVOKING SERVLETS FROM HTML FORM
DATE:
AIM
To write a java program to invoke servlets from HTML forms.
ALGORITHM
1. Write a client side HTML program (client.html) with the following:
i.Insert a <form> that contains the fields such as text, password and one submit button.
ii.Set the URL of the server as the value of form‟s action attribute.
2. Write a java servlet program (server.java) with the following:
i.Define a class server that extends the property of the class GenericServlet.
ii.Handle the request from the client by using the method service() of GenericServlet class.
iii.Get the parameter names from the HTML form by using the method getParameterNames().
iv.Get the parameter values from the HTML forms by using the method getParameter().
v.Send the response to the client by using the method of PrintWriter class.
3. Compile the java source code (server.java).
4. Run the HTML program (client.html).
5. Submit the form data to the server.
Required files to run:
1. client.html
2. server.java
23
PROGRAM
File Name: client.html
<html>
<head>
<title>Invoking Servlet From HTML</title>
</head>
<body>
<form name="form1" method="post" action="http://localhost:8080/servlets-examples/servlet/server">
<fieldset>
<legend>Login</legend>
<table>
<tr>
<td>E-mail:</td>
<td><input type="text" name="LoginID" size="25"/></td>
</tr>
<td>Password:</td>
<td><input type="password" name="Password" size="25"></td>
</tr>
<tr>
<td><input type="submit" Value="Login"></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
24
File Name: server.java
import java.io.*;
import java.util.*;
import javax.servlet.*;
public class server extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res)throws
ServletException,IOException
{
PrintWriter pw=res.getWriter();
pw.print("<h2>Logged in Successfully...</h2>");
pw.print("<h3><u>Login Details</u></h3>");
Enumeration e=req.getParameterNames();
while(e.hasMoreElements())
{
String str1=(String)e.nextElement();
String str2=req.getParameter(str1);
pw.print(str1+"="+str2+"<br/>");
}
pw.close();
}
}
25
OUTPUT
26
RESULT
Thus the program for invoking servlets using HTML is executed successfully and verified.
27
EX NO: 6 AUTHENTICATION AND PERSONAL DETAILS
DATE: FORM FILLING USING SERVLETS
AIM
To write a program in Java servlet to accept the personal information of the user after
authentication and display the users information.
ALGORITHM
1. Create a file named index.html for which the user can fill their username and password for
authentication.
2. If it is the authorized user, it display NewServlet2 file. Otherwise, it display as “Not authorized user”
and exit.
3. In the NewServlet2 file, the user can be redirected to formfill.html.
4. In the formfill.html file, the user can fill his/her personal information and then while pressing submit
button, NewServlet1 file will be displayed.
5. NewServlet1 file displays the user‟s personal information in the form of web page.
Required files to run:
1. index.html
2. formfill.html
3. NewServlet1.java
4. NewServlet2.java
PROGRAM
File: index.html
<html> <body>
<form method="post" action="NewServlet2">
Enter your username: <input type="text" name="t1"><br>
Enter your password: <input type="password" name="t2"><br>
28
<input type="submit" value="OK">
</form> </body> </html>
File: Formfill.html
<html> <head> <title>TODO supply a title</title> </head>
<body>
<form method="post" action="NewServlet1">
Enter your Name: <input type="text" name="t1"><br>
Enter your age: <input type="text" name="t2"><br>
Select your Degree:<br>
<input type="radio" name="r1" value="B.E.,">Engineering<br>
<input type="radio" name="r1" value="B.Sc.,">Science<br>
<input type="radio" name="r1" value="M.B.B.S.,">Medicine<br>
<input type="submit" value="OK">
</form> </body> </html>
File: NewServlet1.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class NewServlet1 extends HttpServlet
{
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
29
response.setContentType("text/html");
try (PrintWriter out = response.getWriter())
{
String name = request.getParameter("t1");
String age= request.getParameter("t2");
String str = request.getParameter("r1");
response.setContentType("text/html");
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet1</title>");
out.println("</head>");
out.println("<body>");
if(name!=null)
{
out.println("Welcome to the website, <b>"+name+"</b><br>");
if(age!=null)
out.println("Your age is "+age+"<br>");
if(str!=null)
out.println("your qualification is "+str);
}
else
out.println("Unfilled Information..");
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
30
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
File: NewServlet2.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
@WebServlet(urlPatterns = {"/NewServlet2"})
public class NewServlet2 extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
try (PrintWriter out = response.getWriter()) {
String str1 = request.getParameter("t1");
String str2 = request.getParameter("t2");
if(str1.equals("india") && (str2.equals("india")))
31
{
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet2</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Logged in Successfully..." + "</h1>");
out.println("<a href=formfill.html>click here to enter personal details</a>");
out.println("</body>");
out.println("</html>");
}
else
{
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet2</title>");
out.println("</head>");
out.println("<body>");
out.println("Username or password is not correct");
out.println("</body>");
out.println("</html>");
}
}
}
@Override
32
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}
OUTPUT
33
34
RESULT
Thus the program for authentication and personal information form filling is executed using java
servlets successfully and output is verified.
35
EX NO:7 JAVA PROGRAM FOR APPLET-SERVLET COMMUNICATION
DATE:
AIM
To write a java program for applet-servlet communication.
ALGORITHM
1. Create a Java Application using File -> New Project -> Categories-Java, Project-Java Application.
Give the Name of the Project as „MyJavaApplication‟ and then click Finish.
2. Create an applet file by right click on the MyJavaApplication project, select New-> Applet. Give the
name of the applet as MyAddApplet.
3. Copy the MyAddApplet code in MyAddApplet.java file.
4. Run the Project.
5. Now we will get the Addition of two numbers applet.
6. Create a New Project by selecting File -> New Project. Give the name of the project as
„MyWebApplication‟.
7. Create a jar file for our applet file by right click on the MyWebApplication project, select Properties,
in the categories, select Packaging and click Add Project to add the created MyJavaApplication project
in the form of jar file. After adding, the jar file will be seen in build/web folder.
8. In the MyWebApplication, index.html file, add the following code within the body section:
<h1> Web Application using NetBeans IDE</h1>
<applet code="MyAddApplet" archive="MyJavaApplication.jar" width="400" height="400" />
</applet>
9. Run the project.
Required files to run:
1. index.html in MyWebApplication project
2. MyAddApplet.java in MyJavaApplication project
3. MyJavaApplication.jar
36
PROGRAM
MyAddApplet.java
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MyAddApplet extends Applet implements ActionListener
{
Button b1;
TextField t1,t2,t3;
Label l1;
public void init()
{
setLayout(new FlowLayout(FlowLayout.LEFT));
t1 = new TextField();
t2 = new TextField();
t3 = new TextField();
l1 = new Label("Add Two Numbers");
add(l1);
add(t1);
add(t2);
b1=new Button("Add");
add(b1);
b1.addActionListener(this);
add(t3);
setVisible(true);
}
37
public void actionPerformed(ActionEvent ae)
{
int a,b,result;
String str;
if(ae.getSource()==b1)
{
str = t1.getText();
a = Integer.parseInt(str);
str = t2.getText();
b = Integer.parseInt(str);
result = a + b;
t3.setText(String.valueOf(result));
}
}
}
38
OUTPUT
RESULT
Thus the program for applet-servlet communication is executed successfully and verified.
39
EX.NO:8
DATE: ONLINE SHOPPING USING JSP
AIM
To write an online book shopping application using JSP.
ALGORITHM
1. Create an index.html file that contains the necessary books to be displayed for purchasing within the
form element. Add Submit button within the form. Add the action as books.jsp for the form element.
2. Create a new jsp file named books.jsp.
3. Calculate the total cost for selected books. Display the cost of book purchase.
4. Pass the cost to sports.jsp using hidden form field included within the form element in books.jsp file.
5. Create a new jsp file named sports.jsp.
6. Calculate the total cost of purchasing the sports and books.
7. Display the total cost of purchasing.
8. Run the web application.
Required programs to run:
1. index.html
2. books.jsp
3. sports.jsp
PROGRAM
index.html
<html> <head> <title>Online shopping - Books</title> </head>
<body>
<form method="post" action="books.jsp">
<h3>Select the books in the following list: <br>
40
<select name="s1" multiple>
<option value="1">Java Unleashed
<option value="2">Java Server Programming
<option value="3">JSP Bible
<option value="4">Java Servlets
</select> <br>
<input type="submit" value="OK"> <br> </form> </body> </html>
books.jsp
<html> <head> <title>Online Shopping - Sports items</title> </head>
<body>
<% int cost=0;
String s[] = request.getParameterValues("s1");
for(int i=0;i<s.length;i++)
{
if(s[i].equals("1"))
cost += 200;
else if(s[i].equals("2"))
cost += 300;
else if(s[i].equals("3"))
cost += 350;
else if(s[i].equals("4"))
cost += 300;
}
%>
41
<h3> You have selected <%= s.length %> Books. <br>
The cost is <%= cost %></h3>
<form method="post" action="sports.jsp">
<input type="hidden" name="h1" value='<%=cost%>'> <br>
Select the sports items: <br>
<select name="s1" multiple>
<option value="1">Ball
<option value="2">Bat
<option value="3">Carrom Board
<option value="4">Chess Board
</select> <br> <input type="submit" value="OK"> </form> </body></html>
sports.jsp
<html> <head> <title>Onlien Shopping - Final Cost </title> </head>
<body>
<% String s = request.getParameter("h1");
String s1[] = request.getParameterValues("s1");
int cost = Integer.parseInt(s);
%>
<h3> You have selected <%=s1.length%> Sport items. <br>
<%
for(int i=0;i<s1.length;i++)
{
if(s1[i].equals("1"))
cost += 100;
else if(s1[i].equals("2"))
cost += 300;
else if(s1[i].equals("3"))
42
cost += 1500;
else if(s1[i].equals("4"))
cost += 500;
}
%>
The total cost of purchase is: <%=cost%> </h3> </body> </html>
OUTPUT
43
44
RESULT
Thus online shopping program is created using JSP and executed successfully.
EX NO:9 DISPLAYING CRICKET PLAYERS PROFILE USING AJAX
45
DATE:
AIM
To write a program using Ajax for displaying cricket players profile.
ALGORITHM
1. Create an XHTML document (AjaxDemo.html) with the following:
i. Insert some images of cricket players.
ii. Call the function getContent() with respect to the onmouseover event. The function accepts an
argument that is the URL of another page contains the information about the player.
iii. Call the function clearContent() with respect to the onmouseout event.
2. Within this XHTML document, insert AJAX based JavaScript code with the following:
i. Create the object for ActiveXObject (for older versions of browsers such as IE5 and IE6).
ii. Create the object for XMLHttpRequest (for modern browsers such as IE7+, Firefox, Chrome, Safari,
and Opera).
iii. AJAX send the request with the use of send() and open() methods.
iv. The response is obtained with the use of responseText Property.
v. AJAX Call the function diplayProfile() with respect to the event onreadystatechange.
3. Run the program.
Required files to run:
1. Ajaxdemo.html
2. sachin.html
3. dravid.html
4. kohli.html
5. raina.html
46
6. yuvi.html
7. veeru.html
8. dhoni.html
9. sachin.jpg
10. dravid.jpg
11. kohli.jpg
12. raina.jpg
13. yuvi.jpg
14. veeru.jpg
15. dhoni.jpg
PROGRAM
Ajaxdemo.html
<html> <head> <title>Ajax Demo...</title>
<style type="text/css"> .box{border:1px solid blue;padding:10px} </style>
<script type="text/javascript">
var req;
function getContent(url)
{
if(window.ActiveXObject)
req=new ActiveXObject("Microsoft.XMLHTTP");
else if(window.XMLHttpRequest)
req=new XMLHttpRequest();
req.onreadystatechange=diplayProfile;
req.open('POST',url,true);
47
req.send(null);
}
function diplayProfile()
{
if(req.readyState==4)
document.getElementById('contentArea').innerHTML=req.responseText;
}
function clearContent()
{ document.getElementById('contentArea').innerHTML=''; }
</script> </head> <body bgcolor="cyan">
<h1>Mouse over the image for More Information</h1>
<img src="sachin.jpg" height="95" width="80" onmouseover='getContent("sachin.html")'
onmouseout='clearContent()'/>
<img src="dravid.jpg" height="95" width="80" onmouseover='getContent("dravid.html")'
onmouseout='clearContent()'/>
<img src="kohli.jpg" height="95" width="80" onmouseover='getContent("kohli.html")'
onmouseout='clearContent()'/>
<img src="raina.jpg" height="95" width="80" onmouseover='getContent("raina.html")'
onmouseout='clearContent()'/>
<img src="yuvi.jpg" height="95" width="80" onmouseover='getContent("yuvi.html")'
onmouseout='clearContent()'/>
<img src="veeru.jpg" height="95" width="80" onmouseover='getContent("veeru.html")'
onmouseout='clearContent()'/>
<img src="dhoni.jpg" height="95" width="80" onmouseover='getContent("dhoni.html")'
onmouseout='clearContent()'/>
<div class="box" id="contentArea"/> </body> </html>
48
sachin.html
<html> <body> <b>Full name:</b> Sachin Ramesh Tendulkar<br/><br/>
<b>Born:</b> April 24, 1973, Bombay (now Mumbai), Maharashtra<br/><br/>
<b>Major teams:</b> India, Asia XI, Mumbai, Mumbai Indians, Yorkshire<br/><br/>
<b>Nickname:</b> Tendlya, Little Master<br/><br/>
<b>Playing role:</b> Top-order batsman<br/><br/>
<b>Batting style:</b> Right-hand bat<br/><br/>
<b>Bowling style:</b> Right-arm offbreak, Legbreak googly </body></html>
dravid.html
<html> <body> <b>Full name:</b> Rahul Sharad Dravid<br/><br/>
<b>Born:</b> January 11, 1973, Indore, Madhya Pradesh <br/><br/>
<b>Major teams:</b> India, Scotland, Asia XI, ICC World XI, Karnataka, Kent,
Marylebone Cricket Club, Rajasthan Royals, Royal Challengers Bangalore<br/><br/>
<b>Nickname:</b> The Wall<br/><br/> <b>Playing role:</b> Top-order batsman<br/><br/>
<b>Batting style:</b> Right-hand bat<br/><br/> <b>Bowling style:</b> Right-arm offbreak
</body> </html>
kohli.html
<html> <body> <b>Full name:</b> Virat Kohli<br/><br/>
<b>Born:</b>November 5, 1988, Delhi<br/><br/>
<b>Major teams:</b>India, Delhi, India Red, India Under-19s, Royal Challengers Bangalore<br/><br/>
<b>Playing role:</b>Middle-order batsman<br/><br/>
<b>Batting style:</b>Right-hand bat<br/><br/> <b>Bowling style:</b>Right-arm medium
</body> </html>
49
raina.html
<html> <body> <b>Full name:</b> Suresh Kumar Raina<br/><br/>
<b>Born:</b>November 27, 1986, Muradnagar, Ghaziabad, Uttar Pradesh<br/><br/>
<b>Major teams:</b>India, Chennai Super Kings, India Blue, India Under-19s, Indian Board President's
XI, Rajasthan Cricket Association President's XI, Uttar Pradesh, Uttar Pradesh Under-16s<br/><br/>
<b>Playing role:</b>Middle-order batsman<br/><br/>
<b>Batting style:</b>Left-hand bat<br/><br/> <b>Bowling style:</b> Right-arm offbreak
</body> </html>
yuvi.html
<html> <body> <b>Full name:</b>Yuvraj Singh<br/><br/>
<b>Born:</b>December 12, 1981, Chandigarh<br/><br/>
<b>Major teams:</b>India, Asia XI, Kings XI Punjab, Pune Warriors, Punjab, Yorkshire<br/><br/>
<b>Playing role:</b>Middle-order batsman<br/><br/>
<b>Batting style:</b>Left-hand bat<br/><br/> <b>Bowling style:</b>Slow left-arm orthodox
</body> </html>
veeru.html
<html> <body> <b>Full name:</b>Virender Sehwag<br/><br/>
<b>Born:</b>October 20, 1978, Delhi<br/><br/>
<b>Major teams:</b>India, Asia XI, Delhi, Delhi Daredevils, ICC World XI, India Blue, Leicestershire,
Rajasthan Cricket Association President's XI<br/><br/>
<b>Playing role:</b>Top-order batsman<br/><br/>
<b>Batting style:</b>Right-hand bat<br/><br/>
<b>Bowling style:</b>Right-arm offbreak </body> </html>
50
dhoni.html
<html> <body bgcolor="cyan"> <b>Full name:</b> Mahendra Singh Dhoni<br/><br/>
<b>Born:</b>July 7, 1981, Ranchi, Bihar (now Jharkhand)<br/><br/>
<b>Major teams:</b>India, Asia XI, Bihar, Chennai Super Kings, Jharkhand<br/><br/>
<b>Playing role:</b>Wicketkeeper batsman<br/><br/>
<b>Batting style:</b>Right-hand bat<br/><br/>
<b>Bowling style:</b>Right-arm medium </body> </html>
OUTPUT
RESULT
Thus the program of displaying cricket players information using Ajax is successfully executed
and the output is verified.
51
EX NO:10 STUDENT RANKING DETAILS USING XML AND XSLT
DATE:
AIM
To write the program using XML and XSLT for displaying student ranking details based on
CGPA values.
ALGORITHM
1.Create an XML document (stud.xml) that contains the markup tags such as <name>, <dept>, and
<rno>.
2.Create an XSL document (stud.xsl) that defines the style to display an XML document.
3.Associate style sheet (XSL) with XML using the markup <?xml-stylesheet>. Add the necessary
sorting markup in XSL file.
4.Load the XML document (stud.xml) in the browser.
Required files to run:
1. stud.xml
2. stud.xsl
PROGRAM
File Name:stud.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="stud.xsl"?> <studInfo>
<stud> <name>Amala</name> <dept>CSE</dept> <rno>97709205001</rno>
<cgpa>8.5</cgpa></stud>
<stud> <name>Deepak</name> <dept>CSE</dept> <rno>97709205002</rno>
<cgpa>7.8</cgpa></stud>
<stud> <name>Sangeetha</name> <dept>CSE</dept> <rno>97709205003</rno>
<cgpa>8.8</cgpa></stud>
52
<stud> <name>Usha</name> <dept>CSE</dept> <rno>97709205004</rno> <cgpa>7.5</cgpa></stud>
</studInfo>
stud.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html> <body>
<h2>Students Information</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>name</th>
<th>dept</th>
<th>rno</th>
<th>cgpa</th>
</tr>
<xsl:for-each select="studInfo/stud">
<xsl:sort select="cgpa"/>
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of select="dept"/></td>
<td><xsl:value-of select="rno"/></td>
<td><xsl:value-of select="cgpa"/></td> </tr>
</xsl:for-each>
53
</table> </body> </html>
</xsl:template>
</xsl:stylesheet>
OUTPUT
RESULT
Thus the program for student information is displayed with order of CGPA using XML and
XSLT is successfully executed and the output is verified.
54
EX NO:10 PROGRAM TO ACCESS THE INFO FROM DATABASE USING JDBC
DATE: CONNECTIVITY
AIM
To write a java program to access the information from Database using JDBC Connectivity.
ALGORITHM:
1. Start the process
2. Install the JDBC Driver using forName () method
3. Create a table with required fields.
4. Create a data source using ODBC Data source in windows.
5. Establish connection to the Data source using getConnection() Method.
6. Create a statement object in the above connection object in order to send query to the table.
7. Send the query to the table using executeQuery() method.
8. Store the results in the ResultSet object.
9. Display the result on the screen.
10. Stop the process.
Required files:
1. stud.mdb
2. odbctest.java
PROGRAM
import java.sql.*;
class odbctest
{
55
public static void main(String a[])
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c=DriverManager.getConnection(
"jdbc:odbc: students”);
Statement s=c.createStatement();
ResultSet rs;
String q="select * from stud";
rs=s.executeQuery(q);
System.out.println("NametttBranchttClassttGrade ");
System.out.println("----ttt------ tt-----tt-----");
while(rs.next())
{
System.out.print(rs.getString(1)+"tt");
System.out.print(rs.getString(2)+"tt");
System.out.print(rs.getString(3)+"tt");
System.out.println(rs.getString(4)+"tt");
}
}catch(Exception e)
{ System.out.println("Error"+e); }
}
}
56
OUTPUT
RESULT
Thus the database connectivity is done and the program is executed for selecting the students
from students data source successfully.

More Related Content

What's hot (20)

Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Html frames
Html framesHtml frames
Html frames
 
HTML practical file
HTML practical fileHTML practical file
HTML practical file
 
Html project
Html projectHtml project
Html project
 
HTML practicals
HTML practicals HTML practicals
HTML practicals
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Wireless Markup Language
Wireless Markup LanguageWireless Markup Language
Wireless Markup Language
 
Html Ppt
Html PptHtml Ppt
Html Ppt
 
Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12Bca sem 6 php practicals 1to12
Bca sem 6 php practicals 1to12
 
Timestamp protocols
Timestamp protocolsTimestamp protocols
Timestamp protocols
 
Html links
Html linksHtml links
Html links
 
Event In JavaScript
Event In JavaScriptEvent In JavaScript
Event In JavaScript
 
Html frames
Html framesHtml frames
Html frames
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Html presentation
Html presentationHtml presentation
Html presentation
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 

Viewers also liked

Practical file on web technology(html)
Practical file on web technology(html)Practical file on web technology(html)
Practical file on web technology(html)RAJWANT KAUR
 
ITFinal it lab manual
ITFinal it lab manualITFinal it lab manual
ITFinal it lab manualKavar Neal
 
Web Design Unit.doc
Web Design Unit.docWeb Design Unit.doc
Web Design Unit.docbutest
 
Lab 4: Introduction to HTML
Lab 4: Introduction to HTMLLab 4: Introduction to HTML
Lab 4: Introduction to HTMLvanessajade
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questionsVipul Naik
 
Web engineering UNIT IV as per RGPV syllabus
Web engineering UNIT IV as per RGPV syllabusWeb engineering UNIT IV as per RGPV syllabus
Web engineering UNIT IV as per RGPV syllabusNANDINI SHARMA
 
Brianna Peoples Event Portfolio
Brianna Peoples Event PortfolioBrianna Peoples Event Portfolio
Brianna Peoples Event PortfolioBrianna Peoples
 
ADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCED
ADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCEDADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCED
ADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCEDMichele Worden
 

Viewers also liked (12)

Practical file on web technology(html)
Practical file on web technology(html)Practical file on web technology(html)
Practical file on web technology(html)
 
Practical File Itm
Practical File ItmPractical File Itm
Practical File Itm
 
Html tables examples
Html tables   examplesHtml tables   examples
Html tables examples
 
ITFinal it lab manual
ITFinal it lab manualITFinal it lab manual
ITFinal it lab manual
 
Web Design Unit.doc
Web Design Unit.docWeb Design Unit.doc
Web Design Unit.doc
 
Lab 4: Introduction to HTML
Lab 4: Introduction to HTMLLab 4: Introduction to HTML
Lab 4: Introduction to HTML
 
Html viva questions
Html viva questionsHtml viva questions
Html viva questions
 
CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
 
Web engineering UNIT IV as per RGPV syllabus
Web engineering UNIT IV as per RGPV syllabusWeb engineering UNIT IV as per RGPV syllabus
Web engineering UNIT IV as per RGPV syllabus
 
Semiotica de la arq
Semiotica de la arqSemiotica de la arq
Semiotica de la arq
 
Brianna Peoples Event Portfolio
Brianna Peoples Event PortfolioBrianna Peoples Event Portfolio
Brianna Peoples Event Portfolio
 
ADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCED
ADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCEDADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCED
ADMISSION BINDER SINGLE PAGE PDF FORMAT REDUCED
 

Similar to Web technology lab manual

Similar to Web technology lab manual (20)

1cst
1cst1cst
1cst
 
Web technology
Web technologyWeb technology
Web technology
 
Web technology
Web technologyWeb technology
Web technology
 
Print this
Print thisPrint this
Print this
 
Unit 1wt
Unit 1wtUnit 1wt
Unit 1wt
 
Unit 1wt
Unit 1wtUnit 1wt
Unit 1wt
 
Dhtml chapter2
Dhtml chapter2Dhtml chapter2
Dhtml chapter2
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 
Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De Htlm
 
Html
HtmlHtml
Html
 
Md5 decrypter
Md5 decrypterMd5 decrypter
Md5 decrypter
 
Css1
Css1Css1
Css1
 
TYBSC prac soln
TYBSC prac solnTYBSC prac soln
TYBSC prac soln
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
 
HTML.pptx
HTML.pptxHTML.pptx
HTML.pptx
 
計算機概論20161205
計算機概論20161205計算機概論20161205
計算機概論20161205
 
Web Developement Workshop (Oct 2009 -Day 1)
Web Developement Workshop (Oct 2009 -Day 1)Web Developement Workshop (Oct 2009 -Day 1)
Web Developement Workshop (Oct 2009 -Day 1)
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
INTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptxINTRODUCTION TO HTML & CSS .pptx
INTRODUCTION TO HTML & CSS .pptx
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 

Recently uploaded

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 

Recently uploaded (20)

Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 

Web technology lab manual

  • 1. 1 EX. NO: 1 DATE: IMAGE MAPPING USING HTML AIM To write the html code to perform the Image Mapping. ALGORITHM 1. Start. 2. Write the code for tnmap.html. 3. Perform mapping using <MAP> tag. 4. Insert Hyperlink using <A href>. 5. Display Results. 6. Stop. Required files to run: 1. maptn.jpg 2. salem.gif 3. erode.gif 4. covai.gif 5. tnmap.html 6. erode.html 7. salem.html 8. covai.html PROGRAM: File Name: tnmap.html <!-- tnmap.html --> <html> <head> <title>TamilNadu</title> </head>
  • 2. 2 <body> <map name="tamilnadu"> <area href="salem.html" shape="circle" coords="78,78,10"> <area href="erode.html" shape="circle" coords="60,90,10"> <area href="covai.html" shape="circle" coords="50,120,10"> </map> <img src="maptn.jpg" border="1" usemap="#tamilnadu"> </body> </html> 2. File Name: salem.html <html><head><title>salem page </title></head> <body> This is the Salem district in Tamilnadu. <br> <img src="salem.gif"> <br> Salem is surrounded by hills and is known for mango cultivation.<br> There were eleven taluks in the district. They are: <ol> <li>Attur <li>Edappadi <li>Gangavalli <li>Mettur <li>Omalur <li>Salem <li>Salem South <li>Salem West <li>Sangagiri <li>Valapady <li>Yercaud </ol> <a href="tnmap.html">home </a> </body></html>
  • 3. 3 3. File Name: erode.html <html><head><title>erode page </title></head> <body> This is the Erode district in Tamilnadu. <br> <img src="erode.gif"> <br> Erode was the largest district by area in the state before the Formation of Tirupur District.<br> There were six taluks in the district. They are: <ol> <li>Andiyur <li>Bhavani <li>Erode <li>Gobichetipalayam <li>Perundurai <li>Sathyamangalam </ol> <a href="tnmap.html">home </a> </body></html> 4. File Name: covai.html <html><head><title>covai page </title></head> <body> This is the coimbatore district in Tamilnadu.<br> <br> <img src="covai.gif"> <br> Coimbatore is the second largest city in Tamilnadu. There were ten taluks in the district. They are: <ol> <li>Annur <li>Coimbatore (North) <li>Coimbatore (South)
  • 5. 5
  • 6. 6 RESULT Thus image mapping has been performed using HTML.
  • 7. 7 EX NO: 2 DATE: APPLYING INLINE CASCADING STYLE SHEETS TO A WEB PAGE AIM To demonstrate the use of style sheets in HTML. ALGORITHM 1. Create a simple HTML page. 2. Write internal CSS using <style> tag in the same page become internal CSS. 3. Create another CSS file using <style> tag with extension .css file for external CSS file. 4. Include the external CSS file in HTML file. 5. Find the style changes on the page. Required files to run 1. parliament.jpg 2. bharat.jpg 3. odissi.jpg 4. kathakali.jpg 5. mohini.jpg 6. liststyle.css 7. style1.html Program Filename: style1.html <html> <head> <title>Inline Style Sheet</title> <!-- External style sheet starts --> <link rel="stylesheet" type="text/css" href="liststyle.css"> <!-- External style sheet ends -->
  • 8. 8 <!-- Internal style sheet starts --> <style> p.ex1 { font-family: Arial, Helvetica, sans-serif; font-size: 46; color: purple; } </style> <!-- Internal style sheet ends --> </head> <body bgcolor=gold> <center> <p class="ex1"> All About INDIA </p> </center> <p> <ul class="a"> <li>India never invaded any country in her last 100000 years of history. <li>When many cultures were only nomadic forest dwellers over 5000 years ago, Indians established Harappan culture in Sindhu Valley (Indus Valley Civilization) <li>The name 'India' is derived from the River Indus, the valleys around which were the home of the early settlers. The Aryan worshippers referred to the river Indus as the Sindhu. <li>The Persian invaders converted it into Hindu. The name `Hindustan' combines Sindhu and Hindu and thus refers to the land of the Hindus. <li>Chess was invented in India. </ul> <!-- inline styles starts --> <p style="color:blue;text-align:center;"> The Parliament <br><img src="parliament.jpg" width=200 height=200> </p> <!-- inline style ends --> <font size="36px" face="Times New Roman" color=red> Culture Of India</font> <p> <ul class="b"> <li> The culture of India has been shaped by the long history of India, its unique geography and the absorption of customs, traditions and ideas from some of its neighbors as well as by preserving its ancient heritages, which were formed during the Indus Valley Civilization and evolved further during the Vedic age, rise and decline of Buddhism, Golden age, Muslim conquests and European colonization.
  • 9. 9 <li>India's great diversity of cultural practices, languages, customs, and traditions are examples of this unique co-mingling over the past five millennia. </ul> </p> <font size="36px" face="Times New Roman" color=red>Indian Classical Dances</font></br> <font size="4px" face="Times New Roman" color=blue> The various dance forms of India are <ol class="d"> <li> Bharatanatyam<img src="bharat.jpg" height=200 width=200> <li>Odissi<img src="odissi.jpg" height=200 width=200> <li>Kathakali<img src="kathakali.jpg" height=200 width=200> <li> MohiniAttam<img src="mohini.jpg" height=200 width=200> </ol> </font> </body> </html> 2. File name: liststyle.css <style> ul.a {list-style-type: circle;} ul.b {list-style-type: square; } ul.c {list-style-type: disc; } ol.d {list-style-type: decimal;} ol.e {list-style-type: lower-alpha;} ol.f {list-style-type: lower-roman;} </style>
  • 10. 10 OUT PUT RESULT Thus inline and external styles are applied to the html file and the program was executed successfully.
  • 11. 11 EX NO:3 CLIENT SIDE SCRIPTS FOR VALIDATING WEB FORM DATE: CONTROLS USING DHTML AIM To create a web form with client side validation using Java script. ALGORITHM 1. Insert a <form> element in the HTML document with the following attributes: Name – to identify the form element. Action – specifies the target of the form data to be submitted. Onsubmit – to call the Java script validation function when the submit button is pressed. 2. Insert all the necessary form elements such as <input>, <textarea>, <select>, and <fieldset>. 3. Insert various types of input fields (such as text, radio, checkbox, and submit) by using „type‟ attribute of <input> element. 4. Embed the form validation function within the head section of the HTML document by using <script> element as follows: <script type="text/javascript">. 5. Add the necessary elements in formvalid.html file. 6. Create register.html file for displaying “register successful”. 7. Execute formvalid.html file in any of the web browsers that support javascript. Required files to run: 1. formvalid.html 2. register.html PROGRAM File Name:formvalid.html <html> <head> <title>Form Validation Using Java Script</title> <script type="text/javascript">
  • 12. 12 function validation() { if(document.f1.name.value=="") { window.alert("Plz Enter Your Name"); return false; } else if(document.f1.email.value=="") { window.alert("Plz Enter Your E-mail:"); return false; } else if(document.f1.email.value.indexOf('@gmail.com')==-1) { window.alert("Plz Enter Your Valid E-mail"); return false; } else if(document.f1.addr.value=="") { window.alert("Plz Enter Your Address"); return false; } else if(document.f1.country.selectedIndex==0) { window.alert("Plz Select Your Country"); return false; } else if((document.f1.rdo[0].checked==false)&&(document.f1.rdo[1].checked==false))
  • 13. 13 { window.alert("Plz Choose Your Gender"); return false; } else if((document.f1.chk[0].checked==false)&&(document.f1.chk[1].checked==false)) { window.alert("Plz Select Your Qualification"); return false; } else return true; } </script> </head> <body bgcolor="lightgreen"> <h3 style="text-align:center">Web Form Validation Using Java Script</h3> <form name="f1" action="Register.html" onsubmit="return validation()"> <fieldset> <legend>Registration Form</legend> <br/> <table border="1"> <tr> <td>Name:</td> <td><input type="text" name="name"></td> </tr> <tr> <td>E-mail:</td> <td><input type="text" name="email"></td> </tr> <tr> <td>Address:</td> <td><Textarea name="addr" rows="5" cols="20"></Textarea></td> </tr> <tr> <td>Country:</td> <td> <select name="country"> <option>---Select Your Country---</option> <option>India</option> <option>USA</option> <option>AUS</option> <option>UK</option> </select> </td> </tr> <tr> <td>Gender:</td> <td> <input type="radio" name="rdo">Male <input type="radio" name="rdo">Female </td> </tr>
  • 14. 14 <tr> <td>Qualification:</td> <td> <input type="checkbox" name="chk">B.E <input type="checkbox" name="chk">M.E </td> </tr> </table> <br/> <input type="submit" value="Register"> </fieldset> </form> </body> </html> File Name: register.html <html> <head> <title>Registration Successful</title> </head> <body> <h3>Registered Successfully.......!</h3> </body> </html> OUTPUT
  • 15. 15 RESULT Thus the form validation program is executed successfully and the output is verified.
  • 16. 16 EX. NO:4 DATE: COLOR PALETTE USING JAVA AIM To write the java program to create applets incorporating the following features: 1. Create a color palette with matrix of buttons. 2. Set background and Foreground of the control text area by selecting a color from color palette. 3. In order to select Foreground or background use check box control as radio buttons. ALGORITHM 1. Import all necessary packages and classes. 2. Define a class CPalette that extends Applet and implements the interfaces ActionListener and ItemListener. 3. Define the objects for the controls such as Button, CheckboxGroup, Checkbox and TextArea. 4. Add all the controls by using the init() method of Applet class. 5. Arrange all the controls by using the method setBounds(). 6. Set the background color for each buttons by using the method setBackground(). 7. Make the controls to listen the action by using the method addActionListener(). 8. Make the frame visible by using the method setVisible(). 9. If the item state value s=1, change the background of the control TextArea. 10. If the item state value s=2, change the foreground of the control TextArea. 11. Compile the java file CPalette.java using java compiler as: javac CPalette.java 12. Create the <applet> code and save it as “ColorPalette.html”. 13. Run the HTML file ColorPalette.html in Internet Explorer. Required files to run: 1. CPalette.java 2. ColorPalette.html
  • 17. 17 PROGRAM File Name :CPalette.java import java.applet.*; import java.awt.*; import java.awt.event.*; public class CPalette extends Applet implements ActionListener,ItemListener { Button b1,b2,b3,b4; CheckboxGroup cg; Checkbox c1,c2; TextArea ta; int s; public void init() { setLayout(null); b1=new Button(); add(b1); b1.setBounds(50,50,50,25); b1.addActionListener(this); b1.setBackground(Color.blue); b2=new Button(); add(b2); b2.setBounds(120,50,50,25); b2.addActionListener(this); b2.setBackground(Color.black); b3=new Button(); add(b3);
  • 18. 18 b3.setBounds(50,95,50,25); b3.addActionListener(this); b3.setBackground(Color.red); b4=new Button(); add(b4); b4.setBounds(120,95,50,25); b4.addActionListener(this); b4.setBackground(Color.cyan); cg=new CheckboxGroup(); c1=new Checkbox("Background",cg,false); add(c1); c1.setBounds(50,200,100,25); c1.addItemListener(this); c2=new Checkbox("Foreground",cg,false); add(c2); c2.setBounds(50,250,100,25); c2.addItemListener(this); ta=new TextArea(); add(ta); ta.setBounds(150,150,120,120); setVisible(true); } public void itemStateChanged(ItemEvent ie) { if(c1.getState()==true) s=1; if(c2.getState()==true)
  • 19. 19 s=2; } public void actionPerformed(ActionEvent ae) { if(s==1) { if(ae.getSource()==b1) ta.setBackground(Color.blue); else if(ae.getSource()==b2) ta.setBackground(Color.black); else if(ae.getSource()==b3) ta.setBackground(Color.red); else ta.setBackground(Color.cyan); } if(s==2) { if(ae.getSource()==b1) ta.setForeground(Color.blue); else if(ae.getSource()==b2) ta.setForeground(Color.black); else if(ae.getSource()==b3) ta.setForeground(Color.red); else ta.setForeground(Color.cyan); } }
  • 20. 20 } /* <applet code=”CPalette.class” width=”200” height=”200”> </applet> */ File Name: ColorPalette.html <html> <head> <title>Color Palette Demonstration</title> </head> <body bgcolor="lightblue"> <applet code="CPalette.class" width="300" height="400"> </applet> </body> </html> How to run 1. Select Start - > Search for cmd. Now a black screen is displayed. 2. Go to the folder where we are having jdk bin. D:Program FilesJavajdk1.6.0bin> 3. Create the file named CPalette.java in ..bin folder. 4. Create the file named ColorPalette.html in the same folder. 5. Compile the java file using the command: javac CPalette.java. 6. Verify the CPalette.class file is generated or not using the command dir C*.*. 7. Open the ColorPalette.html using Internet Explorer browser. 8. Select the foreground and background color. Now you can see the change in the text box for color changing.
  • 21. 21 OUTPUT RESULT Thus the colour palette is created and executed using Java applets.
  • 22. 22 EX NO: 5 INVOKING SERVLETS FROM HTML FORM DATE: AIM To write a java program to invoke servlets from HTML forms. ALGORITHM 1. Write a client side HTML program (client.html) with the following: i.Insert a <form> that contains the fields such as text, password and one submit button. ii.Set the URL of the server as the value of form‟s action attribute. 2. Write a java servlet program (server.java) with the following: i.Define a class server that extends the property of the class GenericServlet. ii.Handle the request from the client by using the method service() of GenericServlet class. iii.Get the parameter names from the HTML form by using the method getParameterNames(). iv.Get the parameter values from the HTML forms by using the method getParameter(). v.Send the response to the client by using the method of PrintWriter class. 3. Compile the java source code (server.java). 4. Run the HTML program (client.html). 5. Submit the form data to the server. Required files to run: 1. client.html 2. server.java
  • 23. 23 PROGRAM File Name: client.html <html> <head> <title>Invoking Servlet From HTML</title> </head> <body> <form name="form1" method="post" action="http://localhost:8080/servlets-examples/servlet/server"> <fieldset> <legend>Login</legend> <table> <tr> <td>E-mail:</td> <td><input type="text" name="LoginID" size="25"/></td> </tr> <td>Password:</td> <td><input type="password" name="Password" size="25"></td> </tr> <tr> <td><input type="submit" Value="Login"></td> </tr> </table> </fieldset> </form> </body> </html>
  • 24. 24 File Name: server.java import java.io.*; import java.util.*; import javax.servlet.*; public class server extends GenericServlet { public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException { PrintWriter pw=res.getWriter(); pw.print("<h2>Logged in Successfully...</h2>"); pw.print("<h3><u>Login Details</u></h3>"); Enumeration e=req.getParameterNames(); while(e.hasMoreElements()) { String str1=(String)e.nextElement(); String str2=req.getParameter(str1); pw.print(str1+"="+str2+"<br/>"); } pw.close(); } }
  • 26. 26 RESULT Thus the program for invoking servlets using HTML is executed successfully and verified.
  • 27. 27 EX NO: 6 AUTHENTICATION AND PERSONAL DETAILS DATE: FORM FILLING USING SERVLETS AIM To write a program in Java servlet to accept the personal information of the user after authentication and display the users information. ALGORITHM 1. Create a file named index.html for which the user can fill their username and password for authentication. 2. If it is the authorized user, it display NewServlet2 file. Otherwise, it display as “Not authorized user” and exit. 3. In the NewServlet2 file, the user can be redirected to formfill.html. 4. In the formfill.html file, the user can fill his/her personal information and then while pressing submit button, NewServlet1 file will be displayed. 5. NewServlet1 file displays the user‟s personal information in the form of web page. Required files to run: 1. index.html 2. formfill.html 3. NewServlet1.java 4. NewServlet2.java PROGRAM File: index.html <html> <body> <form method="post" action="NewServlet2"> Enter your username: <input type="text" name="t1"><br> Enter your password: <input type="password" name="t2"><br>
  • 28. 28 <input type="submit" value="OK"> </form> </body> </html> File: Formfill.html <html> <head> <title>TODO supply a title</title> </head> <body> <form method="post" action="NewServlet1"> Enter your Name: <input type="text" name="t1"><br> Enter your age: <input type="text" name="t2"><br> Select your Degree:<br> <input type="radio" name="r1" value="B.E.,">Engineering<br> <input type="radio" name="r1" value="B.Sc.,">Science<br> <input type="radio" name="r1" value="M.B.B.S.,">Medicine<br> <input type="submit" value="OK"> </form> </body> </html> File: NewServlet1.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class NewServlet1 extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  • 29. 29 response.setContentType("text/html"); try (PrintWriter out = response.getWriter()) { String name = request.getParameter("t1"); String age= request.getParameter("t2"); String str = request.getParameter("r1"); response.setContentType("text/html"); out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet NewServlet1</title>"); out.println("</head>"); out.println("<body>"); if(name!=null) { out.println("Welcome to the website, <b>"+name+"</b><br>"); if(age!=null) out.println("Your age is "+age+"<br>"); if(str!=null) out.println("your qualification is "+str); } else out.println("Unfilled Information.."); } } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response)
  • 30. 30 throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; }// </editor-fold> } File: NewServlet2.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; @WebServlet(urlPatterns = {"/NewServlet2"}) public class NewServlet2 extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); try (PrintWriter out = response.getWriter()) { String str1 = request.getParameter("t1"); String str2 = request.getParameter("t2"); if(str1.equals("india") && (str2.equals("india")))
  • 31. 31 { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet NewServlet2</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>Logged in Successfully..." + "</h1>"); out.println("<a href=formfill.html>click here to enter personal details</a>"); out.println("</body>"); out.println("</html>"); } else { out.println("<!DOCTYPE html>"); out.println("<html>"); out.println("<head>"); out.println("<title>Servlet NewServlet2</title>"); out.println("</head>"); out.println("<body>"); out.println("Username or password is not correct"); out.println("</body>"); out.println("</html>"); } } } @Override
  • 32. 32 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } @Override public String getServletInfo() { return "Short description"; } } OUTPUT
  • 33. 33
  • 34. 34 RESULT Thus the program for authentication and personal information form filling is executed using java servlets successfully and output is verified.
  • 35. 35 EX NO:7 JAVA PROGRAM FOR APPLET-SERVLET COMMUNICATION DATE: AIM To write a java program for applet-servlet communication. ALGORITHM 1. Create a Java Application using File -> New Project -> Categories-Java, Project-Java Application. Give the Name of the Project as „MyJavaApplication‟ and then click Finish. 2. Create an applet file by right click on the MyJavaApplication project, select New-> Applet. Give the name of the applet as MyAddApplet. 3. Copy the MyAddApplet code in MyAddApplet.java file. 4. Run the Project. 5. Now we will get the Addition of two numbers applet. 6. Create a New Project by selecting File -> New Project. Give the name of the project as „MyWebApplication‟. 7. Create a jar file for our applet file by right click on the MyWebApplication project, select Properties, in the categories, select Packaging and click Add Project to add the created MyJavaApplication project in the form of jar file. After adding, the jar file will be seen in build/web folder. 8. In the MyWebApplication, index.html file, add the following code within the body section: <h1> Web Application using NetBeans IDE</h1> <applet code="MyAddApplet" archive="MyJavaApplication.jar" width="400" height="400" /> </applet> 9. Run the project. Required files to run: 1. index.html in MyWebApplication project 2. MyAddApplet.java in MyJavaApplication project 3. MyJavaApplication.jar
  • 36. 36 PROGRAM MyAddApplet.java import java.applet.*; import java.awt.*; import java.awt.event.*; public class MyAddApplet extends Applet implements ActionListener { Button b1; TextField t1,t2,t3; Label l1; public void init() { setLayout(new FlowLayout(FlowLayout.LEFT)); t1 = new TextField(); t2 = new TextField(); t3 = new TextField(); l1 = new Label("Add Two Numbers"); add(l1); add(t1); add(t2); b1=new Button("Add"); add(b1); b1.addActionListener(this); add(t3); setVisible(true); }
  • 37. 37 public void actionPerformed(ActionEvent ae) { int a,b,result; String str; if(ae.getSource()==b1) { str = t1.getText(); a = Integer.parseInt(str); str = t2.getText(); b = Integer.parseInt(str); result = a + b; t3.setText(String.valueOf(result)); } } }
  • 38. 38 OUTPUT RESULT Thus the program for applet-servlet communication is executed successfully and verified.
  • 39. 39 EX.NO:8 DATE: ONLINE SHOPPING USING JSP AIM To write an online book shopping application using JSP. ALGORITHM 1. Create an index.html file that contains the necessary books to be displayed for purchasing within the form element. Add Submit button within the form. Add the action as books.jsp for the form element. 2. Create a new jsp file named books.jsp. 3. Calculate the total cost for selected books. Display the cost of book purchase. 4. Pass the cost to sports.jsp using hidden form field included within the form element in books.jsp file. 5. Create a new jsp file named sports.jsp. 6. Calculate the total cost of purchasing the sports and books. 7. Display the total cost of purchasing. 8. Run the web application. Required programs to run: 1. index.html 2. books.jsp 3. sports.jsp PROGRAM index.html <html> <head> <title>Online shopping - Books</title> </head> <body> <form method="post" action="books.jsp"> <h3>Select the books in the following list: <br>
  • 40. 40 <select name="s1" multiple> <option value="1">Java Unleashed <option value="2">Java Server Programming <option value="3">JSP Bible <option value="4">Java Servlets </select> <br> <input type="submit" value="OK"> <br> </form> </body> </html> books.jsp <html> <head> <title>Online Shopping - Sports items</title> </head> <body> <% int cost=0; String s[] = request.getParameterValues("s1"); for(int i=0;i<s.length;i++) { if(s[i].equals("1")) cost += 200; else if(s[i].equals("2")) cost += 300; else if(s[i].equals("3")) cost += 350; else if(s[i].equals("4")) cost += 300; } %>
  • 41. 41 <h3> You have selected <%= s.length %> Books. <br> The cost is <%= cost %></h3> <form method="post" action="sports.jsp"> <input type="hidden" name="h1" value='<%=cost%>'> <br> Select the sports items: <br> <select name="s1" multiple> <option value="1">Ball <option value="2">Bat <option value="3">Carrom Board <option value="4">Chess Board </select> <br> <input type="submit" value="OK"> </form> </body></html> sports.jsp <html> <head> <title>Onlien Shopping - Final Cost </title> </head> <body> <% String s = request.getParameter("h1"); String s1[] = request.getParameterValues("s1"); int cost = Integer.parseInt(s); %> <h3> You have selected <%=s1.length%> Sport items. <br> <% for(int i=0;i<s1.length;i++) { if(s1[i].equals("1")) cost += 100; else if(s1[i].equals("2")) cost += 300; else if(s1[i].equals("3"))
  • 42. 42 cost += 1500; else if(s1[i].equals("4")) cost += 500; } %> The total cost of purchase is: <%=cost%> </h3> </body> </html> OUTPUT
  • 43. 43
  • 44. 44 RESULT Thus online shopping program is created using JSP and executed successfully. EX NO:9 DISPLAYING CRICKET PLAYERS PROFILE USING AJAX
  • 45. 45 DATE: AIM To write a program using Ajax for displaying cricket players profile. ALGORITHM 1. Create an XHTML document (AjaxDemo.html) with the following: i. Insert some images of cricket players. ii. Call the function getContent() with respect to the onmouseover event. The function accepts an argument that is the URL of another page contains the information about the player. iii. Call the function clearContent() with respect to the onmouseout event. 2. Within this XHTML document, insert AJAX based JavaScript code with the following: i. Create the object for ActiveXObject (for older versions of browsers such as IE5 and IE6). ii. Create the object for XMLHttpRequest (for modern browsers such as IE7+, Firefox, Chrome, Safari, and Opera). iii. AJAX send the request with the use of send() and open() methods. iv. The response is obtained with the use of responseText Property. v. AJAX Call the function diplayProfile() with respect to the event onreadystatechange. 3. Run the program. Required files to run: 1. Ajaxdemo.html 2. sachin.html 3. dravid.html 4. kohli.html 5. raina.html
  • 46. 46 6. yuvi.html 7. veeru.html 8. dhoni.html 9. sachin.jpg 10. dravid.jpg 11. kohli.jpg 12. raina.jpg 13. yuvi.jpg 14. veeru.jpg 15. dhoni.jpg PROGRAM Ajaxdemo.html <html> <head> <title>Ajax Demo...</title> <style type="text/css"> .box{border:1px solid blue;padding:10px} </style> <script type="text/javascript"> var req; function getContent(url) { if(window.ActiveXObject) req=new ActiveXObject("Microsoft.XMLHTTP"); else if(window.XMLHttpRequest) req=new XMLHttpRequest(); req.onreadystatechange=diplayProfile; req.open('POST',url,true);
  • 47. 47 req.send(null); } function diplayProfile() { if(req.readyState==4) document.getElementById('contentArea').innerHTML=req.responseText; } function clearContent() { document.getElementById('contentArea').innerHTML=''; } </script> </head> <body bgcolor="cyan"> <h1>Mouse over the image for More Information</h1> <img src="sachin.jpg" height="95" width="80" onmouseover='getContent("sachin.html")' onmouseout='clearContent()'/> <img src="dravid.jpg" height="95" width="80" onmouseover='getContent("dravid.html")' onmouseout='clearContent()'/> <img src="kohli.jpg" height="95" width="80" onmouseover='getContent("kohli.html")' onmouseout='clearContent()'/> <img src="raina.jpg" height="95" width="80" onmouseover='getContent("raina.html")' onmouseout='clearContent()'/> <img src="yuvi.jpg" height="95" width="80" onmouseover='getContent("yuvi.html")' onmouseout='clearContent()'/> <img src="veeru.jpg" height="95" width="80" onmouseover='getContent("veeru.html")' onmouseout='clearContent()'/> <img src="dhoni.jpg" height="95" width="80" onmouseover='getContent("dhoni.html")' onmouseout='clearContent()'/> <div class="box" id="contentArea"/> </body> </html>
  • 48. 48 sachin.html <html> <body> <b>Full name:</b> Sachin Ramesh Tendulkar<br/><br/> <b>Born:</b> April 24, 1973, Bombay (now Mumbai), Maharashtra<br/><br/> <b>Major teams:</b> India, Asia XI, Mumbai, Mumbai Indians, Yorkshire<br/><br/> <b>Nickname:</b> Tendlya, Little Master<br/><br/> <b>Playing role:</b> Top-order batsman<br/><br/> <b>Batting style:</b> Right-hand bat<br/><br/> <b>Bowling style:</b> Right-arm offbreak, Legbreak googly </body></html> dravid.html <html> <body> <b>Full name:</b> Rahul Sharad Dravid<br/><br/> <b>Born:</b> January 11, 1973, Indore, Madhya Pradesh <br/><br/> <b>Major teams:</b> India, Scotland, Asia XI, ICC World XI, Karnataka, Kent, Marylebone Cricket Club, Rajasthan Royals, Royal Challengers Bangalore<br/><br/> <b>Nickname:</b> The Wall<br/><br/> <b>Playing role:</b> Top-order batsman<br/><br/> <b>Batting style:</b> Right-hand bat<br/><br/> <b>Bowling style:</b> Right-arm offbreak </body> </html> kohli.html <html> <body> <b>Full name:</b> Virat Kohli<br/><br/> <b>Born:</b>November 5, 1988, Delhi<br/><br/> <b>Major teams:</b>India, Delhi, India Red, India Under-19s, Royal Challengers Bangalore<br/><br/> <b>Playing role:</b>Middle-order batsman<br/><br/> <b>Batting style:</b>Right-hand bat<br/><br/> <b>Bowling style:</b>Right-arm medium </body> </html>
  • 49. 49 raina.html <html> <body> <b>Full name:</b> Suresh Kumar Raina<br/><br/> <b>Born:</b>November 27, 1986, Muradnagar, Ghaziabad, Uttar Pradesh<br/><br/> <b>Major teams:</b>India, Chennai Super Kings, India Blue, India Under-19s, Indian Board President's XI, Rajasthan Cricket Association President's XI, Uttar Pradesh, Uttar Pradesh Under-16s<br/><br/> <b>Playing role:</b>Middle-order batsman<br/><br/> <b>Batting style:</b>Left-hand bat<br/><br/> <b>Bowling style:</b> Right-arm offbreak </body> </html> yuvi.html <html> <body> <b>Full name:</b>Yuvraj Singh<br/><br/> <b>Born:</b>December 12, 1981, Chandigarh<br/><br/> <b>Major teams:</b>India, Asia XI, Kings XI Punjab, Pune Warriors, Punjab, Yorkshire<br/><br/> <b>Playing role:</b>Middle-order batsman<br/><br/> <b>Batting style:</b>Left-hand bat<br/><br/> <b>Bowling style:</b>Slow left-arm orthodox </body> </html> veeru.html <html> <body> <b>Full name:</b>Virender Sehwag<br/><br/> <b>Born:</b>October 20, 1978, Delhi<br/><br/> <b>Major teams:</b>India, Asia XI, Delhi, Delhi Daredevils, ICC World XI, India Blue, Leicestershire, Rajasthan Cricket Association President's XI<br/><br/> <b>Playing role:</b>Top-order batsman<br/><br/> <b>Batting style:</b>Right-hand bat<br/><br/> <b>Bowling style:</b>Right-arm offbreak </body> </html>
  • 50. 50 dhoni.html <html> <body bgcolor="cyan"> <b>Full name:</b> Mahendra Singh Dhoni<br/><br/> <b>Born:</b>July 7, 1981, Ranchi, Bihar (now Jharkhand)<br/><br/> <b>Major teams:</b>India, Asia XI, Bihar, Chennai Super Kings, Jharkhand<br/><br/> <b>Playing role:</b>Wicketkeeper batsman<br/><br/> <b>Batting style:</b>Right-hand bat<br/><br/> <b>Bowling style:</b>Right-arm medium </body> </html> OUTPUT RESULT Thus the program of displaying cricket players information using Ajax is successfully executed and the output is verified.
  • 51. 51 EX NO:10 STUDENT RANKING DETAILS USING XML AND XSLT DATE: AIM To write the program using XML and XSLT for displaying student ranking details based on CGPA values. ALGORITHM 1.Create an XML document (stud.xml) that contains the markup tags such as <name>, <dept>, and <rno>. 2.Create an XSL document (stud.xsl) that defines the style to display an XML document. 3.Associate style sheet (XSL) with XML using the markup <?xml-stylesheet>. Add the necessary sorting markup in XSL file. 4.Load the XML document (stud.xml) in the browser. Required files to run: 1. stud.xml 2. stud.xsl PROGRAM File Name:stud.xml <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="stud.xsl"?> <studInfo> <stud> <name>Amala</name> <dept>CSE</dept> <rno>97709205001</rno> <cgpa>8.5</cgpa></stud> <stud> <name>Deepak</name> <dept>CSE</dept> <rno>97709205002</rno> <cgpa>7.8</cgpa></stud> <stud> <name>Sangeetha</name> <dept>CSE</dept> <rno>97709205003</rno> <cgpa>8.8</cgpa></stud>
  • 52. 52 <stud> <name>Usha</name> <dept>CSE</dept> <rno>97709205004</rno> <cgpa>7.5</cgpa></stud> </studInfo> stud.xsl <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <h2>Students Information</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>name</th> <th>dept</th> <th>rno</th> <th>cgpa</th> </tr> <xsl:for-each select="studInfo/stud"> <xsl:sort select="cgpa"/> <tr> <td><xsl:value-of select="name" /></td> <td><xsl:value-of select="dept"/></td> <td><xsl:value-of select="rno"/></td> <td><xsl:value-of select="cgpa"/></td> </tr> </xsl:for-each>
  • 53. 53 </table> </body> </html> </xsl:template> </xsl:stylesheet> OUTPUT RESULT Thus the program for student information is displayed with order of CGPA using XML and XSLT is successfully executed and the output is verified.
  • 54. 54 EX NO:10 PROGRAM TO ACCESS THE INFO FROM DATABASE USING JDBC DATE: CONNECTIVITY AIM To write a java program to access the information from Database using JDBC Connectivity. ALGORITHM: 1. Start the process 2. Install the JDBC Driver using forName () method 3. Create a table with required fields. 4. Create a data source using ODBC Data source in windows. 5. Establish connection to the Data source using getConnection() Method. 6. Create a statement object in the above connection object in order to send query to the table. 7. Send the query to the table using executeQuery() method. 8. Store the results in the ResultSet object. 9. Display the result on the screen. 10. Stop the process. Required files: 1. stud.mdb 2. odbctest.java PROGRAM import java.sql.*; class odbctest {
  • 55. 55 public static void main(String a[]) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection c=DriverManager.getConnection( "jdbc:odbc: students”); Statement s=c.createStatement(); ResultSet rs; String q="select * from stud"; rs=s.executeQuery(q); System.out.println("NametttBranchttClassttGrade "); System.out.println("----ttt------ tt-----tt-----"); while(rs.next()) { System.out.print(rs.getString(1)+"tt"); System.out.print(rs.getString(2)+"tt"); System.out.print(rs.getString(3)+"tt"); System.out.println(rs.getString(4)+"tt"); } }catch(Exception e) { System.out.println("Error"+e); } } }
  • 56. 56 OUTPUT RESULT Thus the database connectivity is done and the program is executed for selecting the students from students data source successfully.