+ All Categories
Home > Documents > Lab Manual

Lab Manual

Date post: 03-Dec-2014
Category:
Upload: senthil-kumar
View: 663 times
Download: 11 times
Share this document with a friend
Popular Tags:
89
SASURIE COLLEGE OF ENGINEERING VIJAYAMANGALAM DEPARTMENT OF INFORMATION TECHNOLOGY LAB MANUAL FOR WEB TECHNOLOGY (VII SEMESTER) PREPARED BY S.RENUGADEVI (LECTURER / IT)
Transcript
Page 1: Lab Manual

SASURIE COLLEGE OF ENGINEERING

VIJAYAMANGALAM

DEPARTMENT OF INFORMATION TECHNOLOGY

LAB MANUAL FOR WEB TECHNOLOGY

(VII SEMESTER)

PREPARED BY

S.RENUGADEVI

(LECTURER / IT)

Page 2: Lab Manual

LAB SYLLABUS

Creating applications using web development tools

1. HTML & VB Script2. XML - DTD3. XML - XSL4. XML - CSS5. Translating EDIfact document to XML6. Active Server Pages7. Java Server Pages8. Java Servlets9. .NET Platform10. C# in .NET Platform

Page 3: Lab Manual

1.HTML & VBSCRIPT

Aim:

To create an application using HTML and VB scripts.

Algorithm:

1.Open notepad.

2. Write HTML scripts and save it as filename.html

3. Run the application using Web browser.

4.Stop the process.

HTML Scripts:

Main page:

<html>

<head>

<title>home page</title>

</head>

<body>

<center><b><h1>welcome to amazon.com</h1></b><br><br>

<form method="post"action="login.html">

<input type="submit"value="click">registration user login hear

</center>

</body>

</html>

Page 4: Lab Manual

Login page:

<html>

<head>

<title>login page</title>

</head>

<body>

<center>

<form method="post" action="login.html">

<p><strong>name:</strong>

<input type="text" name="username" size="25">

</p>

<p><strong>password</strong>

<input name="pass" type="password" size="6"></p>

<p><strong>male</strong>

<input type="radio" value="male"<hacked>&nbsp&nbsp</p>

<p><strong>female</strong>

<option><input type="radio" value="female"<hacked>&nbsp;</p>

<input type="submit" value="submit">&nbsp&nbps

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

<a href="registration.html">new users register hear </a>

</form>

</center>

</body>

Page 5: Lab Manual

</html>

Registration:

<html>

<head>

<title>registration</title>

</head>

<body>

<center>

<form method="post" action="login.html">

<p><strong>name:</strong>

<input type="text" name="username" size="25">

</p>

<p><strong>password</strong>

<input name="pass" type="password" size="6"></p>

<p><strong>male</strong>

<input type="radio" value="male"<hacked>&nbsp&nbsp</p>

<p><strong>female</strong>

<input type="radio" value="female" </p>

<p><strong>address:</strong>

<textarea name="address" row="6" cols="20">

</textarea>

</p>

<p><strong>mobile no:</strong>

<input type="text" name="phno" size="10">

</p><br><br>

Page 6: Lab Manual

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

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

</form>

</center>

</body>

</html>

Books Catalog:

<html>

<head>

<title>books catalog</title>

</head>

<body>

<center><h1><p>welcome to books catalog</p></h1>

<table border="1"width="25%"height="50%">

<tr>

<th>computers</th>

<th>electronics</th>

<th>biotech</th>

<th>mechanical</th>

</tr>

<tr>

<td>

</body>

</html>

Page 7: Lab Manual

Output:

Page 8: Lab Manual
Page 9: Lab Manual
Page 10: Lab Manual

VB SCRIPT:

Reverse a string:

<html>

<body>

<script type="text/vbscript">

sometext = "Hello Everyone!"

document.write(StrReverse(sometext))

</script>

</body>

</html>

Page 11: Lab Manual
Page 12: Lab Manual

VB Script Subroutines:

<HTML><HEAD><TITLE>Subroutine Demo</TITLE>

<SCRIPT LANGUAGE=VBScript>

Sub GetName_OnClick()

UserName = InputBox ("Enter your full name")

Msg = "Hello " & UserName & ". Welcome to my site."

Alert Msg

End Sub

</SCRIPT></HEAD><BODY>

<H1>Subroutine Demo</H1><P>

This document demonstrates the use of VBScript subroutines.

<HR><INPUT TYPE=Button NAME=GetName Value="Tell me your name">

<div style="display: block; font-family: Verdana, Geneva, Arial; font-size: 10px">

Welcome

</div>

</BODY></HTML>

Page 13: Lab Manual
Page 14: Lab Manual
Page 15: Lab Manual

Result:

Thus an application using Html and VB Scripts has been executed successfully.

Page 16: Lab Manual

2.XML – DTD

Aim:

To create an application using XML-DTD

Algorithm:

1.Open notepad.

2. Write XML scripts and save it as filename.html

3. Run the application using Web browser.

4.Stop the process.

Scripts:

1.Internal DTD

<!DOCTYPE BOOKDETAIL [

<!ELEMENT BOOKDETAIL (BOOK)*>

<!ELEMENT BOOK (TITLE, AUTHOR, PRICE)>

<!ELEMENT TITLE (#PCDATA)>

<!ELEMENT AUTHOR EMPTY>

<!ATTLIST AUTHOR FNAME (SCOTT | BALA ) #REQUIRED

SCNAME (MULLER | KURUSAMY) #REQUIRED>

<!ELEMENT PRICE (#PCDATA)>

]>

<BOOKDETAIL>

<BOOK>

<TITLE>EJB</TITLE>

Page 17: Lab Manual

<AUTHOR FNAME="SCOTT" SCNAME="MULLER"></AUTHOR>

<PRICE>RS.500</PRICE>

</BOOK>

<BOOK>

<TITLE>C</TITLE>

<AUTHOR FNAME="BALA" SCNAME="KURUSAMY"></AUTHOR>

<PRICE>RS.300</PRICE>

</BOOK>

<BOOK>

<TITLE>JAVA</TITLE>

<AUTHOR FNAME="SCOTT" SCNAME="MULLER"></AUTHOR>

<PRICE>RS.500</PRICE>

</BOOK>

</BOOKDETAIL>

2. External DTD

<!DOCTYPE BOOKDETAIL SYSTEM "P3.DTD">

<BOOKDETAIL>

<BOOK1>

<TITLE>EJB</TITLE>

<AUTHOR FNAME="SCOTT" SCNAME="MULLER"></AUTHOR>

<PRICE>RS.500</PRICE>

</BOOK1>

Page 18: Lab Manual

<BOOK2>

<TITLE>C</TITLE>

<AUTHOR FNAME="BALA" SCNAME="KURUSAMY"></AUTHOR>

<PRICE>RS.300</PRICE>

</BOOK2>

<BOOK3>

<TITLE>JAVA</TITLE>

<AUTHOR FNAME="SCOTT" SCNAME="MULLER"></AUTHOR>

<PRICE>RS.500</PRICE>

</BOOK3>

</BOOKDETAIL>

DTD

<!ELEMENT BOOKDETAIL (BOOK)*>

<!ELEMENT BOOK (TITLE, AUTHOR, PRICE)>

<!ELEMENT TITLE (#PCDATA)>

<!ELEMENT AUTHOR EMPTY>

<!ATTLIST AUTHOR FNAME (SCOTT | BALA ) #REQUIRED

SCNAME (MULLER | KURUSAMY) #REQUIRED>

<!ELEMENT PRICE (#PCDATA)>

Page 19: Lab Manual

Output:

Page 20: Lab Manual

Result:

Thus an application using XML-DTD has been executed successfully.

Page 21: Lab Manual

3.XML – XSL

Aim:

To create an application using XML-XSL

Algorithm:

1.Open notepad.

2. Write XML scripts and save it as test.xml.

3. We need to transform XML to HTML using XSL

4. Write XSL scripts and save it as test.xsl.

5.Write CSS scripts and save it as css.css

6.Run the application(test.xml) using Web browser.

7.Stop the process.

Scripts:

Test.xml

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

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

<document>

<menu>

<item>

<name>renu</name>

<url>http://www.google.com</url>

</item>

<item>

<name>devi</name>

<url>http://www.india.com</url>

Page 22: Lab Manual

</item>

<item>

<name>Sasurie</name>

<url>http://www.sasurie.com</url>

</item>

</menu>

<content>

<news>

<title>

Welcome

</title>

<news>

How are you

</news>

</news>

<news>

<title>

Hai

</title>

<news>

<font face="courier">

<strong>hai text &#8801;</strong>

</font>

</news>

<include>

Page 23: Lab Manual

<data>

<item>

Information Technology

</item>

<item>

B.Tech

</item>

</data>

</include>

</news>

</content>

</document>

Test.xsl:

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

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="document">

<html>

<head>

<title>Title</title>

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

</head>

<body>

Page 24: Lab Manual

<table>

<tr>

<td valign="top">

<xsl:apply-templates select="menu" />

</td>

<td valign="top">

<table border="1">

<xsl:for-each select="content/news">

<xsl:choose>

<xsl:when test="position() mod 2 = 0">

<tr><td class="text">

<xsl:number value="position()" format="1" />.

<strong><xsl:value-of select="title"/></strong><br/>

<xsl:copy-of select="news"/>

<br/><br/>

<xsl:apply-templates select="include" />

</td></tr>

</xsl:when>

<xsl:otherwise>

<tr><td bgcolor="#cccccc" class="text">

<xsl:number value="position()" format="1" />.

<strong><xsl:value-of select="title"/></strong><br/>

<xsl:copy-of select="news"/>

<br/><br/>

<xsl:apply-templates select="include" />

Page 25: Lab Manual

</td></tr>

</xsl:otherwise>

</xsl:choose>

</xsl:for-each>

</table>

</td>

</tr>

</table>

</body>

</html>

</xsl:template>

<xsl:template match="include">

IT Peak of Perfection<br/>

<xsl:for-each select="data/item">

<strong><xsl:value-of select="."/></strong><br/>

</xsl:for-each>

</xsl:template>

<xsl:template match="menu">

<table border="1">

<xsl:for-each select="item">

<tr>

<td>

<A class="text">

<xsl:attribute name="href">

<xsl:value-of select="url"/>

Page 26: Lab Manual

</xsl:attribute>

<xsl:value-of select="name"/>

</A>

</td>

</tr>

</xsl:for-each>

</table>

</xsl:template>

</xsl:stylesheet>

Css.css:

.text {

line-height: 16px;

color: #222299;

font-family: sans-serif;

font-size: 10px

}

a { text-decoration: none}

a:hover { text-decoration: underline}

Page 27: Lab Manual

Output:

Result:

Thus an application using XML-XSL has been executed successfully.

Page 28: Lab Manual

4.XML – CSS

Aim:

To create an application using XML-CSS

Algorithm:

1.Open notepad.

2. Write XML scripts and save it as css.xml.

3.Write CSS scripts and save it as p5.css

4.Run the application(css.xml) using Web browser.

5.Stop the process.

Css.xml

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

<?xml-stylesheet type="text/css" href="p5.css"?>

<bookdet>

<book>

<title>C</title>

<author>Balaguruswamy</author>

<price>120</price>

<pages>200</pages>

</book>

<book>

<title>C++</title>

<author>Balaguruswamy</author>

Page 29: Lab Manual

<price>150</price>

<pages>400</pages>

</book>

<book>

<title>EJB</title>

<author>Scott</author>

<price>250</price>

<pages>300</pages>

</book>

</bookdet>

p5.css:

bookdet

{

background-color:"#ffffff";

}

title

{

display:block;

font-size:30pt;

border-style:dotted;

color:"#00ff00";

font-family:cursive;

text-align:center;

font-weight:bold;

Page 30: Lab Manual

background-image:url("apa.gif");

}

author

{

display:block;

text-align:center;

color:"#0000ff";

font-family:sans-serif;

background-image:url("apa1.gif");

font-size:25pt;

}

price, pages

{

display:block;

text-align:center;

color:"#ff0000";

font-size:25pt;

text-decoration:underline;

}

Page 31: Lab Manual

Output:

Result:

Thus an application using XML-CSS has been executed successfully.

Page 32: Lab Manual

5.EDIFACT to XML

Aim:

To Translate EDIFACT document to XML document

Algorithm:

1.Open notepad and type EDIFACT program.

2.In Stylus Studio browse our EDIFACT program and convert into XML .

3. While saving give it as allfiles.

4.Now EDIFACT has been converted into equivalent XML.

5.Stop the process.

EDIFACT:

UNA:+.? 'UNB+UNOA:3+STYLUSSTUDIO:1+DATADIRECT:1+20051107:1159+6002'UNH+SSDD1+ORDERS:D:03B:UN:EAN008'BGM+220+BKOD99+9'DTM+137:20051107:102'NAD+BY+5412345000176::9'NAD+SU+4012345000094::9'LIN+1+1+0764569104:IB'QTY+1:25'FTX+AFM+1++XPath 2.0 Programmer?'s Reference'LIN+2+1+0764569090:IB'QTY+1:25'FTX+AFM+1++XSLT 2.0 Programmer?'s Reference'LIN+3+1+1861004656:IB'QTY+1:16'FTX+AFM+1++Java Server Programming'LIN+4+1+0596006756:IB'QTY+1:10'FTX+AFM+1++Enterprise Service Bus'UNS+S'CNT+2:4'

Page 33: Lab Manual

UNT+22+SSDD1'UNZ+1+6002'

Output:

Equivalent EDIFACT to XML by stylus studio:

<EDIFACT>    <UNB>        <UNB01>            <UNB0101><!--0001: Syntax identifier-->UNOA<!--UN/ECE level A--></UNB0101>            <UNB0102><!--0002: Syntax version number-->4<!--Version 4--></UNB0102>        </UNB01>        <UNB02>            <UNB0201><!--0004: Interchange sender identification-->STYLUSSTUDIO</UNB0201>            <UNB0202><!--0007: Identification code qualifier-->1<!--DUNS (Data Universal Numbering System)--></UNB0202>        </UNB02>        <UNB03>            <UNB0301><!--0010: Interchange recipient identification-->DATADIRECT</UNB0301>            <UNB0302><!--0007: Identification code qualifier-->1<!--DUNS (Data Universal Numbering System)--></UNB0302>        </UNB03>        <UNB04>            <UNB0401><!--0017: Date-->20051107</UNB0401>            <UNB0402><!--0019: Time-->1159</UNB0402>        </UNB04>        <UNB05><!--0020: INTERCHANGE CONTROL REFERENCE-->6002</UNB05>    </UNB>    <ORDERS>        <UNH>            <UNH01><!--0062: MESSAGE REFERENCE NUMBER-->SSDD1</UNH01>            <UNH02>                <UNH0201><!--0065: Message type-->ORDERS</UNH0201>                <UNH0202><!--0052: Message version number-->D</UNH0202>                <UNH0203><!--0054: Message release number-->03B</UNH0203>                <UNH0204><!--0051: Controlling agency, coded-->UN</UNH0204>                <UNH0205><!--0057: Association assigned code-->EAN008</UNH0205>

Page 34: Lab Manual

            </UNH02>        </UNH>        <BGM>            <BGM01>                <BGM0101><!--1001: Document name code-->220<!--Order--></BGM0101>            </BGM01>            <BGM02>                <BGM0201><!--1004: Document identifier-->BKOD99</BGM0201>            </BGM02>            <BGM03><!--1225: Message function code-->9<!--Original--></BGM03>        </BGM>        <DTM>            <DTM01>                <DTM0101><!--2005: Date or time or period function code qualifier-->137<!--Document/message date/time--></DTM0101>                <DTM0102><!--2380: Date or time or period text-->20051107</DTM0102>                <DTM0103><!--2379: Date or time or period format code-->102<!--CCYYMMDD--></DTM0103>            </DTM01>        </DTM>        <GROUP_2>            <NAD>                <NAD01><!--3035: Party function code qualifier-->BY<!--Buyer--></NAD01>                <NAD02>                    <NAD0201><!--3039: Party identifier-->5412345000176</NAD0201>                    <NAD0203><!--3055: Code list responsible agency code-->9<!--GS1--></NAD0203>                </NAD02>            </NAD>        </GROUP_2>        <GROUP_2>            <NAD>                <NAD01><!--3035: Party function code qualifier-->SU<!--Supplier--></NAD01>                <NAD02>                    <NAD0201><!--3039: Party identifier-->4012345000094</NAD0201>                    <NAD0203><!--3055: Code list responsible agency code-->9<!--GS1--></NAD0203>                </NAD02>            </NAD>        </GROUP_2>        <GROUP_28>

Page 35: Lab Manual

            <LIN>                <LIN01><!--1082: LINE ITEM IDENTIFIER-->1</LIN01>                <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>                <LIN03>                    <LIN0301><!--7140: Item identifier-->0764569104</LIN0301>                    <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>                </LIN03>            </LIN>            <QTY>                <QTY01>                    <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>                    <QTY0102><!--6060: Quantity-->25</QTY0102>                </QTY01>            </QTY>            <FTX>                <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>                <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>                <FTX04>                    <FTX0401><!--4440: Free text-->XPath 2.0 Programmer's Reference</FTX0401>                </FTX04>            </FTX>        </GROUP_28>        <GROUP_28>            <LIN>                <LIN01><!--1082: LINE ITEM IDENTIFIER-->2</LIN01>                <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>                <LIN03>                    <LIN0301><!--7140: Item identifier-->0764569090</LIN0301>                    <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>                </LIN03>            </LIN>            <QTY>                <QTY01>                    <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--

Page 36: Lab Manual

></QTY0101>                    <QTY0102><!--6060: Quantity-->25</QTY0102>                </QTY01>            </QTY>            <FTX>                <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>                <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>                <FTX04>                    <FTX0401><!--4440: Free text-->XSLT 2.0 Programmer's Reference</FTX0401>                </FTX04>            </FTX>        </GROUP_28>        <GROUP_28>            <LIN>                <LIN01><!--1082: LINE ITEM IDENTIFIER-->3</LIN01>                <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>                <LIN03>                    <LIN0301><!--7140: Item identifier-->1861004656</LIN0301>                    <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>                </LIN03>            </LIN>            <QTY>                <QTY01>                    <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>                    <QTY0102><!--6060: Quantity-->16</QTY0102>                </QTY01>            </QTY>            <FTX>                <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>                <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>                <FTX04>                    <FTX0401><!--4440: Free text-->Java Server Programming</FTX0401>                </FTX04>            </FTX>

Page 37: Lab Manual

        </GROUP_28>        <GROUP_28>            <LIN>                <LIN01><!--1082: LINE ITEM IDENTIFIER-->4</LIN01>                <LIN02><!--1229: ACTION REQUEST/NOTIFICATION DESCRIPTION CODE-->1<!--Added--></LIN02>                <LIN03>                    <LIN0301><!--7140: Item identifier-->0596006756</LIN0301>                    <LIN0302><!--7143: Item type identification code-->IB<!--ISBN (International Standard Book Number)--></LIN0302>                </LIN03>            </LIN>            <QTY>                <QTY01>                    <QTY0101><!--6063: Quantity type code qualifier-->1<!--Discrete quantity--></QTY0101>                    <QTY0102><!--6060: Quantity-->10</QTY0102>                </QTY01>            </QTY>            <FTX>                <FTX01><!--4451: TEXT SUBJECT CODE QUALIFIER-->AFM<!--Title--></FTX01>                <FTX02><!--4453: FREE TEXT FUNCTION CODE-->1<!--Text for subsequent use--></FTX02>                <FTX04>                    <FTX0401><!--4440: Free text-->Enterprise Service Bus</FTX0401>                </FTX04>            </FTX>        </GROUP_28>        <UNS>            <UNS01><!--0081: SECTION IDENTIFICATION-->S</UNS01>        </UNS>        <CNT>            <CNT01>                <CNT0101><!--6069: Control total type code qualifier-->2<!--Number of line items in message--></CNT0101>                <CNT0102><!--6066: Control total quantity-->4</CNT0102>            </CNT01>        </CNT>        <UNT>            <UNT01><!--0074: NUMBER OF SEGMENTS IN A MESSAGE-->22</UNT01>

Page 38: Lab Manual

            <UNT02><!--0062: MESSAGE REFERENCE NUMBER-->SSDD1</UNT02>        </UNT>    </ORDERS>    <UNZ>        <UNZ01><!--0036: INTERCHANGE CONTROL COUNT-->1</UNZ01>        <UNZ02><!--0020: INTERCHANGE CONTROL REFERENCE-->6002</UNZ02>    </UNZ></EDIFACT>

Result:

Thus EDIFACT has been translated into XML document.

6.ASP - COMPONENTS

Page 39: Lab Manual

Aim :

To develop a web page using ASP Components.

Algorithm :

1. Start

2. Create a Text file which contains the component to be displayed. The text file may

contain pictures, link to web page etc.

3. Create a Objects in the ASP Components using CreateObject () method

4. The GetAdvertisement method is used to get details from the text file

5. Display the component using response object

6. Test the ASP Page and display the result

7. Stop

Program :

Adrotator.asp:

<html>

<body>

<%

set adrotator=Server.CreateObject("MSWC.AdRotator")

response.write(adrotator.GetAdvertisement("ads.txt"))

%>

</body>

</html>

Ads.txt:

*

w3schools.gif

http://www.w3schools.com/

Visit W3Schools

Page 40: Lab Manual

80

roses.gif

http://www.microsoft.com/

Visit Microsoft

20

Output:

Result:

Thus the web page using ASP Components has been created and verified successfully.

7.ORDER PROCESSING - JSP

Page 41: Lab Manual

Aim :

To develop a server side program using JSP to perform Order Processing

Algorithm :

1. Start

2. Develop a client application using HTML to get the order from the user. The order

should consist of Order No, Date, Quantity and Remark

3. Create a server side page using JSP to read order details

4. JDBC Connection is established to read the order detail at the server side

5. Use getParameter() method to read the client side details

6. Send the response to the request via out object of JSP

7. Stop

PROGRAM :

<html>

<body>

<Form name=f1 action="http://localhost:8080/examples/jsp/sorder.jsp">

<h1><center><font color="blue"> ABC Industries Pvt. Ltd. </font></center></h1>

<hr>

<H2><center> Order Details </h2>

<pre>

Customer Name : <input type=text name="cname">

Order No : <input type=text name="orno">

Order Date : <input type=text name="ordate">

Page 42: Lab Manual

Item name : <input type=radio name="item" value="Soap" checked> Soap <input type=radio name="item" value="Powder"> Powder

Quantity : <input type=text name="quan">

Remarks : <input type=text name="remarks">

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

</form>

</center>

</html>

Ordersave.jsp

<html>

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

<%

try

{

Connection c=null;

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

c=DriverManager.getConnection("jdbc:odbc:nandha");

Statement s;

s=c.createStatement();

String cname=request.getParameter("cname");

String orno=request.getParameter("orno");

String ordate=request.getParameter("ordate");

Page 43: Lab Manual

String item=request.getParameter("item");

int quan=Integer.parseInt(request.getParameter("quan"));

String remarks= request.getParameter("remarks");

String q="insert into order values('"+cname+"','"+orno+"','"+ordate+"',"+quan+",'"+item+"','"+remarks+"')";

s.executeUpdate(q);

out.print("<h2>Inserted<h2>");

}

catch(Exception e)

{

out.print(e);

}

%>

</html>

Output:

Page 44: Lab Manual
Page 45: Lab Manual

Result:

Thus the Order Processing using JSP has been executed and verified successfully.

Page 46: Lab Manual

8.ACCESS STUDENT INFORMATION USING SERVLET

Aim:

To create server side page to display results of a student using Servlet

Algorithm:

1. Start

2. Develop client side application using HTML

3. Enter the register number at the client side HTML From

4. Invoke the servlet form the client side application

5. Develop a Http base servlet to display student exam results

6. Read the register from the request object of servlet interface

7. Check the availability of the register in the data base using JDBC Connectivity

8. If the register number is available retrieve the results using executeQuery() method.

9. Send back the result to the client via response object

10. Stop

Client side program:

<HTML>

<HEAD><TITLE> Results of a student</title></head>

<body>

<center><h3> University Examination Results July 2008 </h3></center>

<form method = "GET" action="http://localhost:8080/examples/servlet/DisplayResult">

Enter Register Number : <input type ="text" name="regno" value= " ">

<input type ="submit" value="GetResult">

</form>

</body>

</html>

Page 47: Lab Manual

Servlet Program:

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

import java.sql.*;

public class DisplayResult extends HttpServlet {

Connection con;

Statement st;

ResultSet rs;

public void init()

{

try

{

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

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

System.out.println("Connection Created");

st= con.createStatement();

}

catch(Exception e)

{

Page 48: Lab Manual

System.out.println(e);

}

}

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws IOException, ServletException

{

response.setContentType("text/html");

PrintWriter out = response.getWriter();

ResultSet rs;

String qr="";

try

{

out.println("<html>");

out.println("<body>");

out.println("<head>");

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

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

out.println("<body>");

out.print("<h3>Results of " + request.getParameter("regno")+"</H3>");

rs=st.executeQuery("select * from rtable where rno='"+request.getParameter("regno")+"'");

out.println("<h3><pre> <FONT COLOR='BLUE'> Subject Name Grade </FONT></H3></pre>");

if(rs.next())

{

Page 49: Lab Manual

out.print("<h4> Database Technology : " + rs.getString(2)+"</h4>");

out.print("<h4> Compiler Design : " + rs.getString(3)+"</h4>");

out.print("<h4> Object Oriented Analysis and Design ; " + rs.getString(4)+"</h4>");

out.print("<h4> Web Technology : " + rs.getString(5)+"</h4>");

out.print("<h4> Information Security : " + rs.getString(6)+"</h4>");

out.print("<h4> High Speed Networks : " + rs.getString(7)+"</h4>");

}

else

{

out.println("<h1>Invalid Register Number</h1>");

} }

catch(Exception e)

{

out.println("<h1>"+qr+"<br>"+e+"</h1>");

}

finally

{

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

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

out.close();

}

}

}

Page 50: Lab Manual

Output:

Client side Application

Page 51: Lab Manual

Servlet Output:

Page 52: Lab Manual

Result:

Thus a server side page to display results of a student using Servlet created successfully.

Page 53: Lab Manual

9..NET PLATFORM

Aim:

To create an application using .Net Platform.

Algorithm:

1.Programs -- Microsoft visual studio--- file---- new---website.

2.choose template,location,language and click OK.

3.Website will appear which consists of toolbox.

4.Design our application with necessary toolboxes.

5.Double click the items and write the codings.

6.Build the application.

Home.aspx

Partial Class home

Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Literal1.Text = "<marquee direction=Right> Welcome to Sasurie College of Engineering</marquee>"

End Sub

Page 54: Lab Manual

End Class

Login.aspx

Imports System.Data.SqlClient

Imports System.Data

Partial Class _Default

Inherits System.Web.UI.Page

Dim con As New SqlConnection()

Dim cmd As New SqlCommand()

Dim dr As SqlDataReader

Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate

con.ConnectionString = "Data Source=.;Initial Catalog=renuga;Integrated Security=True"

con.Open()

cmd.Connection = con

cmd.CommandText = "Select * from login"

dr = cmd.ExecuteReader()

While dr.Read()

If dr(0).ToString() = Login1.UserName And dr(1).ToString() = Login1.Password Then

Response.Redirect("default.aspx")

End If

End While

con.Close()

End Sub

Page 55: Lab Manual

End Class

Signup.aspx

Imports System.Data.SqlClient

Imports System.Data

Partial Class Signup

Inherits System.Web.UI.Page

Dim con As New SqlConnection()

Dim cmd As New SqlCommand()

Dim dr As SqlDataReader

Dim j As Integer

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

con.ConnectionString = "Data source=.;initial catalog=renuga;integrated security=true;"

con.Open()

cmd.Connection = con

cmd.CommandText = "select * from login"

dr = cmd.ExecuteReader()

While (dr.Read())

If TextBox1.Text = dr(0).ToString() And TextBox2.Text = dr(1).ToString() Then

j = 1

End If

End While

Page 56: Lab Manual

con.Close()

If j = 1 Then

MsgBox("Already exists")

Else

con.Open()

cmd.Connection = con

cmd.CommandText = "insert into login values('" + TextBox1.Text + "','" + TextBox2.Text + "' , '" + TextBox4.Text + "','" + DropDownList1.Text + "'," + TextBox3.Text + ", '" + DropDownList2.Text + "','" + TextBox5.Text + "' )"

cmd.ExecuteNonQuery()

con.Close()

MsgBox("Inserted")

Response.Redirect("default.aspx")

End If

End Sub

End Class

Placement.aspx

Partial Class placement

Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

If CheckBox1.Checked = True Then

Response.Redirect("hcl.aspx")

Page 57: Lab Manual

ElseIf CheckBox2.Checked = True Then

Response.Redirect("infosys.aspx")

End If

End Sub

End Class

Library.aspx

Partial Class library

Inherits System.Web.UI.Page

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

If DropDownList1.SelectedItem.ToString = "IT" Then

Response.Redirect("it.aspx")

elseif DropDownList1.SelectedItem.ToString ="CSE" Then

Response.Redirect("cse.aspx")

ElseIf DropDownList1.SelectedItem.ToString = "EEE" Then

Response.Redirect("eee.aspx")

ElseIf DropDownList1.SelectedItem.ToString = "ECE" Then

Response.Redirect("ece.aspx")

End If

End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Not Page.IsPostBack Then

DropDownList1.Items.Add("select")

Page 58: Lab Manual

DropDownList1.Items.Add("IT")

DropDownList1.Items.Add("CSE")

DropDownList1.Items.Add("EEE")

DropDownList1.Items.Add("ECE")

End If

End Sub

End Class

IT.aspx

Imports System.Data.SqlClient

Imports System.Data

Partial Class it

Inherits System.Web.UI.Page

Dim con As New SqlConnection()

Dim cmd As New SqlCommand()

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

con.ConnectionString = "Data source=.;initial catalog=renuga;integrated security=true;"

con.Open()

cmd.Connection = con

cmd.CommandText = "insert into it values('" + TextBox1.Text + "','" + TextBox2.Text + "' , '" + TextBox3.Text + "')"

cmd.ExecuteNonQuery()

MsgBox("Inserted")

con.Close()

Page 59: Lab Manual

End Sub

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

con.ConnectionString = "Data source=.;initial catalog=renuga;integrated security=true;"

con.Open()

cmd.Connection = con

cmd.CommandText = "delete from it where BookName='" + TextBox1.Text + "' "

cmd.ExecuteNonQuery()

MsgBox("Deletedted")

con.Close()

End Sub

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click

Response.Redirect("thank.aspx")

End Sub

End Class

Page 60: Lab Manual

Output:

Page 61: Lab Manual
Page 62: Lab Manual
Page 63: Lab Manual
Page 64: Lab Manual
Page 65: Lab Manual
Page 66: Lab Manual
Page 67: Lab Manual
Page 68: Lab Manual
Page 69: Lab Manual
Page 70: Lab Manual
Page 71: Lab Manual

Result:

Thus an application using .NET platform has been created successfully.

Page 72: Lab Manual

10.C# .NET PLATFORM

Aim:

To create an application using C# in .NET Platform.

Algorithm:

1.From the File Menu select New--project.

2. Select template as windows application and project type as Visual C#.

3.Give the name and click OK.

4. Windows application form will appear.

5.Design the form using Toolbox and write the codings.

6. Build the application.

Program:

Addition:

namespace renuga

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

Page 73: Lab Manual

private void button1_Click(object sender, EventArgs e)

{

int firstnumber;

int secondnumber;

int answer;

firstnumber = 6;

secondnumber = 6;

answer = firstnumber + secondnumber;

MessageBox.Show(answer.ToString());

}

}

}

Calculator:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace calculator

{

public partial class Form1 : Form

Page 74: Lab Manual

{

public Form1()

{

InitializeComponent();

}

double total1 = 0;

double total2 = 0;

private void button1_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button1.Text;

}

private void button11_Click(object sender, EventArgs e)

{

total1 = total1 + double.Parse(textBox1.Text);

textBox1.Clear();

}

private void button12_Click(object sender, EventArgs e)

{

total2 = total1 + double.Parse(textBox1.Text);

textBox1.Text = total2.ToString();

total1 = 0;

}

Page 75: Lab Manual

private void button3_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button3.Text;

}

private void button2_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button2.Text;

}

private void button4_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button4.Text;

}

private void button5_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button5.Text;

}

private void button6_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button6.Text;

}

Page 76: Lab Manual

private void button7_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button7.Text;

}

private void button8_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button8.Text;

}

private void button9_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button9.Text;

}

private void button10_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button10.Text;

}

private void button14_Click(object sender, EventArgs e)

{

textBox1.Clear();

}

Page 77: Lab Manual

private void button13_Click(object sender, EventArgs e)

{

textBox1.Text = textBox1.Text + button13.Text;

}

}

}

Output:

Page 78: Lab Manual

Result:

Thus an application using C# .NET has been executed successfully.


Recommended