internet programming lab manual

98
IT2357-WebTechnology Lab Department of IT 2012-2013 Ex No: 1 CREATE A WEB PAGE USING HTML WORLDMAP.HTML: <html> <head> <title> World Map </title> </head> <body bgcolor="black" align="center"> <center> <font face="arial" color="green"> <h1>World map</h1> </font> <a href="#"> <img src="map.jpg" ismap width="600" height="420" alt="World map" usemap="#world"> </a> <map name="world"> <area shape="rect" coords="134,80,220,126" alt="north america" href="na.htm" /> <area shape="circle" coords="188,227,23" alt="south america" href="sa.htm" /> <area shape="circle" coords="324,77,28" alt="europe" href="europe.htm" /> <area shape="circle" coords="432,87,28" alt="asia" href="asia.htm" /> <area shape="circle" coords="314,187,28" alt="africa" href="africa.htm" /> St.Joseph’s College of Engineering ISO 9001:2008

Upload: harshad-ranganathan

Post on 31-Oct-2014

855 views

Category:

Documents


3 download

DESCRIPTION

INTERNET PROGRAMMING LAB Manual

TRANSCRIPT

Page 1: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 1 CREATE A WEB PAGE USING HTML

WORLDMAP.HTML:

<html>

<head>

<title>

World Map

</title>

</head>

<body bgcolor="black" align="center">

<center>

<font face="arial" color="green">

<h1>World map</h1>

</font>

<a href="#">

<img src="map.jpg" ismap width="600" height="420" alt="World map" usemap="#world">

</a>

<map name="world">

<area shape="rect" coords="134,80,220,126" alt="north america" href="na.htm" />

<area shape="circle" coords="188,227,23" alt="south america" href="sa.htm" />

<area shape="circle" coords="324,77,28" alt="europe" href="europe.htm" />

<area shape="circle" coords="432,87,28" alt="asia" href="asia.htm" />

<area shape="circle" coords="314,187,28" alt="africa" href="africa.htm" />

<area shape="circle" coords="243,25,28" alt="Green Land" href="gl.htm" />

<area shape="circle" coords="490,280,28" alt="Australia" href="au.htm" />

</map>

</center>

</body>

</html>

AFRICA.HTML:

<html>

<head>

<title>

World Map

</title>

St.Joseph’s College of Engineering ISO 9001:2008

Page 2: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</head>

<body bgcolor="black" align="center">

<center>

<font face="arial" color="green">

<h1>Africa</h1>

<img src="africa2.gif" ismap width="600" height="420" alt="Africa"/>

<ol>

<li>Contains huge population</li>

<li>Habitat for most of the animals</li>

</ol>

</font>

</center>

</body>

</html>

ASIA.HTML:

<html>

<head>

<title>

World Map

</title>

</head>

<body bgcolor="black" align="center">

<center>

<font face="arial" color="green">

<h1>Asia</h1>

</font>

<img src="asia.png" ismap width="600" height="420" alt="Asia"/>

<ul><font color=blue>

<li> Largest Continent in the world </li>

<li> Most Populated continent </li>

<li> Contains developing countries </li>

</font>

</ul>

</center>

St.Joseph’s College of Engineering ISO 9001:2008

Page 3: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</body>

</html>

EUROPE.HTML:

<html>

<head>

<title>

Europe

</title>

</head>

<body bgcolor="yellow" align="center">

<center>

<font face="arial" color="green">

<h1>Europe</h1>

</font>

<img src="europe.jpg" width="300" height="210" alt="Europe"/>

<p><i>Europe is a nice place to live in...It is the most neatest continent in the world.... </i></p>

</center>

</body>

</html>

St.Joseph’s College of Engineering ISO 9001:2008

Page 4: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

WORLDMAP.HTML

St.Joseph’s College of Engineering ISO 9001:2008

Page 5: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

AFRICA.HTML

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 6: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 2 CASCADING STYLE SHEET

EXTERNAL.CSS:

body{ background-color: gray;}

p { color: blue; }

h3{ color: white; }

EXTERNAL.HTML:

<html>

<head>

<link rel="stylesheet" type="text/css" href="EXTERNAL.css" /><!—Link tag for External CSS-->

</head>

<body>

<h3> A White Header </h3>

<p> This paragraph has a blue font.

The background color of this page is gray because

we changed it with CSS! </p>

</body>

</html>

INTERNAL.HTML:

<html>

<head>

<style> <!—Style tag for Internal CSS-->

body { background-color: blue; }

p { color: white; }

</style>

</head>

<body>

<h2>Internal CSS</h2>

<p>This page uses internal CSS. Using the style tag we are able to modify

the appearance of HTML elements.</p>

</body>

</html>

INLINE.HTML:

St.Joseph’s College of Engineering ISO 9001:2008

Page 7: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<html>

<head>

</head>

<body>

<h2>InLINE CSS</h2>

<p style="color:sienna;margin-left:20px"><!—Style Attribute(INLINE)-->

This page uses INLINE CSS. Using the style ATTRIBUTE we are able to modify

the appearance of HTML elements.

</p>

</body>

</html>

OUTPUT:

Login:Priya

EXTERNAL.HTML:

A White Header

This paragraph has a blue font. The background color of this page is gray because we changed it with CSS!

INTERNAL.HTML:

Internal CSS

This page uses internal CSS. Using the style tag we are able to modify the appearance of HTML elements.

INLINE.HTML:

InLINE CSS

This page uses INLINE CSS. Using the style ATTRIBUTE we are able to modify the appearance of

HTML elements.

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 8: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 3 CLIENT SIDE SCRIPT VALIDATINON

VALIDATION.HTML:

<html>

<head>

<script type="text/javascript">

var fl=1;

function check()

{

var n=document.forms[0].elements[0].value;

var re=new RegExp("^[0-9]");

xyz.innerText="";

if(n.length<1)

{

xyz.innerText="invalid user name";

fl=0;

}

if(re.test(n))

{

xyz.innerText="User name should not start with a digit";

fl=0;

}

}

function check1()

{

xyz1.innerText="";

var name1=document.getElementById("pwd").value;

if(name1.length<1)

{

xyz1.innerText="Field should be filled";

fl=0;

}

St.Joseph’s College of Engineering ISO 9001:2008

Page 9: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

}

function check2()

{

xyz2.innerText="";

var name2=document.getElementById("pwd1").value;

var name1=document.getElementById("pwd").value;

if(name2.length<1)

{

xyz2.innerText="Field should be filled";

fl=0;

}

if(name1!=name2)

{

xyz2.innerText="passwords mismatched";

fl=0;

}

}

function email()

{

p1.innerText="";

var m1=document.getElementById("mail").value;

var re1=new RegExp("^[0-9]");

if(m1=="")

{

p1.innerText="please enter email id";

fl=0;

}

if(re1.test(m1))

{

p1.innerText="mail id should not start with a digit";

fl=0;

St.Joseph’s College of Engineering ISO 9001:2008

Page 10: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

}

}

function addr()

{

p2.innerText="";

var adr=document.getElementById("ad").value;

if(adr=="")

{

p2.innerText="field should be filled";

fl=0;

}

}

function showit()

{

if(fl==0)

alert("Your registration was not successful");

else

alert("your registration was successful");

}

</script>

</head>

<body bgcolor="beige" text="black">

<form method="get">

<table align="center">

<tr>

<td>

<h1 align="center"> Email Regestration</h1>

<h3 align="center"> User

Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:

<input type="text" id="uname" onBlur="check()"></h3>

</td>

<td>

St.Joseph’s College of Engineering ISO 9001:2008

Page 11: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<p id="xyz"></p>

</td>

</tr>

<tr>

<td>

<h3 align="center">

Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n

bsp;:

<input type="password" id="pwd" onBlur="check1()"></h3>

</td>

<td>

<p id="xyz1"></p>

</td>

</tr>

<tr>

<td>

<h3 align="center">Confirm password:

<input type="password" id="pwd1" onBlur="check2()"></h3>

</td>

<td>

<p id="xyz2">

</td>

</tr>

<tr>

<td>

<h3 align="center">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb

sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Email Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:

<input type="text" name="mail" onBlur="email()">&nbsp;@

<select size="1" name="mail1" tabindex="9">

St.Joseph’s College of Engineering ISO 9001:2008

Page 12: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<option value="1">gmail</option>

<option value="1">yahoo</option>

<option value="1">rediffmail</option>

<option value="1">hotmail</option>

<option value="1">msn</option></select>&nbsp;&nbsp;.

<select size="1" name="mail2" tabindex="9">

<option value="1">com</option>

<option value="1">co.in</option>

</h3>

</td>

<td>

<p id="p1"></p>

</td>

</tr>

<tr>

<td>

<br>

<h3 align="center">

Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs

p;&nbsp;&nbsp;&nbsp;:

<input type="text" name="ad" onBlur="addr()"></h3>

</td>

<td>

<p id="p2"></p>

</td>

</tr>

<tr>

<td>

<h3 align="center">

Line1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:

St.Joseph’s College of Engineering ISO 9001:2008

Page 13: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<input type="text" name="l1"></h3>

</td>

</tr>

<tr>

<td>

<h3 align="center">

Line2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:

<input type="text" name="l2"></h3>

</td>

</tr>

<tr>

<td>

<h3 align="center">

Pin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n

bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:

<input type="text" name="pin"></h3>

</td>

</tr>

</table>

<br>

<h3 align="center"><input type="submit" value="submit" onClick="showit()">

<input type="reset" value="reset">

</h3>

</form>

</body>

</html>

St.Joseph’s College of Engineering ISO 9001:2008

Page 14: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 15: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 4 JAVA APPLET TO SHOW COLOR PALETTE

PALETTE.JAVA:

/* <applet code=palette height=600 width=600>

</applet>

*/

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

public class palette extends Applet implements ActionListener,ItemListener

{

Button[] colors;

Checkbox foreground,background;

TextArea workarea;

CheckboxGroup cbg;

Panel buttonpanel,checkpanel,palettepanel;

String colour;

public void init()

{

buttonpanel=new Panel();

buttonpanel.setLayout(new GridLayout(3,3));

colors=new Button[9];

colors[0]=new Button("RED");

colors[1]=new Button("GREEN");

colors[2]=new Button("BLUE");

colors[3]=new Button("CYAN");

colors[4]=new Button("ORANGE");

colors[5]=new Button("WHITE");

colors[6]=new Button("BLACK");

colors[7]=new Button("YELLOW");

colors[8]=new Button("PINK");

for(int i=0;i<9;i++)

{

St.Joseph’s College of Engineering ISO 9001:2008

Page 16: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

colors[i].addActionListener(this);

buttonpanel.add(colors[i]);

}

checkpanel=new Panel();

checkpanel.setLayout(new FlowLayout());

cbg=new CheckboxGroup();

foreground=new Checkbox("ForeGround",cbg,true);

background=new Checkbox("BackGround",cbg,false);

foreground.addItemListener(this);

background.addItemListener(this);

checkpanel.add(foreground);

checkpanel.add(background);

workarea=new TextArea(8,40);

workarea.setFont(new Font("Garamond",Font.BOLD,20));

palettepanel=new Panel();

palettepanel.setLayout(new BorderLayout());

palettepanel.add(workarea,BorderLayout.CENTER);

palettepanel.add(checkpanel,BorderLayout.EAST);

palettepanel.add(buttonpanel,BorderLayout.SOUTH);

add(palettepanel);

}

public void itemStateChanged(ItemEvent ie)

{

}

public void actionPerformed(ActionEvent ae)

{

colour=ae.getActionCommand();

if(foreground.getState()==true)

workarea.setForeground(getColour());

if(background.getState()==true)

workarea.setBackground(getColour());

}

St.Joseph’s College of Engineering ISO 9001:2008

Page 17: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

public Color getColour()

{

Color mycolor=null;

if(colour.equals("RED"))

mycolor=Color.red;

if(colour.equals("GREEN"))

mycolor=Color.green;

if(colour.equals("BLUE"))

mycolor=Color.blue;

if(colour.equals("CYAN"))

mycolor=Color.cyan;

if(colour.equals("ORANGE"))

mycolor=Color.orange;

if(colour.equals("WHITE"))

mycolor=Color.white;

if(colour.equals("BLACK"))

mycolor=Color.black;

if(colour.equals("YELLOW"))

mycolor=Color.yellow;

if(colour.equals("PINK"))

mycolor=Color.pink;

return mycolor;

}

}

St.Joseph’s College of Engineering ISO 9001:2008

Page 18: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

c:\jdk1.6\bin>javac palette.java

c:\jdk1.6\bin>appletviewer palette.java

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 19: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 5A PROGRAMS TO INVOKE SERVLETS FROM HTML FORMS

INDEX.JSP:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<FORM action ="Servlet2" method="get">

USERNAME:<input type="text" name="user"/>

PASSWORD:<input type="password" name="pass"/>

<INPUT TYPE="SUBMIT" VALUE="SUBMIT"/>

</FORM>

</body>

</html>

SERVLET2.JAVA:

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

/**

*

* @author Administrator

*/

@WebServlet(name="Servlet2", urlPatterns={"/Servlet2"})

public class Servlet2 extends HttpServlet {

/**

* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.

* @param request servlet request

* @param response servlet response

St.Joseph’s College of Engineering ISO 9001:2008

Page 20: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

* @throws ServletException if a servlet-specific error occurs

* @throws IOException if an I/O error occurs

*/

@Override

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/html;charset=UTF-8");

PrintWriter out = response.getWriter();

String u=request.getParameter("user");

String p=request.getParameter("pass");

System.out.println("USER IS"+u);

System.out.println("PASS IS"+p);

if(u.equals("User1")&&p.equals("pass"))

{

out.println("<html>");

out.println("<head>");

out.println("<title>Servlet</title>");

out.println("</head>");

out.println("<body>");

out.println("<h1>WELCOME :" + u + "</h1>");

/*out.println("<h1>PASSWORD IS " + p + "</h1>");*/

out.println("</body>");

out.println("</html>");

}

else

{

out.println("<html>");

out.println("<head>");

out.println("<title>Servlet</title>");

out.println("</head>");

out.println("<body>");

out.println("<h1>" + u + " is not a valid user</h1>");

St.Joseph’s College of Engineering ISO 9001:2008

Page 21: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

out.println("</body>");

out.println("</html>");

}

}

}

OUTPUT:

Login: Priya

St.Joseph’s College of Engineering ISO 9001:2008

Page 22: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 23: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 5B PROGRAMS TO INVOKE SERVLETS FROM APPLETS

PROGRAM:

INDEX.HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">

<html>

<head>

<title>EchoApplet</title>

</head>

<body>

<applet code="EchoApplet.class" width="500" height="200"></applet>

</body>

</html>

WEB.XML:

<!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>

<!-- General description of your web application -->

<display-name>Echo Servlet</display-name>

<description>

Echo Servlet

</description>

<!-- define servlets and mapping -->

<servlet>

<servlet-name>echo</servlet-name>

<servlet-class>EchoServlet</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>echo</servlet-name>

<url-pattern>/echo</url-pattern>

</servlet-mapping>

</web-app>

St.Joseph’s College of Engineering ISO 9001:2008

Page 24: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

ECHOAPPLET.JAVA:

import java.applet.Applet;

import java.awt.*;

import java.awt.event.*;

import java.io.*;

import java.net.*;

/**

* Simple demonstration for an Applet <-> Servlet communication.

*/

public class EchoApplet extends Applet {

private TextField inputField = new TextField();

private TextField outputField = new TextField();

private TextArea exceptionArea = new TextArea();

/**

* Setup the GUI.

*/

public void init() {

// set new layout

setLayout(new GridBagLayout());

// add title

Label title = new Label("Echo Applet", Label.CENTER);

title.setFont(new Font("SansSerif", Font.BOLD, 14));

GridBagConstraints c = new GridBagConstraints();

c.gridwidth = GridBagConstraints.REMAINDER;

c.weightx = 1.0;

c.fill = GridBagConstraints.HORIZONTAL;

c.insets = new Insets(5, 5, 5, 5);

add(title, c);

St.Joseph’s College of Engineering ISO 9001:2008

Page 25: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

// add input label, field and send button

c = new GridBagConstraints();

c.anchor = GridBagConstraints.EAST;

add(new Label("Input:", Label.RIGHT), c);

c = new GridBagConstraints();

c.fill = GridBagConstraints.HORIZONTAL;

c.weightx = 1.0;

add(inputField, c);

Button sendButton = new Button("Send");

c = new GridBagConstraints();

c.gridwidth = GridBagConstraints.REMAINDER;

add(sendButton, c);

sendButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent e) {

onSendData();

}

});

// add output label and non-editable field

c = new GridBagConstraints();

c.anchor = GridBagConstraints.EAST;

add(new Label("Output:", Label.RIGHT), c);

c = new GridBagConstraints();

c.gridwidth = GridBagConstraints.REMAINDER;

c.fill = GridBagConstraints.HORIZONTAL;

c.weightx = 1.0;

add(outputField, c);

outputField.setEditable(false);

// add exception label and non-editable textarea

c = new GridBagConstraints();

c.anchor = GridBagConstraints.EAST;

St.Joseph’s College of Engineering ISO 9001:2008

Page 26: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

add(new Label("Exception:", Label.RIGHT), c);

c = new GridBagConstraints();

c.gridwidth = GridBagConstraints.REMAINDER;

c.weighty = 1;

c.fill = GridBagConstraints.BOTH;

add(exceptionArea, c);

exceptionArea.setEditable(false);

}

/**

* Get a connection to the servlet.

*/

private URLConnection getServletConnection()

throws MalformedURLException, IOException {

// Connection zum Servlet öffnen

URL urlServlet = new URL(getCodeBase(), "echo");

URLConnection con = urlServlet.openConnection();

// konfigurieren

con.setDoInput(true);

con.setDoOutput(true);

con.setUseCaches(false);

con.setRequestProperty(

"Content-Type",

"application/x-java-serialized-object");

// und zurückliefern

return con;

}

/**

St.Joseph’s College of Engineering ISO 9001:2008

Page 27: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

* Send the inputField data to the servlet and show the result in the outputField.

*/

private void onSendData() {

try {

// get input data for sending

String input = inputField.getText();

// send data to the servlet

URLConnection con = getServletConnection();

OutputStream outstream = con.getOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(outstream);

oos.writeObject(input);

oos.flush();

oos.close();

// receive result from servlet

InputStream instr = con.getInputStream();

ObjectInputStream inputFromServlet = new ObjectInputStream(instr);

String result = (String) inputFromServlet.readObject();

inputFromServlet.close();

instr.close();

// show result

outputField.setText(result);

} catch (Exception ex) {

ex.printStackTrace();

exceptionArea.setText(ex.toString());

}

}

}

St.Joseph’s College of Engineering ISO 9001:2008

Page 28: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

ECHOSERVLET.JAVA:

import java.io.*;

import javax.servlet.ServletException;

import javax.servlet.http.*;

/**

* Simple demonstration for an Applet <-> Servlet communication.

*/

public class EchoServlet extends HttpServlet {

/**

* Get a String-object from the applet and send it back.

*/

public void doPost(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

try {

response.setContentType("application/x-java-serialized-object");

// read a String-object from applet

// instead of a String-object, you can transmit any object, which

// is known to the servlet and to the applet

InputStream in = request.getInputStream();

ObjectInputStream inputFromApplet = new ObjectInputStream(in);

String echo = (String) inputFromApplet.readObject();

// echo it to the applet

OutputStream outstr = response.getOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(outstr);

oos.writeObject(echo);

oos.flush();

oos.close();

} catch (Exception e) {

e.printStackTrace();

St.Joseph’s College of Engineering ISO 9001:2008

Page 29: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

}

}

}

OUTPUT:Login: Priya

St.Joseph’s College of Engineering ISO 9001:2008

Page 30: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 6A THREE-TIER APPLICATIONS USING JSP AND DATABASES FOR

CONDUCTING ON-LINE EXAMINATION

INDEX.JSP:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head><title>Database Test</title></head>

<body>

<center>

<h1>Online Examination</h1>

</center>

<form action="Servlet_tier1" method="POST">

<!—SERVLET NAME IN ACTION ATTRIBUTE -->

<div align="left"><br></div>

<b>Seat Number:</b> <input type="text" name="Seat_no">

<div align="Right">

<b>Name:</b> <input type="text" name="Name" size="50"><br>

</div>

<br><br>

<b>1. Every host implements transport layer.</b><br/>

<input type="radio" name="group1" value="True">True

<input type="radio" name="group1" value="False">False<br>

<b>2. It is a network layer's responsibility to forward packets reliably from source to

destination</b><br/>

<input type="radio" name="group2" value="True">True

<input type="radio" name="group2" value="False">False<br>

<b>3. Packet switching is more useful in bursty traffic</b><br/>

<input type="radio" name="group3" value="True">True

<input type="radio" name="group3" value="False">False<br>

St.Joseph’s College of Engineering ISO 9001:2008

Page 31: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<b>4. A phone network uses packet switching</b><br/>

<input type="radio" name="group4" value="True">True

<input type="radio" name="group4" value="False">False<br>

<b>5. HTML1 is a Protocol for describing web contents</b><br/>

<input type="radio" name="group5" value="True">True

<input type="radio" name="group5" value="False">False<br>

<br><br><br>

<center>

<input type="submit" value="Submit"><br><br>

</center>

</form>

</body>

</html>

SERVLET_TIER1.JAVA:

import java.io.*;

import java.sql.*;

import javax.servlet.*;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.*;

@WebServlet(name="Servlet_tier1", urlPatterns={"/Servlet_tier1"})

public class Servlet_tier1 extends HttpServlet

{

String message,Seat_no,Name,ans1,ans2,ans3,ans4,ans5;

int Total=0;

java.sql.Connection connect;

java.sql.Statement stmt=null;

java.sql.ResultSet rs=null;

@Override

public void doPost(HttpServletRequest request,HttpServletResponse response) throws

ServletException,IOException

{

try

St.Joseph’s College of Engineering ISO 9001:2008

Page 32: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

{

String url="jdbc:odbc:NEO";//DATASOURCENAME NEO

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

connect=DriverManager.getConnection(url,"","");

message="Thank you for participating in online Exam";

}

catch(ClassNotFoundException cnfex){

cnfex.printStackTrace();

}

catch(SQLException sqlex){

sqlex.printStackTrace();

}

catch(Exception excp){

excp.printStackTrace();

}

Seat_no=request.getParameter("Seat_no");

Name=request.getParameter("Name");

ans1=request.getParameter("group1");

ans2=request.getParameter("group2");

ans3=request.getParameter("group3");

ans4=request.getParameter("group4");

ans5=request.getParameter("group5");

if(ans1.equals("True"))

Total+=2;

if(ans2.equals("False"))

Total+=2;

if(ans3.equals("True"))

Total+=2;

if(ans4.equals("False"))

Total+=2;

if(ans5.equals("False"))

Total+=2;

try

St.Joseph’s College of Engineering ISO 9001:2008

Page 33: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

{

stmt=connect.createStatement();

String query="INSERT INTO student("+"Seat_no,Name,Total"+")

VALUES('"+Seat_no+"','"+Name+"','"+Total+"')";//student-Table Name

stmt.executeUpdate(query);

stmt.close();

}catch(SQLException ex){

}

response.setContentType("text/html");

PrintWriter out=response.getWriter();

out.println("<html>");

out.println("<head>");

out.println("</head>");

out.println("<body bgcolor=cyan>");

out.println("<center>");

out.println("<h1>"+message+"</h1>\n");

out.println("<h3>Yours results stored in our database</h3>");

out.print("<br><br>");

out.println("<b>"+"Participants and their Marks"+"</b>");

out.println("<table border=5>");

try

{

java.sql.Statement stmt2=connect.createStatement();

String query="SELECT * FROM student";

rs=stmt2.executeQuery(query);

out.println("<th>"+"Seat_no"+"</th>");

out.println("<th>"+"Name"+"</th>");

out.println("<th>"+"Marks"+"</th>");

while(rs.next())

{

out.println("<tr>");

out.print("<td>"+rs.getString(1)+"</td>");

out.print("<td>"+rs.getString(2)+"</td>");

out.print("<td>"+rs.getString(3)+"</td>");

St.Joseph’s College of Engineering ISO 9001:2008

Page 34: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

out.println("</tr>");

}

out.println("</table>");

}

catch(SQLException ex){ }

finally

{

try

{

if(rs!=null)

rs.close();

if(stmt!=null)

stmt.close();

if(connect!=null)

connect.close();

}

catch(SQLException e){ }

}

out.println("</center>");

out.println("</body></html>");

Total=0;

} }

TABLE CREATION IN MICROSOFT ACCESS:

St.Joseph’s College of Engineering ISO 9001:2008

Page 35: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 36: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 6B THREE-TIER APPLICATIONS USING JSP AND DATABASES FOR

CONDUCTING FOR DISPLAYING STUDENT MARK LIST

INDEX.JSP:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head><title> mark sheet</title></head>

<body>

<center>

<h1>Student Mark Sheet</h1>

</center>

<form action="serv" method="POST">

registration number:<input type="text" name="regno">

<input type="submit" value="Submit"><br><br>

</form>

</body>

</html>

SERV.JAVA:

import java.io.IOException;

import java.io.PrintWriter;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.servlet.ServletException;

import javax.servlet.annotation.WebServlet;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

St.Joseph’s College of Engineering ISO 9001:2008

Page 37: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

/**

*

* @author Priya

*/

@WebServlet(name="serv", urlPatterns={"/serv"})

public class serv extends HttpServlet

{

String message,Reg_no;

Connection connect;

Statement stmt=null;

ResultSet rs=null;

@Override

public void doPost(HttpServletRequest request,HttpServletResponse response) throws

ServletException,IOException

{

try

{

String url="jdbc:odbc:NEO1";//DATASOURCENAME NEO1

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

connect=DriverManager.getConnection(url,"","");

message="Mark List";

}

catch(ClassNotFoundException cnfex){

}

catch(SQLException sqlex){

}

catch(Exception excp){

}

Reg_no=request.getParameter("regno");

response.setContentType("text/html");

PrintWriter out=response.getWriter();

out.println("<html>");

out.println("<head>");

St.Joseph’s College of Engineering ISO 9001:2008

Page 38: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

out.println("</head>");

out.println("<body bgcolor=cyan>");

out.println("<center>");

out.println("<h1>"+message+"</h1>\n");

try

{

stmt = connect.createStatement();

String query="SELECT * FROM Marklist WHERE regno= " + Reg_no;// Marklist-Table Name

rs=stmt.executeQuery(query);

boolean b=rs.next();

out.println("Regsitration No:"+rs.getInt(1));

out.println("<br>"+"Name:"+rs.getString(2));

out.println("<table border=5>");

out.println("<th>"+"cs01"+"</th>");

out.println("<th>"+"cs02 "+"</th>");

out.println("<th>"+"cs03"+"</th>");

out.println("<th>"+"status"+"</th>");

while(b)

{

out.println("<tr>");

out.print("<td>"+rs.getString(3)+"</td>");

out.print("<td>"+rs.getString(4)+"</td>");

out.print("<td>"+rs.getString(5)+"</td>");

out.print("<td>"+rs.getString(6)+"</td>");

out.println("</tr>");

b=rs.next();

}

out.println("</table>");

}

catch(SQLException ex){

out.println("error in connection");

}

finally

St.Joseph’s College of Engineering ISO 9001:2008

Page 39: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

{

try

{

if(rs!=null)

rs.close();

if(stmt!=null)

stmt.close();

if(connect!=null)

connect.close();

}

catch(SQLException e){ }

}

out.println("</center>");

out.println("</body></html>");

}

}

TABLE CREATION IN MICROSOFT ACCESS:

St.Joseph’s College of Engineering ISO 9001:2008

Page 40: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 41: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 7A XML-SCHEMA FOR AN ADDRESS BOOK

SCHEMA.XSD:

<?xml version="1.0" encoding="UTF-8"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="addr">

<xs:complexType>

<xs:sequence>

<xs:element name="book1">

<xs:complexType>

<xs:sequence>

<xs:element name="name">

<xs:complexType>

<xs:sequence>

<xs:element name="fname" type="xs:string" />

<xs:element name="lname" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="gender" type="xs:string" />

<xs:element name="dob" type="xs:string" />

<xs:element name="phone" type="xs:string" />

<xs:element name="contact">

<xs:complexType>

<xs:sequence>

<xs:element name="dno" type="xs:string" />

<xs:element name="street" type="xs:string" />

<xs:element name="city" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

St.Joseph’s College of Engineering ISO 9001:2008

Page 42: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<xs:element name="book2">

<xs:complexType>

<xs:sequence>

<xs:element name="name">

<xs:complexType>

<xs:sequence>

<xs:element name="fname" type="xs:string" />

<xs:element name="lname" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="gender" type="xs:string" />

<xs:element name="dob" type="xs:string" />

<xs:element name="phone" type="xs:string" />

<xs:element name="contact">

<xs:complexType>

<xs:sequence>

<xs:element name="dno" type="xs:string" />

<xs:element name="street" type="xs:string" />

<xs:element name="city" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="book3">

<xs:complexType>

<xs:sequence>

<xs:element name="name">

<xs:complexType>

<xs:sequence>

<xs:element name="fname" type="xs:string" />

St.Joseph’s College of Engineering ISO 9001:2008

Page 43: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<xs:element name="lname" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="gender" type="xs:string" />

<xs:element name="dob" type="xs:string" />

<xs:element name="phone" type="xs:string" />

<xs:element name="contact">

<xs:complexType>

<xs:sequence>

<xs:element name="dno" type="xs:string" />

<xs:element name="street" type="xs:string" />

<xs:element name="city" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="book4">

<xs:complexType>

<xs:sequence>

<xs:element name="name">

<xs:complexType>

<xs:sequence>

<xs:element name="fname" type="xs:string" />

<xs:element name="lname" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="gender" type="xs:string" />

<xs:element name="dob" type="xs:string" />

<xs:element name="phone" type="xs:string" />

St.Joseph’s College of Engineering ISO 9001:2008

Page 44: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<xs:element name="contact">

<xs:complexType>

<xs:sequence>

<xs:element name="dno" type="xs:string" />

<xs:element name="street" type="xs:string" />

<xs:element name="city" type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

St.Joseph’s College of Engineering ISO 9001:2008

Page 45: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 7B XML DOCUMENT TO STORE AN ADDRESS BOOK.

ADDRESS.XML:

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="address.xsl"?>

<addr>

<book>

<sr>1</sr>

<name>

<fname>KARTHIK</fname>

<lname>BASKARAN</lname>

</name>

<gender>MALE</gender>

<dob>08-05-1991</dob>

<phone>9176232480</phone>

<contact>

<dno>143</dno>

<street>St.Joseph's Boys Hostel</street>

<city>Chennai</city>

</contact>

</book>

<book>

<sr>2</sr>

<name>

<fname>XXX</fname>

<lname>YYY</lname>

</name>

<gender>ZZZ</gender>

<dob>00-00-0000</dob>

<phone>9876543210</phone>

<contact>

<dno>1</dno>

<street>Rich Street</street>

<city>Chennai</city>

</contact>

St.Joseph’s College of Engineering ISO 9001:2008

Page 46: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</book>

<book>

<sr>3</sr>

<name>

<fname>Rajathi</fname>

<lname>Raja</lname>

</name>

<gender>Male</gender>

<dob>1-1-2000</dob>

<phone>123456789</phone>

<contact>

<dno>6</dno>

<street>Vivekananda Street</street>

<city>Dubai</city>

</contact>

</book>

<book>

<sr>4</sr>

<name>

<fname>Mahalakshmi</fname>

<lname>Kumaran</lname>

</name>

<gender>Male</gender>

<dob>31-12-1990</dob>

<phone>4444444444</phone>

<contact>

<dno>7G</dno>

<street>Rainbow Colony</street>

<city>Kovilpatti</city>

</contact>

</book>

<book>

<sr>5</sr>

<name>

St.Joseph’s College of Engineering ISO 9001:2008

Page 47: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<fname>Kishore</fname>

<lname>Kumar</lname>

</name>

<gender>Male</gender>

<dob>05-05-2005</dob>

<phone>3333333333</phone>

<contact>

<dno>99</dno>

<street>Velachery Road</street>

<city>Medavakkam</city>

</contact>

</book>

<book>

<sr>6</sr>

<name>

<fname>Kalai</fname>

<lname>Prabakaran</lname>

</name>

<gender>Male</gender>

<dob>17-12-1990</dob>

<phone>988487817</phone>

<contact>

<dno>1</dno>

<street>V.M. Nagar</street>

<city>Avadi</city>

</contact>

</book>

<book>

<sr>7</sr>

<name>

<fname>Jones</fname>

<lname>Jebaraj</lname>

</name>

<gender>Male</gender>

St.Joseph’s College of Engineering ISO 9001:2008

Page 48: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<dob>5-5-2005</dob>

<phone>9999999999</phone>

<contact>

<dno>147</dno>

<street>St.Joseph's Boys Hostel</street>

<city>Chennai</city>

</contact>

</book>

<book>

<sr>8</sr>

<name>

<fname>Johny</fname>

<lname>Sebastin</lname>

</name>

<gender>Male</gender>

<dob>11-09-1990</dob>

<phone>9566306560</phone>

<contact>

<dno>142</dno>

<street>St.Joseph's Boys Hostel</street>

<city>Chennai</city>

</contact>

</book>

<book>

<sr>9</sr>

<name>

<fname>Meera</fname>

<lname>Mohidden</lname>

</name>

<gender>Male</gender>

<dob>01-01-2000</dob>

<phone>111111</phone>

<contact>

<dno>420</dno>

St.Joseph’s College of Engineering ISO 9001:2008

Page 49: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<street>Moolakadai</street>

<city>Chennai</city>

</contact>

</book>

<book>

<sr>10</sr>

<name>

<fname>Mohamed</fname>

<lname>Abdulla</lname>

</name>

<gender>Male</gender>

<dob>07-08-1990</dob>

<phone>2626262626</phone>

<contact>

<dno>143</dno>

<street>St.Joseph's Boys Hostel</street>

<city>Chennai</city>

</contact>

</book>

</addr>

St.Joseph’s College of Engineering ISO 9001:2008

Page 50: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 7C XSLT PROGRAM TO EXTRACT XML DOCUMENT DETAILS AND

FORMATTING

ADDRESS.XSL:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<html>

<body bgcolor="gray">

<h1><center>ADDRESS BOOK</center></h1>

<table border="3" color="green">

<thead>

<tr bgcolor="red">

<th align="center">S.No</th>

<th align="center">First Name</th>

<th align="center">Last Name</th>

<th align="center">D.O.B</th>

<th align="center">Phone</th>

<th align="center">Dno</th>

<th align="center">Street</th>

<th align="center">City</th>

</tr>

</thead>

<xsl:for-each select="/addr/book">

<tr bgcolor="white">

<td align="center"><xsl:value-of select="sr" /></td>

<td align="center"><xsl:value-of select="name/fname" /></td>

<td align="center"><xsl:value-of select="name/lname" /></td>

<td align="center"><xsl:value-of select="dob" /></td>

<td align="center"><xsl:value-of select="phone" /></td>

<td align="center"><xsl:value-of select="contact/dno" /></td>

<td align="center"><xsl:value-of select="contact/street" /></td>

<td align="center"><xsl:value-of select="contact/city" /></td>

</tr>

St.Joseph’s College of Engineering ISO 9001:2008

Page 51: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</xsl:for-each>

</table>

</body>

</html>

</xsl:template>

</xsl:stylesheet>

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 52: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 8 PROGRAM USING DOM

BOOK.XML:

<?xml version="1.0" encoding="ISO-8859-1"?>

<books>

<book>

<name>Web Technology</name>

<author>Jeffrey C Jackson</author>

<publisher>Pearson</publisher>

<edition>7</edition>

<pageno>1000</pageno>

<price>500</price>

</book>

<book>

<name>C Programming</name>

<author>Balagurusamy</author>

<publisher>Tata Mc Graw Hill</publisher>

<edition>5</edition>

<pageno>750</pageno>

<price>400</price>

</book>

<book>

<name>Java - The Complete Reference</name>

<author>Herbert Schildtz</author>

<publisher>Tata Mc-Graw Hill</publisher>

<edition>4</edition>

<pageno>2500</pageno>

<price>1000</price>

</book>

<book>

<name>Cryptography</name>

<author>Willian Stalling</author>

<publisher>Pearson</publisher>

<edition>3</edition>

<pageno>400</pageno>

St.Joseph’s College of Engineering ISO 9001:2008

Page 53: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<price>400</price>

</book>

<book>

<name>C++ Programming</name>

<author>Balagurusamy </author>

<publisher>Tata Mc-Graw Hill</publisher>

<edition>5</edition>

<pageno>800</pageno>

<price>400</price>

</book>

<book>

<name>DataBase Management System</name>

<author>Shilberschetz</author>

<publisher>Tata Mc-Graw Hill</publisher>

<edition>7</edition>

<pageno>1200</pageno>

<price>800</price>

</book>

<book>

<name>Computer Networks </name>

<author>Feroutzha+</author>

<publisher>Pearson</publisher>

<edition>5</edition>

<pageno>500</pageno>

<price>300</price>

</book>

<book>

<name>Fundamentals of Computing </name>

<author>Ramesh Babu</author>

<publisher>Prentice - Hall</publisher>

<edition>5</edition>

<pageno>500</pageno>

<price>400</price>

</book>

St.Joseph’s College of Engineering ISO 9001:2008

Page 54: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

<book>

<name>Operating System </name>

<author>Shilberschetz</author>

<publisher>Tata Mc-Graw Hill</publisher>

<edition>5</edition>

<pageno>1000</pageno>

<price>500</price>

</book>

<book>

<name>Data Structures</name>

<author>Balagurusamy</author>

<publisher>Pearson</publisher>

<edition>5</edition>

<pageno>500</pageno>

<price>300</price>

</book>

</books>

BOOK.HTML:

<html>

<head>

<title>

Book Shop

</title>

<script language="JavaScript" for="window" event="onload">

Document=dsobook.XMLDocument;

name.innerText=Document.documentElement.childNodes(0).text;

author.innerText=Document.documentElement.childNodes(0).text;

publisher.innerText=Document.documentElement.childNodes(0).text;

edition.innerText=Document.documentElement.childNodes(0).text;

pageno.innerText=Document.documentElement.childNodes(0).text;

price.innerText=Document.documentElement.childNodes(0).text;

</script>

St.Joseph’s College of Engineering ISO 9001:2008

Page 55: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</head>

<body>

<xml id="dsoBook" src="book.xml"></xml>

<h2> Book Description </h2>

<table datasrc="#dsoBook" datfld="books" border="3" cellpadding="3">

<thead>

<th> Title </th>

<th> Author </th>

<th> Publisher </th>

<th> Edition </th>

<th> Pages </th>

<th> Price </th>

</thead>

<tr align="center">

<td><span datafld="name"></span></td>

<td><span datafld="author"></span></td>

<td><span datafld="publisher"></span></td>

<td><span datafld="edition"></span></td>

<td><span datafld="pageno"></span></td>

<td><span datafld="price"></span></td>

</tr>

</table>

</body>

</html>

St.Joseph’s College of Engineering ISO 9001:2008

Page 56: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 57: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 9 PROGRAMS USING AJAX

PROGRAM:

INDEX.JSP:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title>Ajax Example</title>

<script language="Javascript">

function postRequest(strURL) {

var xmlHttp;

if (window.XMLHttpRequest) { // Mozilla, Safari, ...

var xmlHttp = new XMLHttpRequest();

} else if (window.ActiveXObject) { // IE

var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

}

xmlHttp.open('POST', strURL, true);

xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

xmlHttp.onreadystatechange = function() {

if (xmlHttp.readyState == 4) {

updatepage(xmlHttp.responseText);

}

}

xmlHttp.send(strURL);

}

function updatepage(str){

document.getElementById("result").innerHTML =

"<font color='red' size='5'>" + str + "</font>";;

}

function showCurrentTime(){

var rnd = Math.random();

St.Joseph’s College of Engineering ISO 9001:2008

Page 58: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

var url="process.jsp";

postRequest(url);

}

</script>

</head>

<body>

<h1 align="center"><font color="#000080">Ajax Example</font></h1>

<p><font color="#000080">&nbsp;This very simple Ajax Example retrieves the

current date and time from server and shows on the form. To view the current

date and time click on the following button.</font></p>

<form name="f1">

<p align="center"><font color="#000080">&nbsp;<input value=" Show Time "

type="button" onclick='JavaScript:showCurrentTime()' name="showdate"></font></p>

<div id="result" align="center"></div>

</form>

<div id=result></div>

</body>

</html>

PROCESS.JSP:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*" %>

<%

out.println(new Date());

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>JSP Page</title>

</head>

<body>

<h1>Hello World!</h1>

</body>

St.Joseph’s College of Engineering ISO 9001:2008

Page 59: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</html>

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 60: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 10 IMAGE SLIDE SHOW

SLIDE.JAVA:

import java.applet.*;

import java.awt.*;

public class slide extends Applet

{

private Image image;

String disp=null;

String name="img";

public void paint(Graphics g)

{

for(int i=1;i<=3;i++)

{

disp=name+i+".jpg";

image=getImage(getCodeBase(),disp);

g.drawImage(image,0,0,50,50,this);

try{

Thread.sleep(200);

}

catch(Exception e)

{

}

g.clearRect(0,0,500,500);

if(i==3)

i=1;}}}

/*

<applet code="slide" width=300 height=400>

</applet>

*/

St.Joseph’s College of Engineering ISO 9001:2008

Page 61: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

OUTPUT:

Login: Priya

C:\Program Files\Java\jdk1.6.0_23\bin>javac slide.java

C:\Program Files\Java\jdk1.6.0_23\bin>appletviewer slide.java

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 62: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 11 MOUSE AND KEYBOARD EVENTS

Keyboard2.java

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.util.Vector;

public class Keyboard2 extends Applet

implements KeyListener, MouseListener, MouseMotionListener {

int width, height;

int N = 25;

Color[] spectrum;

Vector listOfPositions;

String s = "";

int skip = 0;

public void init() {

width = getSize().width;

height = getSize().height;

setBackground( Color.black );

spectrum = new Color[ N ];

for ( int i = 0; i < N; ++i ) {

spectrum[i] = new Color( Color.HSBtoRGB(i/(float)N,1,1) );

}

listOfPositions = new Vector();

addKeyListener( this );

addMouseListener( this );

addMouseMotionListener( this );

}

public void keyPressed( KeyEvent e ) { }

public void keyReleased( KeyEvent e ) { }

public void keyTyped( KeyEvent e ) {

char c = e.getKeyChar();

St.Joseph’s College of Engineering ISO 9001:2008

Page 63: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

if ( c != KeyEvent.CHAR_UNDEFINED ) {

s = s + c;

repaint();

e.consume();

}

}

public void mouseEntered( MouseEvent e ) { }

public void mouseExited( MouseEvent e ) { }

public void mouseClicked( MouseEvent e ) {

s = "";

repaint();

e.consume();

}

public void mousePressed( MouseEvent e ) { }

public void mouseReleased( MouseEvent e ) { }

public void mouseMoved( MouseEvent e ) {

// only process every 5th mouse event

if ( skip > 0 ) {

-- skip; // this is shorthand for "skip = skip-1;"

return;

}

else skip = 5;

if ( listOfPositions.size() >= N ) {

// delete the first element in the list

listOfPositions.removeElementAt( 0 );

}

// add the new position to the end of the list

listOfPositions.addElement( new Point( e.getX(), e.getY() ) );

repaint();

e.consume();

}

public void mouseDragged( MouseEvent e ) { }

public void paint( Graphics g ) {

if ( s != "" ) {

St.Joseph’s College of Engineering ISO 9001:2008

Page 64: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

for ( int j = 0; j < listOfPositions.size(); ++j ) {

g.setColor( spectrum[ j ] );

Point p = (Point)(listOfPositions.elementAt(j));

g.drawString( s, p.x, p.y );

}

}

}

}

OUTPUT:

Login: Priya

C:\Program Files\Java\jdk1.6.0_11\bin>javac Keyboard2.java

Note: Keyboard2.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

C:\Program Files\Java\jdk1.6.0_11\bin>appletviewer Keyboard2.java

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 65: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Ex No: 12 MINI PROJECT

Implementing an application with web services

PROGRAM: <?xml version = "1.0"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Solution11.16 -->

<!-- Airline Reservation System-->

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>

<title>Airline Reservation System</title>

<script type = "text/javascript">

var input;

var secondInput;

var element;

var secondElement;

var firstCount = 0;

var economyCount = 0;

var seats = [ ,0,0,0,0,0,0,0,0,0,0]; //allocate 10-element Array

function startArray()

{

for(var i=0; i<11; i++)

{

input = window.prompt("Please type 1 for First Class and Please type 2 for Economy.","0");

if (input == 1 || input == 2)

{

element = linearSearch(seats);

if (element==-1 && input == 1)

{

document.writeln("The First Class is already fully booked<br/>");

secondQuestion(seats);

}

else if (element ==-1 && input == 2)

{

St.Joseph’s College of Engineering ISO 9001:2008

Page 66: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

document.writeln("The Economy Class is already fully booked<br/>");

secondQuestion(seats);

}

else

boardingPass(input);

}

//to terminate the program

else

{

window.status = "Bye-bye!";

System.exit(0);

}

}

}

function linearSearch(theArray)

{

if (input == 1)

{

for (var n=0; n<6 ; n++)

if (theArray [n] == 0)

return n;

}

else if (input == 2)

{

for (var n=6; n<11 ; n++)

if (theArray [n] == 0)

return n;

}

return -1;

}

function boardingPass(theInput)

{

if (input ==1)

{

St.Joseph’s College of Engineering ISO 9001:2008

Page 67: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

document.writeln("----------BOARDING PASS----------<br/>");

document.writeln("You are allocated in the First Class<br/>");

document.writeln("Your seat number is "+ element+"<br/>");

document.writeln("-----------------------------------------<br/>");

seats[element]= 1;

firstCount++;

}

else if (input ==2)

{

document.writeln("----------BOARDING PASS----------<br/>");

document.writeln("You are allocated in the Economy Class<br/>");

document.writeln("Your seat number is "+ element +"<br/>");

document.writeln("-----------------------------------------<br/>");

seats[element]= 1;

economyCount++;

}

}

function secondQuestion(theArray)

{

if (input == 1)

{

for (var n=6; n<11 ;n++)

{

if (theArray [n] == 0)

{

secondInput = window.prompt("Do you want to move to Economy Class? (If YES, please press 1. If NO,

please press 2)","0");

if ( secondInput == 1)

{

input = 2;

element=linearSearch(seats);

document.writeln("You have been allocated to Economy Class<br/>");

boardingPass(input);

break;

St.Joseph’s College of Engineering ISO 9001:2008

Page 68: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

}

else if (secondInput == 2)

{

document.writeln("Next flight leaves in 3 hours<br/>");

break;

}

}

}

}

else if (input == 2)

{

for (var n=0; n<6 ;n++)

{

if (theArray [n] == 0)

{

secondInput = window.prompt("Do you want to move to First Class? (If YES, please press 1. If NO, please

press 2)","0");

if ( secondInput == 1)

{

input = 1;

element=linearSearch(seats);

document.writeln("You have been allocated to First Class<br/>");

boardingPass(input);

break;

}

else if (secondInput == 2)

{

document.writeln("Next flight leaves in 3 hours<br/>");

break;

}

}

}

}

}

St.Joseph’s College of Engineering ISO 9001:2008

Page 69: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

</script>

</head>

<body onload = "startArray()"></body>

</html>

OUTPUT:

Login: Priya

Result:

St.Joseph’s College of Engineering ISO 9001:2008

Page 70: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Viva Questions

1.what is xsl? XSL refers to EXtensible Stylesheet Language, and is a style sheet language for XML documents.2. XPath is a language for navigating in XML documents.3.XSLT uses XPath to find information in an XML document.4.An XSL style sheet consists of one or more set of rules that are called templates.5.The <xsl:template> element is used to build templates.6.The match attribute is used to associate a template with an XML element.7.The <xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformation.8.The XSL <xsl:for-each> element can be used to select every XML element of a specified node-set.9.The <xsl:apply-templates> element applies a template to the current element or to the current element's child nodes.10.The <xsl:choose> element is used in conjunction with <xsl:when> and <xsl:otherwise> to express multiple conditional tests. 11.The XML DOM defines a standard way for accessing and manipulating XML documents.12.The DOM presents an XML document as a tree-structure.13.what are the three levels of DOM? Core DOM , XML DOM , HTML DOM14.The DOM defines the objects and properties of all document elements, and the methods to access them.15.What is the XML DOM? The XML DOM is a standard for how to get, change, add, or delete XML elements.

16.According to the DOM, everything in an XML document is a node.17.The XML DOM views an XML document as a tree-structure and the tree structure is called a node-tree.18.An XML parser reads XML, and converts it into an XML DOM object that can be accessed with JavaScript.19.Mention the ways to access a node. By using the getElementsByTagName() method By looping through (traversing) the nodes tree. By navigating the node tree, using the node relationships.20.what is ajax?AJAX = Asynchronous JavaScript and XML.AJAX is not a new programming language, but a new way to use existing standards. AJAX is the art of exchanging data with a server, and update parts of a web page - without reloading the whole page.21.what is ajax about?AJAX is about updating parts of a web page, without reloading the whole page22.ajax is a combination of XMLHttpRequest object (to exchange data asynchronously with a server) JavaScript/DOM (to display/interact with the information) CSS (to style the data) XML (often used as the format for transferring data) 23.AJAX applications are browser- and platform-independent!24.The keystone of AJAX is the XMLHttpRequest object.25. The XMLHttpRequest object is used to exchange data with a server. To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object:

St.Joseph’s College of Engineering ISO 9001:2008

Page 71: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

27.. To get the response from a server, use the responseText or responseXML property of the XMLHttpRequest object.28. The XMLHttpRequest object is used to exchange data with a server behind the scenes.29.The onreadystatechange event is triggered every time the readyState changes.30. Three important properties of the XMLHttpRequest object are onreadystatechange , readyState and status31.what is xml? Extensible Markup Language (XML) is a set of rules for encoding documents in machine-readable form.32.give some examples for xml based languages. RSS, Atom, SOAP, and XHTML.33.what is the difference between HTML and XML? HTML is about displaying information, while XML is about carrying information.34. What are the implicit objects? Implicit objects are objects that are created by the web container and contain information related to a particularrequest35.XML is a software- and hardware-independent tool for carrying information.36.XML data is stored in plain text format.37.XML tags are case sensitive.38.what is the significance of xml attribute value? In XML, the attribute values must always be quoted "<" and "&" characters are strictly illegal in XML.A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition.39.what is the purpose of DTD? The purpose of a DTD is to define the structure of an XML document.40.what is JSP? JavaServer Pages (JSP) is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML, or other document types.41.what is the purpose of JSP? The purpose of JSP is to provide a declarative, presentation-centric method of developing servlets.42.what are Java Servlets? They are programs that run on a Web server and build Web pages. To be a servlet, a class should extend HttpServlet and override doGet or doPost.43.what are JSP sessions? They are objects associated with a visitor data can be put in the session and retrieved from it.44.what are custom tags and why do you need custom tags? Custom tags are those which are user defined Inorder to separate the presentation logic in a separate class rather than keeping in jsp page we can use custom tags.45.Mention the three main types of JSP elements? Directive element, Scripting element and Action element46.What is JSP page? A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format such as HTML, SVG, WML, and XML, and JSP elements, which construct dynamic content.47. How can a servlet refresh automatically if some new data has entered the database? By a client-side Refresh or Server Push.48. What is the difference between node and host? A node is any addressable device connected to a network whereas the host is a more specific descriptor that refers to a networked general-purpose computer rather than a single purpose device .49.What is the purpose of routers? Router operates like electronic postal workers that evaluate and forward packets between networks.

St.Joseph’s College of Engineering ISO 9001:2008

Page 72: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

50. Define protocol. A protocol is a formal set of rules that must be followed in order to communicate.51. Why are the protocols layered? Layering protocols simplifies the task of communicating over the network and it allows for reuse of layers that are not specific to a particular application.52. Define encapsulation. Placing the data inside a package of headers is known as encapsulation.53. Define port. A port is a logical channel to an application running on a host. ie., The applications running on the host machines are uniquely identified by port numbers.54. What do you mean by well-known ports? Port numbers can range from 1 to 65535, however ports 1 to 1023 are reserved. These reserved ports are referred to as we1l-known ports because the Internet Assigned Numbers Authority publicly documents the applications that use them.55. What is meant by Name Resolution? Name Resolution is the process of mapping a hostname to its corresponding IP Address.One way to translate a hostname to an IP address is to look it up in a simple text file. The second way is the domain name service, which is a distributed database containing all registered hostnames on the Internet and their IP addresses.56. Define protocol tunneling. Protocol tunneling is the process of encapsulating one protocol within another protocol that operates on the same layer.57.Define URI, URL, URN. 1. URI (Uniform Resource Identifier): It identifies an object on the Internet. 2. URL (Uniform Resource Locator): It is a specification for identifying an object such as a file, newsgroup, CGI program or e-mail address by indicating the exact location onthe internet.58. URN (Uniform Resource Name): It is a method for referencing an object without declaring the full path to the object.59. What are the components of HTTP URL? The components are host, an optional port, path, filename, section and query string.60. Define URL encoding. URL encoding involves replacing all unsafe and nonprintable characters with a percent sign (%) followed by two hexadecimal digits corresponding to the character’s ASCIIvalue.61. What are the issues of next generation IP? The issues to be considered in IP next generation are I. Addresses Space Growth 2. Support large Global networks 3. A clear way of transition from the existing IP to new IP next generation62. What is the difference between TCP and UDP? TCP: Connection oriented transport protocol Sends data as a stream of bytes Guarantee of delivery UDP: Connection less protocol Datagram service No guarantee of delivery.63. What does ICMP provide?

St.Joseph’s College of Engineering ISO 9001:2008

Page 73: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

ICMP provides 1. Error messaging 2. Demand reply functions64. Define IGMP. It is Internet Group Management protocol. It provides 1. Broadcasting 2. Multicasting65. List the goals of SGML. I. To manage the flow of millions of pages. 2. For structuring information exchange 3. For modeling inter-document linkages 4. For managing information flows between departments and weapons systems66. What is the role of server? 1. Manages application tasks 2. Handles storage 3. Handles security 4. Provides scalability 5. Handles accounting and distribution67. What are the necessities of using HTML forms? 1. Gathering user information 2. Conducting Surveys 3. Interactive services68. What are the sequences of steps for each HTTP request from a client to the server? 1. Making the connection 2. Making a request 3. The response 4. Closing the connection69. Define MIME. MIME (Multipurpose Internet Mail Extensions) is an open standard for sending multipart, multimedia data through Internet email.70. List the predefined MIME content types. 1. Text

2. Multipart3. Message4. Image5. Audio6. Video7. Model8. Application

71. Define HTML. It is a simple page description language, which enables document creation for the web.72. What is meant by loop back address? A zone that enables the server to direct traffic to itself. The host number is almost always 127.0.0.1.73. Define packet switched networks. Packet switched network means that data traveling on the network is broken into chunks called packets and each packet is handled separately.74. Define socket. The socket is a software abstraction used to represent the terminals of a connection between two machines or processes.75. What are the basic operations of client sockets?

St.Joseph’s College of Engineering ISO 9001:2008

Page 74: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Connect to a remote machineSend dataReceive dataClose a connection

76. What are the basic operations of Server socket?Bind to a portListen for incoming dataAccept connections from remote machines on the bound port

77. List all the socket classes in java.SocketServerSocketDatagram SocketMulticast SocketSecure sockets

78.What the Socket Object does? Socket object is the java representation of a TCP connection when a socket is created; a connection is opened to the specified destination.79. What is meant by Server Socket? ServerSocket represents a listening TCP connection. Once an incoming connection is requested, the ServerSocket object will return a Socket object representing the connection.80. What do you mean by DatagramSocket and DatagramPacket?

DatagramSocket represents a connectionless datagram socket. This class works with theDatagramPacket class to provide for communication using the UDP protocol.

81. Write a note on Connect Exception. This exception is raised when a connection is refused at the remote host. (ie, no process is listening on that port).82. What is a multicast socket? Multicasting sends data from one host to many different hosts, which are in the multicast group.83. What is multicast address and the range of address?

A multicast address is the address of a group of hosts called a multicast group.Multicast addresses are IP addresses in the range 224.0.0.0 to 239.255.255.255

84. What are the different types of IP addresses?Unicast address: It is used for transmitting a message to single destination nodeMulticast address: It delivers a message to a group of destination nodes, which are necessarily in the

same sub network.Broadcast address: It transmits a message to all nodes in a sub network.

85. What is meant by protocol handler?Protocol handlers are used to retrieve the web objects using application specificprotocols. The protocols are specified in the URL referencing the object.

86. How are the protocol handlers implemented?Four different classes in the java.net package implement the protocol handlers: 1. URL

2. URLStreamHandler3. URLConnection4. URLStreamHandlerFactory

87. What are the methods for parsing URLs?1. parseURL(URL u, String spec, int start, int limit)- splits the URL into parts2. setURL(URL u, Sring protocol, String host, int port, String file, String ref) –assigns values to the

URL’s fields.88. What is content handler?

St.Joseph’s College of Engineering ISO 9001:2008

Page 75: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

Content handlers are used to retrieve objects via an URLConnection object.89. What is Remote Method Invocation?

The Remote Method Invocation is application-programming interface that allows java objects on different hosts communicate with each other.90. What do you mean by remote object?

Objects that have methods that can be called across virtual machines are remote objects.91. Define serialization.

It is the process of converting a set of object instances that contain references to each other into a linear stream of bytes, which can then be through a socket. It is the mechanism used by RMI to pass objects between Java Virtual Machines.92. What are the responsibilities of stub?

A stub for a remote object is the client side proxy for the remote object. A client side stub is responsible for:

1.Initiating a call to the remote object2.Marshaling arguments to a marshal stream3.Informing the remote reference layer that the call should be invoked4.Unmarshaling the return value or exception from a marshal stream

93. What is the role of skeleton in RMI?A skeleton for a remote object is a server side entity that contains a method which dispatches calls to

the actual remote object implementation. The skeleton is responsible for1.Unmarshaling arguments from the marshal stream.2.Making the up-call to the actual remote object.3.Marshalling the return value of the call to an exception onto the Marshall stream

94. List down the layers of RMI architecture.1.Stubs/Skeletons2.Remote reference layer3.Transport layer

95. Define Object Activation.Object Activation is mechanism, which allows a java object to be bound and then activated at some

later data simply by referencing the object through the Registry.96. Write down the Socket object methods to get information about a socket.

1. getInetAddress ()- displays which remote host the Socket is connected to2. getPort () -displays which port the Socket is connected to on the remote host.3. getLoca1Port ()- to find the port number for the local end of a connection4. getLocalAddress () -tells you which network interface a socket is bound to..

97. Define cascading.Cascading refers to a certain set of rules that browsers use, in cascading order, to determine how to

use the style information. Such a set of rules is useful in the event of conflicting style information because the rules would give the browser a way to determine which style is given precedence.98.. What are the style precedence rules when using multiple approaches?

Inline styles override both linked style sheets and style information stored in the document head with <STYLE> tag.

Styles defined in the document head override linked style sheets.Linked style sheets override browser defaults.

99. Give the syntax to specify a characteristic in linked style sheet.{Characteristic: value}Multiple characteristic/value pairs should be separated by semicolons.

100.Define SSI. Server Side Includes (SSI) gives you a way to insert the content of another file into a file before the web server processes it.

St.Joseph’s College of Engineering ISO 9001:2008

Page 76: INTERNET PROGRAMMING LAB MANUAL

IT2357-WebTechnology Lab Department of IT 2012-2013

St.Joseph’s College of Engineering ISO 9001:2008