web technology lab program

75
1a)Developing Web Page Using Basic Html Algorithm Steps: Begin: Step 1: Create a HTML document. Step 2: Including the image of the college in the html document using the <IMG> tag. Step 3: Using <FRAMESET> tag divide the html page as preferred. Step 4: Create relevant web pages for the college and display the menu in the left side of the window. Step 5: Make the respective forms to be displayed in the right side of web page when the menu is clicked End Main.htm <HTML> <TITLE> Welcome to Kavery Engineering college!!! </TITLE> <FRAMESET BORDER COLOR="#rrggbb" ROWS="25%,75%"> <FRAME NAME="A" scrolling="no" src="f:/meena/flower2.gif"> <FRAMESET BORDER COLOR="#rrggbb" COLS="25%,75%"> <FRAME NAME="B" scrolling="no" SRC="menu.htm"> <FRAME NAME="C" src="home.htm"> </HTML>

Upload: chandrumtr

Post on 04-Apr-2015

5.807 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Technology Lab Program

1a)Developing Web Page Using Basic Html

Algorithm Steps:

Begin:

Step 1: Create a HTML document.

Step 2: Including the image of the college in the html document using the <IMG> tag.

Step 3: Using <FRAMESET> tag divide the html page as preferred.

Step 4: Create relevant web pages for the college and display the menu in the left side of

the window.

Step 5: Make the respective forms to be displayed in the right side of web page when the

menu is clicked

End

Main.htm

<HTML>

<TITLE>

Welcome to Kavery Engineering college!!!

</TITLE>

<FRAMESET BORDER COLOR="#rrggbb" ROWS="25%,75%">

<FRAME NAME="A" scrolling="no" src="f:/meena/flower2.gif">

<FRAMESET BORDER COLOR="#rrggbb" COLS="25%,75%">

<FRAME NAME="B" scrolling="no" SRC="menu.htm">

<FRAME NAME="C" src="home.htm">

</HTML>

Page 2: Web Technology Lab Program

Menu.htm

<HTML>

<BODY BGCOLOR="TAN">

<A HREF="home.htm" target="C"><B><H4>Home</H4></B></A>

<A HREF="courses.htm" target="C"><B><H4>Courses Offered

</H4></B></A>

<A HREF="academics.htm" target="C"><B><H4>Academics

</H4></B></A>

<A HREF="achievements.htm" target="C"><B><H4>Achievements

</H4></B></A>

<A HREF="contact.htm" target="C"><B><H4>Contact Us

</H4></B></A>

</BODY></HTML>

Home.htm

<HTML>

<BODY BGCOLOR="TAN">

<Marque><b><Font COLOR="RED" SIZE=24>

Knowledge Is Immortl!!!</font></b></marquee>

<DL>

<FoNT COLOR="GREEN">

<B><U>ABOUT US</B><U/></FONT><BR>

<DD>

<I><FONT COLOR="BLACK"><3>

This college was established in the year 2006 and belong to Kavery Educational

Trust</H3></FONT></I>

</DD></DL>

<DL>

<FONT COLOR="GREEN"><U><B>

VISION & MISSION</B></U></FONT><BR>

Page 3: Web Technology Lab Program

<DD>

<I><FONT COLOR="BLACK">

<H3>Our singular aim is to impart quality education with hight standards per excellence

in Engineering and Technology, to provide an excellent infrastructure in a serene and

conducive atmosphere that would motivate the students in pursuit of knowledge in

Engineering and Technology.

</H3></FONT></I>

</DD></DL>

<DL>

<FONT COLOR="GREEN"><B><U>

LOCATION</B></U></FONT><BR>

<DD>

<I><FONT COLOR="BLACK"><H3>The College is situated on the Salem Mettur

highway and is about 350 kms from Salem Railway station and Airport.

<H3></FONT></I>

</DD></DL>

</BODY>

</HTML>

Page 4: Web Technology Lab Program

Courses.htm

<HTML>

<BODY BGCOLOR="TAN">

<P><FONT COLOR="BLUE"><H3><B><I><U>

Under Graduation:</U></I></B></H3>

<PRE>

<U><h4><FONT COLOR="GREEN"><B>

Bachelor of Engineering:</B></FONT></H4></U>

<p><FONT COLOR="BLACK"><B>

Computer Science and Engineering

Electronics and Communication Engineering

Electrical and Electronics Engineering

Mechanical Engineering</B><FONT>

<U><H4><FONT COLOR="GREEN"><B>

Bachelor of technology</B></FONT>

</P></PRE>

<P><FONT COLOR="BLUE"><H3><B><I><U>

Post Graduation:</U></I></B></H3>

<PRE><P>

<FONT COLOR="BLACK"><B>

Master of Computer Application

Master of Business Administration

</B></FONT></O></PRE>

</BODY>

</HTML>

Page 5: Web Technology Lab Program

Academics.htm

<HTML>

<BODY BGCOLOR="TAN">

<H1><FONT FACE="monotype corsiva" COLOR="RED"><CENTER><B><I>

Code of conduct</I></B></CENTER></FONT></H1>

<H3><FONT FACE="monotype corsiva"COLOR="BLACK"><CENTER><B><I><P>

<FONT COLOR="RED">DISCIPLINE</FONT></P><P>

Students are expected to maintain discipline within the college premises, failing which

they will be

heavily fined, suspended or dismissed from the college.</P>

<P>

<FONT COLOR="RED">TEST MARK </FONT></P>

<P>

Students should get a minimum of 60% marks in each subject in all tests. Otherwise they

should take a

re-test in the concerned subjects after the college hours, till they secure 60% marks.</P>

<P>

<FONT COLOR="RED">INTERNAL / EXTERNAL PARTICIPATION

</FONT></P>

<P>

Conduct of those students participating in functions / seminars etc in the college or

outside

should bring credit to themselves and to the institution.</P>

<P>

<FONT COLOR="RED">TUITION FEES </FONT></P><P>

Students are expected to pay the fees before the due date as notified by the College.

Fees once paid will not be refunded. If any student discontinues the course in the middle,

he / she has to

pay the fees for the entire course</P>

<P>

Page 6: Web Technology Lab Program

<FONT COLOR="RED">

RAGGING AND EVE-TEASING </FONT></P><P>

(i)Ragging and Eve-Teasing are considered as crimes. They are strictly prohibited by an

act promulgated by the Govt.of Tamil Nadu with a fine up to Rs.10,000\- and 2 years of

rigorous imprisionment.

(ii) Students indulging in any form of ragging or Eve-Teasing inside the college or Hostel

premises or outside shall summarily be expelled from the college.</P>

<P>

<FONT COLOR="RED">

DRESS CODE / LATE ARRIVAL</FONT></P><P>

Students are advised to come to the college on time with their I.D. cards and they should

be neatly dressed in accordance to the college dress code and with the approved uniform

during the practical classes.

</P>

<P>

<FONT COLOR="RED">DRESS CODE:</FONT></P>

Boys: Formal pants with shirts neatly tucked in and formal shoes (Black or Brown color

only)

Girls: churidar or saree (Black cut shoe)</P>

<FONT COLOR="RED">CELL PHONES </FONT></P>

<p>

Use of cell phones by the Students is strictly prohibited in the college campus.</P>

</I></b></CENTER></FONT></H3>

<A HREF="#TOP"><FONT SIZE=4>TOP</FONT></A>

</BODY>

</HTML>

Page 7: Web Technology Lab Program

Achievements.htm

<HTML>

<BODY BG COLOR="TAN">

<H2><FONT FACE="monotype corsiva" COLOR="RED><CENTER><B><I>

Achievements</I></B></CENTER></FONT></H2>

<H3><FONT FACE="monotype corsiva" COLOR="BLACK"><CENTER><B><I>

<P>

Mr. Anandakumar T of 3rd Year MCA presented a paper on "Server Virtualisation"

in the International Conference at Dublin,Netherlands. He was the only student who

participated in the conference from India and was sponsored by The KaveryEngineering

College. He also won the ISTE Student

Best Project Award 2010. <P>Mr. Manikumar S. & Mr. Srinivasan M. Agila S of final

year MCA have been selected for innovative students project award 2010 by Indian

National Academy of New Delhi for their project on "Railway Station Signalling using

Embedded System"

<P>

Mr.Dinesh Karthik & Mr.Ananda Padmanabhan of Second year MCA presented the

paper on "Tsunami warning system" in the International Conference held in IISC,

Bangalore and were awarded the best paper

</P></I></B></CENTER></FONT></H3>

</BODY>

</HTML>

Page 8: Web Technology Lab Program

Contact.htm

<html>

<body bgcolor="pink">

<dl><b><font color="green"><h2><u>

contact us</u></h2></font><p>

<font color="black"></B>

<dd><pre><h3><i>

The Kavery Engineering College

Approved by AICTE, New Delhi and

Affiliated to Anna University, Coimbatore

Phone-0427-26494295

email: [email protected]

Trust Office:

THE KAVERY EDUCATIONAL TRUST

M.Kalipatti.Mecheri. Salem

</i><h3></pre>

</p><dd></dl>

</body>

</html>

Output:

Page 9: Web Technology Lab Program
Page 10: Web Technology Lab Program

1b)Html Code To Create Web Page Using Cascading Style Sheet :

Algorithm Steps:

Step 1: Create a HTML document.

Step 2: Including all the department information using various HTML tags.

Step 3: Create a CSS file to predefine the appearance of the HTML.

Step 4: Add the CSS file in all the HTML pages.

Background.css

HTML

{

BACKGROUND:#CC9999;

}

BODY

{

MARGIN:0;

PADDING:0;

COLOR:#333333;

FONT-FAMILY: VERDANA,ARIAL,HELVETICA,SANS-SERIF;

FONT-SIZE:0.9EM;

}

{

FONT-FAMILY:ARIAL,HELVETICA;

FONT-SIZE:25 PT;

COLOR:BLACK;

TEXT-ALLIGN:"CENTER";

TEXT-DECORATION:UNDERLINE;

}

Page 11: Web Technology Lab Program

HR

{

COLOR:MAROON;

WEIGHT:20PX

}

SPAN.BLUE

{

FONT-STYLE:ITALIC;

COLOR:BLUE;

}

SPAN.LINE

{

BORDER-BOTTOM: IPX SLIE#880033;

}

Main1.htm

<HTML>

<FRAMESET ROWS="25%,75%">

<FRAME SRC="D:\jdk\bin\flower1.gif">

<FRAMESET COLS="25%,75%">

<FRAME NAME="B" SRC="mca.HTM">

<FRAME NAME="C" SRC="lab.HTM">

</FRAMESET>

</FRAMESET>

</HEAD>

</HTML>

Page 12: Web Technology Lab Program

Mca.htm

<HTML>

<HEAD>

<TITLE>MCA</TITLE>

<LINK REL"stylesheet"TYPE="text/css" HREF="background.css">

<STYLE TYPE="text/css">

P.ARTICLE:FIRST-LETTER

{

COLOR:#A20000;

FONT-SIZE:XX-LARGE;

TEXT-INDENT:3CM

}

H3

{

FONT-FAMILY:SANSERIF;

FONT-SIZE="14";

TEXT-ALIGN="JUSTIFY"

}

DIV

{

TEXT-DECORATION:UNDERLINE

}

P.INDENT

TEXT-INDENT:3CM

}

P.THICK

{

FONTWEIGHT:BOLD

}

Page 13: Web Technology Lab Program

SPAN.HIGHLIGHT

{

BACKGROUND-COLOR:YELLOW

}

</STYLE>

</HEAD>

<BODY>

<H1>

<P CLASS="THICK">

<DIV>

Department of Computer Applications

</DIV></p>

</h1>

<hr>

<h3>

<p class="article">

The growth of versatile operating systems, programming languages, electronics

and communication system have given software industry a boom to develop <SPAN

CLASS="HIGHLIGHT">real time applications and high-end products</SPAN>. the

department of cse targets the students to acquire the present industrial requirements in

various domains such as Data structures, DBMS, system software, OOPS web

technology</p>

<P CLASS="INDENT">

The department library has been encouraging students to develop various software

projects. It has also been creating opportunities for pursuing pg programs in in reputed

Indian and Foreign Universities </p>

<p class="indent">

The society of Computer Science <span class="highlight">trace(Technology reformers

association for cse)</span> provides a platform for the students to sharpen their problem-

solving,

programming and exam work skills.</p></h3>

Page 14: Web Technology Lab Program

</body>

</html>

Lab.htm

<html>

<head>

<title>LAB</title>

<link rel="stylesheet" type="text/css"HREF="background.css">

<style type="text/css">

DT

{

margin:10px;

Padding:5px 5px 5px 5px

}

p.indent

{

text.indent:5 cm

}

h4

{

font-size="12pt";

text-align="justify";

font-family:arial

}

h3

{

font-weight:bold;

font-family:times

}

</style>

</head>

Page 15: Web Technology Lab Program

<body>

<h1>lab facilities</h1><hr>

<dl>

<dt>

<h3><span class="blue">central computer lab</span></h3>

<dd><p class="indent"><h4> this lab is equipped with 90 Pentium IV higher

configuration machines.

</h4></p></dl>

<dl><dt><h3>

<span class="blue">unix/rdbms lab:</span></h3>

<dd><p class="indent"><h4>

This lab is equipped with 90 Pentium IV higher configuration machines and installed

with oracle 10G.</h4></p></dl>

<dl><dt><h3>

<span class="blue">multimedia workshop</span></h3>

<dd><p class="indent"><h4>

This lab is equipped with 90 Pentium IV higher configuration machines and installed

with oracle 10G and multimedia

software. </h4></p></dl>

</body>

</html>

Page 16: Web Technology Lab Program

Cse.htm

<HTML>

<HEAD>

<TITLE>MCA </TITLE>

<LINK REL"stylesheet"TYPE="text/css" HREF="background.css">

<STYLE TYPE="text/css">

P.ARTICLE:FIRST-LETTER

{

COLOR:#A20000;

FONT-SIZE:XX-LARGE;

TEXT-INDENT:3CM

}

H3

{

FONT-FAMILY:SANSERIF;

FONT-SIZE="14";

TEXT-ALIGN="JUSTIFY"

}

DIV

{

TEXT-DECORATION:UNDERLINE

}

P.INDENT

TEXT-INDENT:3CM

}

P.THICK

{

FONTWEIGHT:BOLD

Page 17: Web Technology Lab Program

}

SPAN.HIGHLIGHT

{

BACKGROUND-COLOR:YELLOW

}

</STYLE>

</HEAD>

<BODY>

<H1>

<P CLASS="THICK">

<DIV>

Department of Computer Applications

</DIV></p>

</h1>

<hr>

<h3>

<p class="article">

The growth of versatile operating systems, programming languages, electronics

and communication system have given software industry a boom to develop <SPAN

CLASS="HIGHLIGHT">real time applications and high-end products</SPAN>. the

department of cse targets the students to acquire the present industrial requirements in

various domains such as Data structures, DBMS, system software, OOPS web

technology</p>

<P CLASS="INDENT">

The department library has been encouraging students to develop various software

projects. It has also been creating opportunities for pursuing pg programs in in reputed

Indian and Foreign Universities </p>

<p class="indent">

The society of Computer Science <span class="highlight">trace(Technology reformers

association for cse)</span> provides a platform for the students to sharpen their problem-

solving, programming and exam work skills.</p></h3></body></html>

Page 18: Web Technology Lab Program

Lab.htm

<html>

<head>

<title>LAB</title>

<link rel="stylesheet" type="text/css"HREF="background.css">

<style type="text/css">

DT

{

margin:10px;

Padding:5px 5px 5px 5px

}

p.indent

{

text.indent:5 cm

}

h4

{

font-size="12pt";

text-align="justify";

font-family:arial

}

h3

{

font-weight:bold;

font-family:times

}

</style>

</head>

<body>

<h1>lab facilities</h1><hr>

<dl>

Page 19: Web Technology Lab Program

<dt>

<h3><span class="blue">central computer lab</span></h3>

<dd><p class="indent"><h4> this lab is equipped with 90 Pentium IV higher

configuration machines.

</h4></p></dl>

<dl><dt><h3>

<span class="blue">unix/rdbms lab:</span></h3>

<dd><p class="indent"><h4>

This lab is equipped with 90 Pentium IV higher configuration machines and installed

with oracle 10G.</h4></p></dl>

<dl><dt><h3>

<span class="blue">multimedia workshop</span></h3>

<dd><p class="indent"><h4>

This lab is equipped with 90 Pentium IV higher configuration machines and installed

with oracle 10G and multimedia

software. </h4></p></dl>

</body>

</html>

Page 20: Web Technology Lab Program
Page 21: Web Technology Lab Program

1c) Program using Javascript and DHTML create an Order form

<html>

<head>

<script type="text/javascript">

function blinking_header()

{

if (!document.getElementById('blink').style.color)

{

document.getElementById('blink').style.color="red";

}

if (document.getElementById('blink').style.color=="red")

{

document.getElementById('blink').style.color="black";

}

else

{

document.getElementById('blink').style.color="red";

}

timer=setTimeout("blinking_header()",100);

}

function stoptimer()

{

clearTimeout(timer);

}

</script>

</head>

<body onload="blinking_header()" onunload="stoptimer()">

Page 22: Web Technology Lab Program

<h1 id="blink">Blinking header</h1>

<form name="OrderForm">

<table border=2 width="75%">

<tr>

<td><i>First Name</i></td>

<td>

<input type="text" name="Firstname" size=30 onfocus="window.status='Enter ur first

name please'">

</td>

</tr>

<tr>

<td><i>Last Name</i></td>

<td>

<input type="text" name="lastname" size=30 onfocus="window.status='Enter ur last

name please'">

</td>

</tr>

<tr>

<td><i>Address<i></td>

<td colspan="3">

<input type="text" name="address" size=30 onfocus="window.status='Enter ur mailung

address please'">

</td>

</tr>

<tr>

<td><i>City</i></td>

<td>

<input type="text" name="city" size=30 onfocus="window.status='Enter ur city please'">

</td>

</tr>

Page 23: Web Technology Lab Program

<tr>

<td><i>State</i></td>

<td>

<input type="text" name="state" size=30 onfocus="window.status='Enter ur state

please'">

</td>

</tr>

<tr>

<td><i>ZIP</i></td>

<td>

<input type="text" name="zip" size=10 onfocus="window.status='Enter ur PIn

please'">

</td>

</tr>

</table>

<p>

<center>

would u like to be in ur mailing list

<input type="checkbox" name="list" checked onclick="notify()">Yes

</center?

<p>

<hr widh=50% align=center>

<p>

<select name="orderitem">

<option value="8.95">Grey

<option value="12.95">Color

<option value="24.99">Our Mid Range Item

<option value="99.95">Super Deluxe

</select> Select the Item u want

<p>

<select name="Qty">

Page 24: Web Technology Lab Program

<option value="1">One

<option value="2">Two

<option value="3">Three

<option value="4">Four

</select>Select the qty of items to order</b>

<p>

Total Due

<input type=text name="total" size=11 onfocus="totalorder(this.form)">

<hr>

<p>

<input type=submit value="Place order" ><input type=reset value="clear the form">

</form>

<script language="javascript">

function notify()

{

alert("Please be aware that mailing list is for internal use");

}

function totalorder(form)

{

var x=form.orderitem.options[form.orderitem.selectedIndex].value;

var y=form.Qty.options[form.Qty.selectedIndex].value;

var due=x*y;

form.total.value=due;

}

</script>

</body>

</html>

Page 25: Web Technology Lab Program
Page 26: Web Technology Lab Program

2. Write a application/GUI program in java for getting time and data information

from the server using TCP/UDP

TCPServer.java

import java.io.*;

import java.net.*;

import java.util.*;

class TCPServer

{

public static void main(String args[])

{

try

{

Date d;

ServerSocket s=new ServerSocket(8080,5);

Socket con=s.accept();

PrintWriter out=new PrintWriter(con.getOutputStream(),true);

d=new Date();

System.out.println("Server Conencted");

out.println(d.toString());

con.close();

out.close();

}

catch(Exception e)

{

System.out.println(e);

}

}

}

Page 27: Web Technology Lab Program

TCPClient.java

import java.io.*;

import java.net.*;

import java.util.*;

class TCPClient

{

public static void main(String args[])

{

try

{

int i=1;

Socket con=new Socket("localhost",8080);

BufferedReader in=new BufferedReader(new

InputStreamReader(con.getInputStream()));

System.out.println("Date using TCP");

String st=new String(in.readLine());

System.out.println(st);

con.close();

in.close();

}

catch(Exception e)

{

System.out.println(e);

}

}

}

Page 28: Web Technology Lab Program

Output:

Page 29: Web Technology Lab Program

3. Design a FTP Server through which download /Upload files.

ServerFile.java

import java.net.*;

import java.io.*;

public class ServerFile

{

ServerSocket serverSocket;

Socket socket;

int port;

ServerFile()

{

this(9999);

}

ServerFile(int port)

{

this.port = port;

}

void waitForRequests() throws IOException

{

serverSocket = new ServerSocket(port);

while (true)

{

System.out.println("Server Is WAITING...");

socket = serverSocket.accept();

System.out.println("Request Received From " +

socket.getInetAddress()+"@"+socket.getPort());

new ServantFile(socket).start();

System.out.println("Service Started Thread ");

}

}

Page 30: Web Technology Lab Program

public static void main(String[] args)

{

try

{

new ServerFile().waitForRequests();

}

catch (IOException e)

{

e.printStackTrace();

}

}

}

Page 31: Web Technology Lab Program

ClientFile.java

import java.io.*;

import java.net.*;

public class ClientFile

{

String serverAddress;

String fileName;

int port;

Socket socket;

ClientFile()

{

this("localhost", 9999, "Model.txt");

}

ClientFile(String serverAddress, int port, String fileName)

{

this.serverAddress = serverAddress;

this.port = port;

this.fileName = fileName;

}

void sendRequestForFile() throws UnknownHostException, IOException

{

socket = new Socket(serverAddress, port);

System.out.println("Connecting to Server...");

PrintWriter writer = new PrintWriter(new

OutputStreamWriter(socket.getOutputStream()));

writer.println(fileName);

writer.flush();

System.out.println("Request has been Sent... ");

getResponseFromServer();

socket.close();

}

Page 32: Web Technology Lab Program

void getResponseFromServer() throws IOException

{

BufferedReader reader = new BufferedReader(new

InputStreamReader(socket.getInputStream()));

String response = reader.readLine();

if(response.trim().toLowerCase().equals("filenotfound"))

{

System.out.println(response);

return; }

else

{

BufferedWriter fileWriter = new BufferedWriter(new FileWriter("FileRecd.txt"));

do

{

fileWriter.write(response);

fileWriter.flush();

}while((response=reader.readLine())!=null);

fileWriter.close();

}

}

public static void main(String[] args)

{

try

{

new ClientFile().sendRequestForFile();

}

catch (UnknownHostException er)

{

er.printStackTrace();

}

Page 33: Web Technology Lab Program

catch (IOException er)

{

er.printStackTrace();

}

}

}

Page 34: Web Technology Lab Program

ServantFile.java

import java.net.*;

import java.io.*;

public class ServantFile extends Thread

{

Socket socket;

String fileName;

BufferedReader in;

PrintWriter out;

ServantFile(Socket socket) throws IOException

{

this.socket = socket;

in = new BufferedReader(new

InputStreamReader(socket.getInputStream()));

out = new PrintWriter(new

OutputStreamWriter(socket.getOutputStream()));

}

public void run()

{

try

{

fileName = in.readLine();

File file = new File(fileName);

if (file.exists())

{

BufferedReader fileReader = new

BufferedReader(new FileReader(fileName));

String content = null;

while ((content = fileReader.readLine())!=null)

{

out.println(content);

Page 35: Web Technology Lab Program

out.flush();

}

System.out.println("File has been Sent...");

}

else

{

System.out.println("Requested File was Not Found...");

out.println("File Not Found");

out.flush();

}

socket.close();

System.out.println("Connection Closed!");

}

catch (FileNotFoundException e)

{

e.printStackTrace();

}

catch (IOException e)

{

e.printStackTrace();

}

}

public static void main(String[] args)

{

}

}

Page 36: Web Technology Lab Program
Page 37: Web Technology Lab Program
Page 38: Web Technology Lab Program

4. Write a program in java to implement Database Connectivity

import java.sql.*;

public class Selectdemo

{

public static void main(String args[])

{

try

{

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

Connection con=DriverManager.getConnection("jdbc.odbc.mca","","");

ResultSet rs=stat.executeQuery("select * from student");

while(rs.next())

{

int rno=rs.getInt("rollno");

String name=rs.getString("sname");

int tot=rs.getInt("total");

System.out.println(rno+ " "+name+" "+tot);

}

catch(SQLException e)

{

System.out.println(e);

}

catch(Exception ex)

{

System.out.println(ex);

}

}

}

Page 39: Web Technology Lab Program
Page 40: Web Technology Lab Program

5. Write a JSP program for order processing

JSP Shopping Cart

<html>

<jsp:useBean id="cart" scope="session" class="sessions.DummyCart" />

<jsp:setProperty name="cart" property="*" />

<%

cart.processRequest(request);

%>

<FONT size = 5 COLOR="#CC0000">

<br> You have the following items in your cart:

<ol>

<%

String[] items = cart.getItems();

for (int i=0; i<items.length; i++) {

%>

<li> <%= items[i] %>

<%

}

%>

</ol>

</FONT>

<hr>

<%@ include file ="/jsp/sessions/carts.html" %>

</html>

Page 41: Web Technology Lab Program

Carts.htm

<head>

<title>carts</title>

</head>

<body bgcolor="white">

<font size = 5 color="#CC0000">

<form type=POST action=carts.jsp>

<BR>

Please enter item to add or remove:

<br>

Add Item:

<SELECT NAME="item">

<OPTION>Beavis & Butt-head Video collection

<OPTION>X-files movie

<OPTION>Twin peaks tapes

<OPTION>NIN CD

<OPTION>JSP Book

<OPTION>Concert tickets

<OPTION>Love life

<OPTION>Switch blade

<OPTION>Rex, Rugs & Rock n' Roll

</SELECT>

<br> <br>

<INPUT TYPE=submit name="submit" value="add">

<INPUT TYPE=submit name="submit" value="remove">

</form>

Page 42: Web Technology Lab Program

</FONT>

</body>

</html>

Page 43: Web Technology Lab Program
Page 44: Web Technology Lab Program

6. Write a Servlet, bean program to access information from databases

EmployeeDetails.java

import java.io.*;

import java.sql.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class EmployeeDetails extends HttpServlet

{

static int i;

Connection con;

PrintWriter out;

ResultSet rs;

public void init()

{

i=0;

con=null;

out=null;

rs=null;

}

public void doGet(HttpServletRequest req,HttpServletResponse res) throws

ServletException,IOException

{

i++;

out=res.getWriter();

out.println("You are user no " + i + "to visit this site<br>");

try

Page 45: Web Technology Lab Program

{

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

con=DriverManager.getConnection("jdbc:odbc:EmployeeDb","","");

PreparedStatement stat=null;

String query=null;

query="select id,ename,address,age,desig from Employee where id=?";

stat=con.prepareStatement(query);

stat.setInt(1,Integer.parseInt(req.getParameter("id")));

rs=stat.executeQuery();

out.println("<b><center>Employee Details</center></b><br><br>");

ResultSetMetaData rsmd=rs.getMetaData();

int colcount=rsmd.getColumnCount();

out.println("<table align=CENTER BORDER=1 CELLPADDING=2>");

out.println("<TR>");

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

{

out.println("<th>"+rsmd.getColumnLabel(i)+"</th>");

}

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

while(rs.next())

{

out.println("<tr>");

out.println("<td>"+rs.getString("id")+"</td>");

out.println("<td>"+rs.getString("ename")+"</td>");

out.println("<td>"+rs.getString("address")+"</td>");

out.println("<td>"+rs.getString("age")+"</td>");

out.println("<td>"+rs.getString("desig")+"</td>");

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

}

Page 46: Web Technology Lab Program

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

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

}

catch(Exception e)

{

out.println(e.toString());

}

}

public void destroy()

{

try

{

i=0;

con.close();

out.close();

rs.close();

}

catch(SQLException se)

{

out.println(se.toString());

}

}

}

Page 47: Web Technology Lab Program

Emp.htm

<html>

<body>

<form method="GET"

ACTION="http://localhost:8080/examples/servlet/EmployeeDetails">

<h2 align="center">Find Employee Information</center></h2>

<table>

<tr><th>Enter Employee Id</th>

<td><input type="text" name="id"></td></tr>

</table>

<input type="submit" value="click me">

</form>

</html>

Page 48: Web Technology Lab Program
Page 49: Web Technology Lab Program
Page 50: Web Technology Lab Program
Page 51: Web Technology Lab Program

7.Write a ASP program using the components

Browser Capability Component

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"

Inherits="_Default" %>

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

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

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

<head runat="server">

<title>ASP Components</title>

<style type ="text/css">

p { font-family : tahoma, sans-serif; font-size: 10pt; }

td { font-family : tahoma, sans-serif; font-size: 8; padding-left: 10; }

tr { background-color:#F7f7f7; }

.title { color:#396B9C; font-weight: bold; }

.header { background-color:#CCDDEE; }

</style>

</head>

<body>

<form id="form1" runat="server">

<div>

<table width ="90%" border ="1" cellpadding ="2" cellspacing ="2">

<tr class ="header">

<td>Property</td>

<td>Value</td>

</tr>

<tr>

<td>ActiveXControls</td>

Page 52: Web Technology Lab Program

<td><%=Request.Browser.ActiveXControls %></td>

</tr>

<tr>

<td>AOL</td>

<td><%=Request.Browser.AOL %></td>

</tr>

<tr>

<td>BackgroundSounds</td>

<td><%=Request.Browser.BackgroundSounds %></td>

</tr>

<tr>

<td>Beta</td>

<td><%=Request.Browser.Beta %></td>

</tr>

<tr>

<td>Browser</td>

<td><%=Request.Browser.Browser %></td>

</tr>

<tr>

<td>CDF</td>

<td><%=Request.Browser.CDF %></td>

</tr>

<tr>

<td>ClrVersion</td>

<td><%=Request.Browser.ClrVersion %></td>

</tr>

<tr>

<td>Cookies</td>

<td><%=Request.Browser.Cookies %></td>

</tr>

<tr>

Page 53: Web Technology Lab Program

<td>Crawler</td>

<td><%=Request.Browser.Crawler %></td>

</tr>

<tr>

<td>ClrVersion</td>

<td><%=Request.Browser.ClrVersion %></td>

</tr>

<tr>

<td>Frames</td>

<td><%=Request.Browser.Frames %></td>

</tr>

<tr>

<td>Java Applets</td>

<td><%=Request.Browser.JavaApplets %></td>

</tr>

<tr>

<td>JavaScript</td>

<td><%=Request.Browser.JavaScript %></td>

</tr>

<tr>

<td>Major Version</td>

<td><%=Request.Browser.MajorVersion %></td>

</tr>

<tr>

<td>Minor Version</td>

<td><%=Request.Browser.MinorVersion %></td>

</tr>

<tr>

<td>Platform</td>

<td><%=Request.Browser.Platform %></td>

</tr>

Page 54: Web Technology Lab Program

<tr>

<td>Tables</td>

<td><%=Request.Browser.Tables %></td>

</tr>

<tr>

<td>Type</td>

<td><%=Request.Browser.Type %></td>

</tr>

<tr>

<td>Version</td>

<td><%=Request.Browser.Version %></td>

</tr>

<tr>

<td>Win16</td>

<td><%=Request.Browser.Win16 %></td>

</tr>

<tr>

<td>WIn32</td>

<td><%=Request.Browser.Win32 %></td>

</tr>

</table>

</div>

</form>

</body>

</html>

Page 55: Web Technology Lab Program
Page 56: Web Technology Lab Program

AdRotator Component

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"

Inherits="_Default" %>

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

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

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

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:Label ID="showAd" Runat="server" Text="Advertisment show Here!" Font-

Bold="True" Font-Names ="Verdana" Font-Size="12pt" ForeColor="RoyalBlue" ><br/>

<hr/><br/>

<asp:AdRotator AdvertisementFile="advertisementfile.xml" Target="_blank"

BorderColor="#993366" BorderWidth="2" Runat="server" KeywordFilter="ShowAd!"

id="dispAdd" />

<hr/><br/>

<asp:Label ID="showMsg" Runat="server" Font-Bold="True" Font-Names ="Verdana"

Font-Size="10pt" ForeColor="RoyalBlue" />

</div>

</form>

</body>

</html>

Page 57: Web Technology Lab Program

Advertisement.xml

<Advertisements>

<Ad>

<ImageUrl>

dog1.gif

</ImageUrl >>

<NavigateUrl>

www.xyz1.com

</NavigateUrl>

<AlternateText>

Click Me!

</AlternateText >>

<Keyword>

ShowAd!

</Keyword >

<Impression>

70

</Impression >

<AccountName>

ACC1

</AccountName>

</Ad>

<Ad>

<ImageUrl>

fish2.gif

</ImageUrl>

<NavigateUrl>

www.xyz2.com

</NavigateUrl>

<AlternateText>

Click Me!

Page 58: Web Technology Lab Program

</AlternateText>

<Keyword>

ShowAd!

</Keyword >

<Impression>

70

</Impression>

<AccountName>

ACC2

</AccountName >

</Ad >

<Ad>

<ImageUrl>

splash.gif

</ImageUrl >

<NavigateUrl>

www.xyz3.com

</NavigateUrl>

<AlternateText>

Click Me!

</AlternateText>

<Keyword>

Don'tShowAd!

</Keyword>

<Impression>

70

</Impression >>

<AccountName>

ACC3

</AccountName>

</Ad>

Page 59: Web Technology Lab Program

<Ad>

<ImageUrl>

serverduke.gif

</ImageUrl >

<NavigateUrl>

www.xyz4.com

</NavigateUrl>

<AlternateText>

Click Me!

</AlternateText>

<Keyword>

ShowAd!

</Keyword >>

<Impression>

70

</Impression>

<AccountName>

ACC4

</AccountName >

</Ad >

</Advertisements >

Page 60: Web Technology Lab Program
Page 61: Web Technology Lab Program