You are on page 1of 76

LIST OF EXPERIMENTS

PAGE NO

S.NO

DATE

NAME OF THE EXPERIEMENTS STUDY OF BASICS AND TAGS OF HTML

SIGNATURE

1 2 a. b. 3. 4. 5. 6. 7.

IMAGE MAPPING CREATION OF MENU USING EMBEDDED CSS CREATION OF MENU USING EXTERNAL CSS EXERCISE USING JAVA SCRIPT CLIENT SIDE SCRIPT-FORM VALIDATION IN DHTML COLOR PALETTE WITH MATRIX BUTTONS AND CHECK BOX MAKING COLOR SLIDESS ON THE APPLET TO INVOKE SERVLETS FROM HTML FORMS CONDUCTING ONLINE EXAMINATION USING SERVLET DISPLAYING STUDENT MARKLIST USING JSP DOCUMENT OBJECT MODEL PROGRAMS USING XML- SCHEMA

8 a. b. 9. 10. a. b. 11. 12.

PROGRAMS USING -XSLT/XSL PROGRAMS USING AJAX TRAVEL AGENT AND AIRLINE SERVICE USING JSP AND DATABASES

INTRODUCTION TO WEB TECHNOLOGIES


Internet: The Internet is a global system of interconnected computer networks that use the standard Internet Protocol Suite (TCP/IP) to serve billions of users worldwide. It is a network of networks that consists of millions of private, public, academic, business, and government networks, of local to global scope, that are linked by a broad array of electronic and optical networking technologies. The Internet carries a vast range of information resources and services, such as the inter-linked hypertext documents of the World Wide Web (WWW) and the infrastructure to support electronic mail. There are many Web technologies, from simple to complex of which some of them are explained in brief below Markup Languages: Markup is used to in text and word processing documents to describe how a document should look when displayed or printed. The Internet uses markup to define how Web pages should look when displayed in a browser or to define the data contained within a Web document. There are many different types of markup languages. For example, Rich Text Formatting (RTF) is a markup language that word processors use. HTML: HTML stands for Hypertext Markup Language. HTML is the primary markup language that is used for Web pages. HTML tells the browser what to display on a page. For example, it specifies text, images, and other objects and can also specify the appearance of text, such as bold or italic text. The World Wide Web Consortium (W3C) defines the specification for HTML. The current versions of HTML are HTML 4.01 and XHTML 1.1. DHTML stands for Dynamic HTML. DHTML combines cascading style sheets (CSS) and scripting to create animated Web pages and page elements that respond to user interaction.

CSS: CSS stands for cascading style sheets. Cascading style sheets provide the ability to change the appearance of text (such as fonts, colors, spacing) on Web pages. Using CSS, you can also position elements on the page, make certain elements hidden, or change the appearance of the browser, such as changing the color of scroll bars in Microsoft Internet Explorer. Cascading style sheets can be used similar to FrontPage Themes. For example, you can apply a cascading style sheet across all the pages in a Web site to give the site a uniform look and feel. Then all you need to do is to change the CSS style formatting in a single file to change the look and feel of an entire Web site.

XML: XML stands for Extensible Markup Language. Similar to HTML, XML is a markup language designed for the Internet. However, unlike HTML, which was designed to define formatting of Web pages, XML was designed to describe data. You can use XML to develop custom markup languages. XSLT: XSLT is an abbreviation for XSL Transformations. XSLT uses the Extensible Stylesheet Language (XSL), which you use to define the appearance of an XML document or change an XML document into another kind of documentXML, HTML, or another markup language format. As with other Web markup languages, the W3C defines the specifications for XSL and XSLT. Programming Languages and Technologies: Programming languages enable you to create custom applications and add functionality that is not already part of an application. On the Internet, programming languages enable you to create visual animation, respond to user actions, validate forms, interact with databases, and provide e-commerce solutions. Programming languages come in two flavors: interpreted and compiled. Most scripting languages are interpreted, which means that you write the code and the browser or server understands what to do with it. Compiled languages require an added step that translates the code into machine language code, which is then stored in a separate file with either a .dll or .exe file name extension. Compiled languages are generally used for server-side processing for Web applications, such as form processing, that require interaction with databases or other server processes. JavaScript (JScript/ECMAScript): JavaScript is an interpreted scripting language commonly used on the Internet for creating Web pages that respond to user actions, such as when a user moves a mouse pointer over an image or clicks a form button. Combined with HTML and CSS, JavaScript allows you to create Dynamic HTML pages. JavaScript is generally used for client-side scripting; as a result, users can easily view JavaScript code along with the HTML code in a page. Although it may be used for serverIT2357 WEB TECHNOLOGY LAB MANUAL Page 8 side scripting, JavaScript works best for visual animation (such as changing an image when a user moves the mouse pointer over it) or for validating form fields. VBScript: VBScript is an interpreted scripting language that is a subset of Microsoft Visual Basic. As a result, the structure and syntax are similar to Visual Basic, making VBScript an easy scripting language to learn.

Although VBScript can be used for client-side scripting in Internet Explorer, most other browsers do not include a VBScript interpreter. Therefore, VBScript is most commonly used in server-side scripting for Web pages that use classic ASP.

PHP: PHP is an interpreted scripting language that is used as an alternative to ASP on UNIXbased servers. PHP is commonly used to access databases and provide server-side form and e-commerce processing. As with ASP code, PHP code is contained within the body of an HTML page. PHP code typically runs on Linux-based and UNIX-based Web servers, and can run on Windows-based servers with an installed interpreter. Java: Java is a compiled object-oriented programming language that was designed for use on the Internet. In 1995, Sun Microsystems designed the Java programming language and introduced it to Web developers as a way to include animation and dynamic elements in Web pages. Java syntax is similar to C++ but is considered easier to learn. Java code is generally used for server-side processing but can also be run on the client by using the Java virtual machine. ActiveX Controls: ActiveX controls require that a compiled file be downloaded and installed on the client machine. ActiveX controls can be installed and run only on Windows-based computers, and Internet Explorer is the only browser that natively supports ActiveX controls. In addition, because ActiveX controls are installed on the client computer, browsers that support ActiveX controls generally allow users to accept or deny installing ActiveX controls, which means that if an ActiveX control is not installed on a client machine, the page that contains it often does not function as expected. Therefore, ActiveX controls are best used in a controlled environment, such as an intranet site, in which Internet Explorer is the standard browser in use. ASP: ASP is an abbreviation for Active Server Pages. ASP is a server-side scripting technology that you can use to create dynamic Web pages. ASP code is generally embedded in the HTML within a page, and HTML pages that contain ASP have an .asp file name extension; however, because processing is done on the server, the ASP code is not sent to the browser, and visitors to your site never see your ASP code. Client computers receive only the resulting HTML. Web Servers and Server Products:

A Web server is the computer on which you host your Web site. It is connected directly to

the Internet and sends hosted Web pages to the client using the Hypertext Transfer Protocol (HTTP). If you host your FrontPage site through an Internet service provider (ISP), Web presence provider (WPP), or Web host provider (WHP), you may have access to several different types of Web servers. The most common Web servers available are Windows-based servers running Microsoft Internet Information Services (IIS) and UNIXbased servers running Apache. Internet Information Services: Internet Information Services (IIS) is a Web server designed to process HTTP and FTP requests on Windows operating systems. IIS is part of the Microsoft Windows NT, Microsoft Windows 2000, and Microsoft Windows 2003 operating systems, and you can install and enable IIS on Windows XP-based computers for testing ASP and ASP.NET applications. Apache: Apache is an open-source Web server that runs on UNIX operating systems, such as Solaris and Linux, but can also be installed on Windows-based servers. Apache Web servers provide simple HTTP processing. Databases: Databases allow you to store information for easy retrieval. On the Internet, databases are used to store users' logon information, product information, and customers' orders, among other things. There are almost as many database products as there are reasons and ways to use databases. Access SQL Server MySQL Oracle Database

BASICS OF HTML
HTML: HTML is a language for describing web pages. HTML stands for Hyper Text Markup Language HTML is not a programming language, it is a markup language A markup language is a set of markup tags HTML uses markup tags to describe web pages HTML Tags: HTML markup tags are usually called HTML tags HTML tags are keywords surrounded by angle brackets like <html> HTML tags normally come in pairs like <b> and </b> The first tag in a pair is the start tag, the second tag is the end tag Start and end tags are also called opening tags and closing tags HTML Documents = Web Pages: HTML documents describe web pages HTML documents contain HTML tags and plain text HTML documents are also called web pages The purpose of a web browser (like Internet Explorer or Firefox) is to read HTML documents and display them as web pages. The browser does not display the HTML tags, but uses the tags to interpret the content of the page: <html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>

Explanation: The text between <html> and </html> describes the web page The text between <body> and </body> is the visible page content The text between <h1> and </h1> is displayed as a heading The text between <p> and </p> is displayed as a paragraph

HTML TAGS AND DESCRIPTION


LIST OF HTML TAGS ORDERED ALPHABETICALLY

TAG

DESCRIPTION

DTD

<!--...--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area /> <b> <base /> <basefont /> <bdo> <big> <blockquote> <body> <br /> <button> <caption> <center> <cite> <code> <col /> <colgroup> <dd> <del> <dfn> <div> <dl> <dt> <em> <fieldset> <font> <form> <frame /> <frameset> <h1>to<h6> <head> <hr /> <html> <i> <iframe>

Defines a comment Defines the document type Defines an anchor Defines an abbreviation Defines an acronym Defines contact information for the author/owner of a document Deprecated. Defines an embedded applet Defines an area inside an image-map Defines bold text Defines a default address or a default target for all links on a page Deprecated. Defines a default font, color, or size for the text in a page Defines the text direction Defines big text Defines a long quotation Defines the document's body Defines a single line break Defines a push button Defines a table caption Deprecated. Defines centered text Defines a citation Defines computer code text Defines attribute values for one or more columns in a table Defines a group of columns in a table for formatting Defines a description of a term in a definition list Defines deleted text Defines a definition term Defines a section in a document Defines a definition list Defines a term (an item) in a definition list Defines emphasized text Defines a border around elements in a form Deprecated. Defines font, color, and size for text Defines an HTML form for user input Defines a window (a frame) in a frameset Defines a set of frames Defines HTML headings Defines information about the document Defines a horizontal line Defines an HTML document Defines italic text Defines an inline frame

STF STF STF STF STF STF TF STF STF STF TF STF STF STF STF STF STF STF TF STF STF STF STF STF STF STF STF STF STF STF STF TF STF F F STF STF STF STF STF TF

TAG <img /> <input /> <ins> <isindex> <kbd> <label> <legend> <li> <link /> <map> <menu> <meta /> <noframes> <noscript> <object> <ol> <optgroup> <option> <p> <param /> <pre> <q> <s> <samp> <script> <select> <small> <span> <strike> <strong> <style> <sub> <sup> <table> <tbody> <td> <textarea> <tfoot> <th> <thead> <title> <tr> <tt>

DESCRIPTION Defines an image Defines an input control Defines inserted text Deprecated. Defines a searchable index related to a document Defines keyboard text Defines a label for an input element Defines a caption for a fieldset element Defines a list item Defines the relationship between a document and an external resource Defines an image-map Deprecated. Defines a menu list Defines metadata about an HTML document Defines an alternate content for users that do not support frames Defines an alternate content for users that do not support clientside script Defines an embedded object Defines an ordered list Defines a group of related options in a select list Defines an option in a select list Defines a paragraph Defines a parameter for an object Defines preformatted text Defines a short quotation Deprecated. Defines strikethrough text Defines sample computer code Defines a client-side script Defines a select list (drop-down list) Defines small text Defines a section in a document Deprecated. Defines strikethrough text Defines strong text Defines style information for a document Defines subscripted text Defines superscripted text Defines a table Groups the body content in a table Defines a cell in a table Defines a multi-line text input control Groups the footer content in a table Defines a header cell in a table Groups the header content in a table Defines the title of a document Defines a row in a table Defines teletype text

DTD STF STF STF TF STF STF STF STF STF STF TF STF TF STF STF STF STF STF STF STF STF STF TF STF STF STF STF STF TF STF STF STF STF STF STF STF STF STF STF STF STF STF STF

<u> <ul> <var> <xmp>

Deprecated. Defines underlined text Defines an unordered list Defines a variable part of a text Deprecated. Defines preformatted text

TF STF STF STF

S=Strict, T=Transitional, and F=Frameset

1-IMAGE MAPPING
AIM: To write a program in HTML to demonstrate the Image Map

ALGORITHM :

1. Create an html page to load the India map. 2. Create four hot spots using coordinates in four major cities. 3. Give area link to those four major cities. 4. If any area is clicked then that area information should be shown. 5. From this page give link to home page.

PROGRAM:
INDIA.HTML: <html> <head> <title>Home - States of India!!</title> </head> <body> <img align="right" src = "India Map.gif" usemap="#india"> <map name="india"> <area shape="circle" coords="274,745,20" href="TAMILNADU.html"> <area shape="circle" coords="325,718,3" href="ANDHRAPRADESH.html"> <area shape="rect" coords="193,604,248,679" href="KARNATAKA.html"> </map> <h1><u>Republic of India</u></h1> <img src="flag.jpg"> <p>India is the Seventh Largest country in the world by geographical area, the second most populous country with over 1.2 billion people, and the most populous democracy in the world. India is a federal constitutional Republic with a parliamentry democracy consisting of 28 states and 7 Union Terrirories.</p> <h2>Features</h2> <ul> <li><b>Population</b> - 1,028,610,328 (2001 census). <li><b>Capital </b> - New Delhi <li><b>Largest City </b> - Mumbai <li><b>Currency </b> - Indian Rupee. <li><b>Time Format</b> - IST (UTC + 5:30) <li><b>National Sport </b> - Hockey <li><b>Current PM </b> - Manmohan Singh <li><b>Current President </b> - Prathiba Patil </ul> <h2><b>To view the details of states please click on the specified area in the map!!</b></h2> </body> </html> TAMILNADU.HTML: <html> <head><title>Tamil Nadu - India</title></head> <body> (Data as on 11.004.2011) <h1>Tamil Nadu</h1> <h3>is one of the 28 states of India. Its capital and largest city is Chennai. Tamil Nadu lies in the southernmost part of the Indian Peninsula and is bordered by the States of Puducherry, Kerala, Karnataka and Andhra Pradesh. It is bound by the Eastern Ghats in the north, the Nilgiri, the Anamalai Hills, and Palakkad on the west, by the Bay of Bengal in the east, the Gulf of Mannar, the Palk Strait in the south east, and by the Indian Ocean in the south.</h3>

<h3> <ol> <li><i>Districts </i> - 32 <li><i>Capital City </i> - Chennai <li><i>Largest City </i> - Chennai <li><i>Governor </i> - Surjit Singh Barnala <li><i>Chief Minister</i> - M. Karunanidhi <li><i>Deputy Cheif Minister</i> - M.Stalin <li><i>Popultation </i> - 66,396,000 <li><i>Dance </i> - Bharthanatyam <li><i>Festivals</i> - Pongal, Alanganallur Jallikattu etc., <li><i>Cuisine </i> - Dosai, Adai, Idly, Vadai, Pongal, Appam(Aappam), Paniyaram, Puttu(Pittu), Uppumavu(Uppuma), Santhakai(Noodles), Idiyappam and Uthappam. <li><i>Tourist spots </i> <ul> <li>Mamallapuram (Shore Temple) <li>Brihadeeshwara Temple <li>Ooty <li>Kodaikanal. <li>Kanyakumari. (Thiruvalluvar statue etc.,) <li>Marina Beach(chennai) <li>Madurai Meenakshi Amman Temple. <li>Thanjavur. <li>Velankanni. <li>Rameswaram. </ul> </ol> </body> </html> KARNATAKA.HTML: <html> <head> <title>Karnataka - India</title> </head> <body> (Data as on 16.12.2010) <h1>Karnataka</h1> <h3> <ol> <li><i>Districts </i> - 30 <li><i>Capital City </i> - Bangalore <li><i>Largest City </i> - Bangalore <li><i>Governor </i> - Hansraj Bhardwaj <li><i>Chief Minister</i> - B. S. Yeddyurappa <li><i>Popultation </i> - 52,850,562

<li><i>Tourist spots </i> - Gol Gumbaz, Mysore Palace, Keshava Temple etc., </ol> </body> </html> ANDHRAPRADESH.HTML:

<html> <head> <title>Andhra Pradesh - India</title> </head> <body> (Data as on 16.12.2010) <h1>Andhra Pradesh</h1> <h3>A.P., is a state situated on the southeastern coast of India. It is India's fourth largest state by area and fifth largest by population.</h3> <h3> <ul> <li><i>Districts </i> - 23 <li><i>Capital City </i> - Hyderabad <li><i>Largest City </i> - Hyderabad <li><i>Governor </i> - E. S. L. Narasimhan <li><i>Chief Minister</i> - N. Kiran Kumar Reddy <li><i>Popultation </i> - 76,210,007 <li><i>Tourist spots </i> - Tirumala Tirupati, Charminar, Golconda Fort, Chandragiri Fort, Chowmahalla Palace, Falaknuma Palace etc., </ul> </body> </html>

OUTPUT:

RESULT: Thus the program has been executed successfully.

2-a.CREATION OF MENU USING EMBEDED CSS


AIM: To create a horizontal menu on the webpage using embedded CSS.

ALGORITHM: Create a HTML program. Use <style> tag to import CSS. Define required styles and access it on to body of the program.

PROGRAM: <html> <head> <style type="text/css"> #nav { padding: 0; } #nav li { display: inline; height: 100; font: 1.7em; margin-right:1px; } #nav li a { font-family: helvetica; text-decoration: none; float: left; padding: 10px; background-color:pink; color: #0000FF ; }

#nav li a:hover

{ background-color:lime; padding-bottom:12px; border-bottom:2px; color: #38c; } </style> </head> <body bgcolor=#1E90FF> <ul id="nav" align="center"> <li><a href="#">Home</a></li> <li><a href="#">Products</a></li> <li><a href="#">Registration</a></li> <li><a href="#">Services</a></li> <li><a href="#">Contact us</a></li> </ul> </body> </html> OUTPUT:

RESULT:

Thus the above program has been executed successfully.

2-b.CREATION OF MENU USING EXTERNAL CSS


AIM: To create a vertical menu on the webpage using external CSS.

AlGORITHM: Create a HTML program. Create a CSS file separately to define styles to different web page. Give link to access CSS file from HTML program. Save the file and open this file on browser web browser.

PROGRAM: Extstyle.css: body { background: url(bg.gif) repeat-y center top; } #nav { padding: 0; width: 250px; } #nav li { height: 50; font: 1.7em; margin-right:1px; } #nav li a { font-family: helvetica; text-decoration: none; float: left; padding: 10px; background-color:#81ac00; color: black;

width: 250px; height: 50; } #nav li a:hover { background-color: #c3e0f0; padding-bottom:10px; border-bottom:2px; background-color:black; color: white; height: 50; }

Vert_menu.html:

<html> <head> <link rel="stylesheet" href="Extstyle.css" type="text/css"></link> </head> <body> <ul id="nav" > <li><a href="#">Home</a></li> <li><a href="#">Marks Details</a></li> <li><a href="#">Attendance Details</a></li> <li><a href="#">Dues Details</a></li> <li><a href="#">Contact us</a></li> </ul> </body> </html>

OUTPUT:

RESULT: Thus the above program has been executed successfully.

3.PROGRAMS USING JAVA SCRIPT


AIM: To write a java script programs to implement the Alert box and Date.

ALGORITHM: Create a HTML program. Use <script> tag to import java script. Define required operations. Save the file and open this file on the browser web-browser.

ALERT BOX USING JAVASCRIPT:

<html> <head> <script type="text/javascript"> function show_alert() { alert("Hello! I am an alert box!"); } </script> </head> <body> <input type="button" onclick="show_alert()" value="Show alert box" /> </body> </html> : OUTPUT

DATE FUNCTIONS IN JAVASCRIPT:

<html> <body> <script type="text/javascript"> var d=new Date(); document.write(d); </script> </body> </html> OUTPUT:

Sat Nov 06 2010 19:58:39 GMT+0530 (India Standard Time)

RESULT:
Thus the above program has been executed successfully.

4. CLIENT SIDE SCRIPT-FORM VALIDATION IN DHTML


AIM: To create a web page with form controls and validate username, password, email, phone number and isEmpty, using java script. ALGORITHM:

1. 2. 3. 4. 5.

Create a HTML file with form controls In Script tag, set the attribute src="validationscript.js" In form tag, set the attribute onsubmit="return validateFormOnSubmit(this)" If the validation is completed the open the test.html file. Validate the username, password, email, phone number, and isEmpty using java script in validationscript.js file

PROGRAM: HTML Program: <html> <head> <title>Form Validation</title> <script language="JavaScript" src="validationscript.js" type="text/javascript"></script> </head> <body> <h1>Form Validation</h1> <form name="demo" onsubmit="return validateFormOnSubmit(this)" action="test.htm"> <table summary="Demonstration form"> <tbody> <tr> <td><label for="username">Your user name:</label></td> <td><input name="username" size="35" maxlength="50" type="text"></td> </tr> <tr> <td><label for="pwd">Your password</label></td> <td><input name="pwd" size="35" maxlength="25" type="password"></td> </tr> <tr> <td><label for="email">Your email:</label></td> <td><input name="email" size="35" maxlength="30" type="text"></td> </tr>

<tr> <td><label for="phone">Your telephone number:</label></td> <td><input name="phone" size="35" maxlength="25" type="text"></td> </tr> <tr> <td> <label for="from">Where are you :</label></td> <td><input name="from" size="35" maxlength="50" type="text"></td> </tr> <tr> <td>&nbsp;</td> <td><input name="Submit" value="Send" type="submit" ></td> <td>&nbsp;</td> </tr> </tbody> </table> </form> </body> </html> JAVA SCRIPT: validationscript.js function validateFormOnSubmit(theForm) { var reason = ""; reason += validateUsername(theForm.username); reason += validatePassword(theForm.pwd); reason += validateEmail(theForm.email); reason += validatePhone(theForm.phone); reason += validateEmpty(theForm.from); if (reason != "") { alert("Some fields need correction:\n" + reason); return false; } return true; } function validateEmpty(fld) { var error = ""; if (fld.value.length == 0) { fld.style.background = 'Yellow'; error = "The required field has not been filled in.\n" } else { fld.style.background = 'White'; } return error; }

function validateUsername(fld) { var error = ""; var illegalChars = /\W/; // allow letters, numbers, and underscores if (fld.value == "") { fld.style.background = 'Yellow'; error = "You didn't enter a username.\n"; } else if ((fld.value.length < 5) || (fld.value.length > 15)) { fld.style.background = 'Yellow'; error = "The username is the wrong length.\n"; } else if (illegalChars.test(fld.value)) { fld.style.background = 'Yellow'; error = "The username contains illegal characters.\n"; } else { fld.style.background = 'White'; } return error; } function validatePassword(fld) { var error = ""; var illegalChars = /[\W_]/; // allow only letters and numbers if (fld.value == "") { fld.style.background = 'Yellow'; error = "You didn't enter a password.\n"; } else if ((fld.value.length < 7) || (fld.value.length > 15)) { error = "The password is the wrong length. \n"; fld.style.background = 'Yellow'; } else if (illegalChars.test(fld.value)) { error = "The password contains illegal characters.\n"; fld.style.background = 'Yellow'; } else if (!((fld.value.search(/(a-z)+/)) && (fld.value.search(/(0-9)+/)))) { error = "The password must contain at least one numeral.\n"; fld.style.background = 'Yellow'; } else { fld.style.background = 'White'; } return error; } function trim(s) { return s.replace(/^\s+|\s+$/, ''); } function validateEmail(fld) { var error=""; var tfld = trim(fld.value);

// value of field with whitespace trimmed off

var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ; var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ; if (fld.value == "") { fld.style.background = 'Yellow'; error = "You didn't enter an email address.\n"; } else if (!emailFilter.test(tfld)) { //test email for illegal characters fld.style.background = 'Yellow'; error = "Please enter a valid email address.\n"; } else if (fld.value.match(illegalChars)) { fld.style.background = 'Yellow'; error = "The email address contains illegal characters.\n"; } else { fld.style.background = 'White'; } return error; } function validatePhone(fld) { var error = ""; var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, ''); if (fld.value == "") { error = "You didn't enter a phone number.\n"; fld.style.background = 'Yellow'; } else if (isNaN(parseInt(stripped))) { error = "The phone number contains illegal characters.\n"; fld.style.background = 'Yellow'; } else if (!(stripped.length == 10)) { error = "The phone number is the wrong length. Make sure you included an area code.\n"; fld.style.background = 'Yellow'; } return error; }

OUTPUT:

Result: Thus the program to validate the html form controls using java script was completed.

5-COLOR PALETTE WITH MATRIX BUTTONS AND CHECK BOXES


AIM: To demonstrate the Text Formatting options of AWT controls in Java Applets

ALGORITHM:

Create the TextArea Controls using the TextArea class Create the Array of Buttons Using the Button class Using the ActionListener event handler fire the event for the Button Control Using the setForeground() and setBackground() method modify the Foreground and Background color of the TextArea, with the object of the color class as its parameter Add the TextArea to the Applet window Compile the code View it using Applet Viewer. Stop the program.

PROGRAM: /* <applet code="palette1.class" height=600 width=600> </applet> */ import java.awt.*; import java.awt.event.*; import java.applet.*; public class palette1 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++) { 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()); }

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; } }

PALETTE.HTML: <html> <title>Applet Example</title> <body bgcolor="black" > <h1 align="center"> <applet code="palette1.class" height=500 width=800> </h1> </applet></body> </html>

OUTPUT:

RESULT: Thus the above program has been executed successfully.

6-MAKING COLOR SLIDES ON THE APPLET


AIM: To write a Java Applet program for making color slides on the applet.

ALGORITHM: Import required java packages. Embbed HTML code with JAVA code. Use AWT components to define GUI. Save and execute the program.

PROGRAM: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.JScrollBar; import java.applet.*; /*<applet code="Slide.class" height=300 width=300> </applet>*/ public class Slide extends Applet { JScrollBar scroll; JScrollBar scroll1; JScrollBar scroll2; JLabel lbl1; JLabel lbl2; JLabel lbl3; JPanel panel1; JPanel panel2; JPanel panel3; JPanel panel; int redness=0; int greenness=0; int blueness=0; Color co; public void init() { scroll= new JScrollBar(JScrollBar.HORIZONTAL); scroll.setMaximum(265); scroll.addAdjustmentListener(new MyAdjustmentListener()); scroll1= new JScrollBar(JScrollBar.HORIZONTAL);

scroll1.setMaximum(265); scroll1.addAdjustmentListener(new MyAdjustmentListener()); scroll2= new JScrollBar(JScrollBar.HORIZONTAL); scroll2.setMaximum(265); scroll2.addAdjustmentListener(new MyAdjustmentListener()); lbl1 = new JLabel("Red"); lbl2 = new JLabel("Green"); lbl3 = new JLabel("Blue"); panel = new JPanel(); panel1 = new JPanel(); panel2 = new JPanel(); panel3 = new JPanel(); panel1.setLayout(new BorderLayout()); panel2.setLayout(new BorderLayout()); panel3.setLayout(new BorderLayout()); panel1.add(lbl1,BorderLayout.WEST); panel1.add(scroll); panel2.add(lbl2,BorderLayout.WEST); panel2.add(scroll1); panel3.add(lbl3,BorderLayout.WEST); panel3.add(scroll2); panel.setLayout(new BorderLayout()); panel.add(panel1,BorderLayout.NORTH); panel.add(panel2,BorderLayout.CENTER); panel.add(panel3,BorderLayout.SOUTH); add(panel,BorderLayout.NORTH); setSize(300,300); setVisible(true); } class MyAdjustmentListener implements AdjustmentListener { public void adjustmentValueChanged(AdjustmentEvent e) { if(e.getSource()==scroll) redness = e.getValue(); else if(e.getSource() == scroll1) greenness = e.getValue(); else blueness = e.getValue(); co=new Color(redness,greenness,blueness); setBackground(co); repaint(); } } }

OUTPUT:

RESULT: Thus the above program has been executed successfully.

7- TO INVOKE SERVLETS FROM HTML FORMS


AIM:
To write programs in JAVA using Servlets to invoke Servlets from HTML forms. ALGORITHM:

Import required java packages. Embbed HTML code with JAVA code. Use AWT components to define GUI. Save and execute the program.

Servlet.html:
<html> <head> <title>Student Information Form</title> </head> <body bgcolor=cyan> <center> <form name="form1"action="http://localhost:8081/DHANAPATHY/my_servletDemo"> <h1>Enter student information in following fields</h1> <table> <tr> <td><b><h2>Roll Number</h2></b></td> <td><input type="text"name="Roll Number"size="25"value=""></td> </tr> <tr> <td><b><h2>Student Name</h2></b></td> <td><input type="text"name="Student Name"size="25"value=""></td> </tr> <tr> <td><b><h2>Student Address</h2></b></td> <td><input type="text"name="address"size="50"value=""></td> </tr> <tr> <td><b><h2>Phone</h2></b></td> <td><input type="text"name="Phone"size="25"value=""></td> </tr> <tr> <td><b><h2>Total Marks</h2></b></td> <td><input type="text"name="Total Marks"size="10"value=""></td> </tr> </table>

<input type="submit"value="SUBMIT"> </form> </center> <body> </html> My_servletDemo.java: import java.io.*; import java.util.*; import javax.servlet.*; public class my_servletDemo extends GenericServlet { public void service(ServletRequest req,ServletResponse res) throws ServletException,IOException { PrintWriter out=res.getWriter(); Enumeration en=req.getParameterNames(); while(en.hasMoreElements()) { String name_received=(String)en.nextElement(); out.print(name_received+"="); String value_received=req.getParameter(name_received); out.println(value_received); out.println(""); } out.close(); } }

OUTPUT:

RESULT:
Thus the above program has been executed and servlets are invoked from HTML forms successfully.

8.a- ONLINE EXAMINATION USING SERVLET


AIM: To write java servlet programs to conduct online examination .

ALGORITHM:

HTML Step 1: Write a html file which contains a form that is directed to a servlet Step 2: Write various questions and choices Step 2: Include to buttons reset and click Servlet Step 1: Import all necessary packages Step 2: Define a class that extends servlet Step 3: In the doPost() method, do the following: i) Set the content type of the response to "text/html" ii) Create a writer to the response iii) Get a paratmeter from the request iv) If its value is equal to right answer then add 5 to mark variable v) Similarly repeat step iv) for all parameters vi) Display the result in an html format using the writer

PROGRAM: HTML <html> <head><title>Exam Form</title></head> <body> <form action="http://localhost:8080/servlet/serv" method=POST> <strong> <p> QUESTIONS: </p></strong> 1.JavaUses: <p> <input type=radio name=ans1 value="inter">Interpreter <input type=radio name=ans1 value="comp">Compiler <input type=radio name=ans1 value="intercomp">Interpreter&Compiler </p> 2.Net is an OS: <p> <input type=radio name=ans2 value="yes">yes <input type=radio name=ans2 value="no">no </p> 3.ASP Uses: <p> <input type=radio name=ans3 value="vbs">VBScript <input type=radio name=ans3 value="js">JavaScript <input type=radio name=ans3 value="vbjs">VBScript&JavaScript </p> <input type=submit value="click"> <input type=reset> </form> </body> </html> Servlet import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class serv extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse resp) throws ServletException,IOException { int s=0; resp.setContentType("text/html"); PrintWriter out=resp.getWriter(); String res=req.getParameter("ans1"); if(res.equals("intercomp")) s=s+5; res=req.getParameter("ans2"); if(res.equals("no"))

s=s+5; res=req.getParameter("ans3"); if(res.equals("vbjs")) s=s+5; out.println("<html><body><p><center><h1><b>RESULT</b></h1><br><br><hr>" +s+"<hr><h2>Thanx for ur Participation</h2></center></p></body></html>"); out.close(); } }

OUTPUT:

RESULT: Thus the above program has been executed successfully.

8.b-DISPLAYING STUDENT MARK LIST USING JSP AND DATABASES


AIM:
To write programs in JAVA to create three-tier applications using JSP and Databases. ALGORITHM: Create a CSS file to apply styles to the web page. Create a MS-Access file to store and retrieve the data. Create appropriate JSP fle. Execute program in browser web browser.

Results.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css">

div.container { width: 30%; border: 1px solid gray; margin: 0px; line-height: 150%; background-color:#e0f2ae; color: #476403; } div.header,div.footer { padding: 0.5em; color: white; background-color: #81AC00; clear: both; } div.left { float: left; width: 260px; margin: 0px;

padding-top: 10px; color: #476403; } h1.header, h3.footer { padding: 0px; margin: 0px; text-align: center; } </style> </head> <body bgcolor=pink> <form action="http://localhost:8081/StudentDatabase/displayMarks.jsp" method="post"> <div class="container"> <div class="header"><h1 class="header">RRASE UNIVERSITY</h1></div> <div class="left"> Register No: <input type="text" name="regno"/> <center><br><input type="submit" value="Submit"/> <br>Enter your register number to view the results</center> </div> <div class="footer"><h3 class="footer">CS2358 Internet Programming Lab </h3></div> </div> </form> </body> </html>

displayMarks.jsp:
<%@ page language="java" import="java.sql.*"%> <html> <head> <title>RRASE Student Database</title> </head> <body bgcolor=pink> <% Connection con=null; Statement st; ResultSet res; String regno,studName; String m1,m2,m3; String flag1="Fail",flag2="Fail",flag3="Fail"; int mark1,mark2,mark3; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("Jdbc:Odbc:StudentMarks"); st = con.createStatement(); regno = request.getParameter("regno"); res = st.executeQuery("SELECT * FROM Marks where regno='"+regno+"'");

if(!res.next()) { out.println("<Center><h3>Login Failure! No such user exists</h3>"); }

else { studName = res.getString("STUDNAME"); m1 = res.getString("OOPS"); m2 = res.getString("JAVA"); m3 = res.getString("WEBTECH"); mark1 = Integer.parseInt(m1); mark2 = Integer.parseInt(m2); mark3 = Integer.parseInt(m3); if(mark1 >= 50) flag1 = "Pass"; if(mark2 >= 50) flag2 = "Pass"; if(mark3 >= 50) flag3 = "Pass"; out.println("<h1 align='center'>RRASE UNIVERSITY RESULTS</h1>"); out.println("<h1>Welcome "+studName+"!</h1>"); out.println("<table border='2' width='400' cellpadding='5'>"); out.print("<th colspan='3'>REG NO: "+regno +"</th>"); out.print("<tr><td>OOPS</td><td>" +m1+"</td><td>"+flag1+"</td></tr>"); out.print("<tr><td>JAVA</td><td>" +m2+"</td><td>"+flag2+"</td></tr>"); out.print("<tr><td>WEBTECH</td><td>" +m3+"</td><td>"+flag3+"</td></tr>"); out.println("</table>"); } } catch(Exception e) {

out.println("Exception: " + e.getMessage()); } finally { try { if(con != null) con.close(); } catch(SQLException e) { } } %> </body> </html>

StudentMarks.db

OUTPUT:

RESULT:
Thus the above three-tier applications of displaying student mark list has been implemented successfully using JSP and Databases.

9-DOCUMENT OBJECT MODEL


Aim: To create a program for implementing the book bank application using DOM Algorithm: 1. 2. 3. 4. 5. 6. 7. Create the bookstore.xml file Add the tags such as book, category, title, author, year, price, etc for each book. Set the values for each attributes in that file. Add more numbers of book details. Then create bookstore.html file Add script and ActiveX Control tags. Read the data from bookstore.xml and display it using formatting tags.

bookstore.xml: <?xml version="1.0" ?> <bookstore> <book> <category> Cooking </category> <title> Everyday Italian </title> <author> Giada De Laurentiis </author> <year> 2005 </year> <price> 30.00 </price> </book> <book> <category> Children </category> <title> Harry Potter </title> <author> J K. Rowling </author> <year> 2005 </year> <price> 29.99 </price> </book> <book> <category> Web </category> <title> XQuery Kick Start </title> <author> Vaidyanathan Nagarajan </author> <year> 2003 </year> <price> 49.99 </price> </book> </bookstore>

bookstore.html <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript" FOR=window EVENT=onload> loadDoc(); </SCRIPT> <SCRIPT LANGUAGE="JavaScript"> var xmlDoc = new ActiveXObject ("microsoft.xmldom") ; xmlDoc.load ("bookstore.xml") ; function loadDoc() { if(xmlDoc.readyState=="4") processFile(); else window.setTimeout("loadDoc()",4000); } function processFile() { var rootElement, currentElement, i ; rootElement = xmlDoc.documentElement ; for ( i = 0 ; ( currentElement = rootElement.childNodes.item(i)) != null ; i++ ) { document.write('<BR>Category:</B>' +currentElement.childNodes.item(0).text+ '<BR>'); document.write('<BR>Title:</B>' +currentElement.childNodes.item(1).text+ '<BR>'); document.write('<BR>Author:</B>' +currentElement.childNodes.item(2).text+ '<BR>'); document.write('<BR>Year:</B>' +currentElement.childNodes.item(3).text+ '<BR>'); document.write('<BR>Price:</B>' +currentElement.childNodes.item(4).text+ '<BR>'); document.write('<HR>'); } } </SCRIPT> </HEAD> </HTML>

OUTPUT:

RESULT: Thus the program to implement DOM parser was created and executed.

10.a-PROGRAMS USING XML SCHEMA


AIM: To write a program in XML Schema for online purchase application Algorithm: Create a laptop.xml file. Add an xml schema tag computer and its sub tags processor, monitor, cpu speed, ram etc. Add a multiple number of schema tags for various computer models. Create a computer.xsd xml schema file. Add simple type and complex type to give the definition for the values which was entered for the attributes in the loptop.xml file.

PROGRAM: laptop.xml <?xml version = "1.0"?> <!-- Laptop components marked up as XML --> <computer:laptop xmlns:computer = "http://www.deitel.com/computer" manufacturer = "IBM"> <processor model = "Centrino">Intel</processor> <monitor>17</monitor> <CPUSpeed>2.4</CPUSpeed> <RAM>256</RAM> </computer:laptop> computer.xsd <?xml version = "1.0"?> <!-- W3C XML Schema document --> <schema xmlns = "http://www.w3.org/2001/XMLSchema" xmlns:computer = "http://www.deitel.com/computer" targetNamespace = "http://www.deitel.com/computer"> <simpleType name = "gigahertz"> <restriction base = "decimal"> <minInclusive value = "2.1"/> </restriction> </simpleType>

<complexType name = "CPU"> <simpleContent> <extension base = "string"> <attribute name = "model" type = "string" /> </extension> </simpleContent> </complexType> <complexType name = "portable"> <all> <element name = "processor" type = "computer:CPU"/> <element name = "monitor" type = "int"/> <element name = "CPUSpeed" type = "computer:gigahertz"/> <element name = "RAM" type = "int"/> </all> <attribute name = "manufacturer" type = "string"/> </complexType> <element name = "laptop" type ="computer:portable"/> </schema>

OUTPUT:

Result: Thus the program to implement XML schema for online purchase application was created and executed.

10. b-PROGRAMS USING -XSLT/XSL


AIM: To write a programs to implement XSLT/XSL. ALGORITHM:

Create a Cricket.xml file. Add an xml schema tag team name,captain,etc., Add a multiple number of schema tags for various teams. Create a Cricket.xsl xml schema file. Add simple type and complex type to give the definition for the values which was entered for the attributes in the Cricket.xml file.

Cricket.xml: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="cricket.xsl"?> <ICC> <Cricket-Team> <team-name>India</team-name> <captain>MS.Dhoni</captain> <played-matches>456</played-matches> <won>370</won> <lost>86</lost> </Cricket-Team> <Cricket-Team> <team-name>Australia</team-name> <captain>Ricky Ponting</captain> <played-matches>445</played-matches> <won>323</won> <lost>118</lost> </Cricket-Team> <Cricket-Team> <team-name>Pakistan</team-name> <captain>Afridi</captain> <played-matches>386</played-matches> <won>150</won> <lost>236</lost> </Cricket-Team> <Cricket-Team> <team-name>SriLanka</team-name> <captain>Kumar Sankakara</captain> <played-matches>342</played-matches>

<won>230</won> <lost>112</lost> </Cricket-Team> <Cricket-Team> <team-name>South Africa</team-name> <captain>Smith</captain> <played-matches>319</played-matches> <won>181</won> <lost>148</lost> </Cricket-Team> </ICC> Cricket.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="/"> <html> <body bgcolor="#008B8B"> <h1 align="center" >International Cricket Club Council Database</h1> <table border="10" align="center"> <tr bgcolor="#E9967A"> <th>Team-Name</th> <th>Captain</th> <th>Played-matches</th> <th>Won</th> <th>Lost</th> </tr> <xsl:for-each select="ICC/Cricket-Team"> <tr bgcolor="pink"> <td><xsl:value-of select="team-name"/></td> <td><xsl:value-of select="captain"/></td> <td><xsl:value-of select="played-matches"/></td> <td><xsl:value-of select="won"/></td> <td><xsl:value-of select="lost"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

OUTPUT:

RESULT: Programs using XSLT/XSL are executed and verified the output successfully.

11-PROGRAMS USING AJAX


AIM: To create a program to implement the concept of Asynchronous java script XML concepts for web page login process. Algorithm: 1. Create the AJAX file simpleajax.html 2. Add script tag and postRequest function to send the request to the PHP file. 3. Start the apache tomcat server and deploy the php file. 4. Get the user name and password from the user using HTML form 5. Check the user name and password at the server side using PHP 6. If the user name and password is valid, show the welcome message.

AJAX Program: login.html <html> <head> <script language="javascript"> function postRequest(strURL){ var xmlHttp; if(window.XMLHttpRequest){ // For Mozilla, Safari, ... var xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject){ // For Internet Explorer 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){ if(str=="yes"){ alert("Welcome User"); }else{ alert("Invalid Login! Please try again!"); } } function call_login(){ var username = window.document.f1.username.value; var password = window.document.f1.password.value; var url = "login.php?username=" + username + "&password=" +password ; postRequest(url); } </script> </head> <body> <Center> <form name="f1" onsubmit="return call_login();"> <table border="0" bgcolor="#CCCCFF" cellspacing="1" cellpadding="3" width="287"> <tr> <td align="left" colspan="2" width="275"><b><font size="5"

color="#000080">Login</font></b></td> </tr> <tr> <td align="right" width="81"><b><font color="#000080">User Name:</font></b></td> <td width="184"><input type="text" name="username" id="user" size="20" value="" /></td> </tr> <tr> <td align="right" width="81"><b><font color="#000080">Password:</font></b></td> <td width="184"><input type="password" name="password" size="20" value="" /></td> </tr> <tr> <td colspan="2" align="center" width="275"><input type="button" name="a1" value="Login" onclick="call_login()"></td> </tr> </table> </form> </center> </body> </html>

PHP Program: login.php <? $username=$_GET["username"]; $password=$_GET["password"]; if($username=="admin" && $password=="admin"){ echo "yes"; }else{ echo "No"; } ?>

OUTPUT:

RESULT: Thus the program to login in to a web page using AJAX and PHP was completed and executed.

12-TRAVEL AGENT AND AIRLINE SERVICE USING WEBSERVICES AND DATABASES


AIM: Consider a case where we have two web Services- an airline service and a travel agent and the travel agent is searching for an airline. To implement this scenario using Web Services and Data base.

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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Travel Agency</title> </head> <body> <center><h1>Travel Easy</h1> <h3> - A Smarter way to travel</h3> <br><br> <b> Enter your Details</b> <form name="index" action="AirlineList.jsp" method="post"> <br> <table cellpadding="6" cellspacing="6"> <tr> <td><b>From</b></td> <td><input type="text" name="txt_from"</td> </tr> <tr> <td><b>To</b></td> <td><input type="text" name="txt_to"</td> </tr> <tr> <td><b>Date of Journey</b></td> <td><input type="text" name="txt_depart"</td> </tr> <tr> <td><b>Number of Passengers</b></td> <td><input type="text" name="txt_no"</td>

</tr> <tr> <td><b>Type of Flight</b></td> <td><input type="Radio" name="group1" value="domestic">Domestic Flights</td </tr> <tr> <td></td> <td><input type="Radio" name="group1" value="international">International Flights</td> </tr> <tr> <td><b>Select desired Airlines</b></td> <td> <select name="airline"> <option>Kingfisher</option> <option>SpiceJet</option> </select> </td> </tr> </table> <br><br> <input type="Submit" name="Submit" value="Find Flights"> </form> </center> </body> </html>
airlinelist.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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Domestic Flights</title> </head> <body> <center><h1>Travel Easy</h1> <h3> - A Smarter way to travel</h3> </center> <br><br> <%@ page language="java" %> <%@ page import ="java.sql.*" %> <%@ page import = "java.util.Date,java.text.SimpleDateFormat,java.text.ParseException"%> <%

String type = request.getParameter("group1"); String from= request.getParameter("txt_from"); String to = request.getParameter("txt_to"); String depart= request.getParameter("txt_depart"); String ret = request.getParameter("txt_return"); String no = request.getParameter("txt_no"); String airline = request.getParameter("airline"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String sTable = type; String sSql = "SELECT * FROM " sTable " WHERE From='" from "' and TO='" to "' and DepartDate='" depart "' and SeatCapacity>=" no ""; String sDBQ = "d:/" airline ".mdb"; String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" sDBQ ";DriverID=22;READONLY=true"; Connection cn = null; Statement st = null; ResultSet rs = null; try { cn = DriverManager.getConnection( database ,"",""); st = cn.createStatement(); rs = st.executeQuery( sSql ); ResultSetMetaData rsmd = rs.getMetaData(); String s1,s2,s3,s4,s5,s6,s7,s8; int i=1; String flight_no[] = new String[100]; //out.println("<form name='AirlLine' action='' method='post'><b>" i " . " rs.getString(1) "</b><br><br>"); out.println("<h3><b>" airline " Flights</b></h3><br>"); out.println("<table cellspacing=20 cellpaddinng=15>"); out.println("<tr><th>Flight No</th><th>From</th><th>To</th><th>Departure Date</th><th>Arrival Date</th><th>Start Time</th>"); out.println("<th>Reach Time</th><th>Seats Remaining</th></tr>"); while(rs.next()) { s1 = rs.getString(1); flight_no[i] = s1; s2 = rs.getString(2); s3 = rs.getString(3); s4 = rs.getString(4); s5 = rs.getString(5); s6 = rs.getString(6); s7 = rs.getString(7); s8 = rs.getString(8); out.println("<tr><td>" s1 "</td>"); out.println("<td>" s2 "</td>"); out.println("<td>" s3 "</td>"); out.println("<td>" s4 "</td>"); out.println("<td>" s5 "</td>"); out.println("<td>" s6 "</td>");

out.println("<td>" s7 "</td>"); out.println("<td>" s8 "</td></tr>"); i ; } out.println("</table>"); if(i==1) { out.println("<br><center><b>Sorry!! No flights scheudle available</b></center><br>"); } else { out.println("<form name='AirlineList' action='" airline ".jsp' method='post'>"); out.println("<br><table><tr><td>Select Flight</td><td>"); out.println("<select name='flight_no'>"); for(int temp=1;temp<i;temp ) { out.println("<option>" flight_no[temp] "</option>"); } out.println("</select></td></tr><tr></tr>"); out.println("<tr><td><input type='hidden' name='no' value='" no "'</td>"); out.println("<td><input type='hidden' name='air_type' value='" type "'</td></tr>"); for(int j=1;j<=Integer.parseInt(no);j ) { out.println("<tr><th>Passenger " j " details</th></tr>"); out.println("<tr></tr>"); out.println("<tr><td>Name</td><td><input type='text' name='pas" j "_name'</td></tr>"); out.println("<tr><td>Age</td><td><input type='text' name='pas" j "_age'</td></tr>"); out.println("<tr><td>Sex</td><td><input type='text' name='pas" j "_sex'</td></tr>"); out.println("<tr></tr>"); } out.println("</table><br><br><input type='Submit' name='Submit' value='Book Now'/></form>"); } //out.println("<input name ='submit' value='Submit' type='submit'/>"); } finally { try { if( null != rs ) rs.close(); } catch( Exception ex ) {} try { if( null != st ) st.close(); } catch( Exception ex ) {} try { if( null != cn ) cn.close(); } catch( Exception ex ) {} } %> </body> </html>

Kingfisher.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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Kingfisher Airlines</title> </head> <body> <%@ page language="java" %> <%@ page import ="java.sql.*" %> <% String s = request.getParameter("no"); out.println("<h1><center>Kingfisher Airlines</h1><br><h3>- Have a nice trip!!!</h3></center><br>"); out.println("<br><br>Your Booking Details"); out.println("<br><br><table cellspacing=10 cellpaddin=10>"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String sTable = request.getParameter("air_type"); String sSql = "SELECT * FROM " sTable " WHERE FlightNo='" request.getParameter("flight_no") "'"; String sDBQ = "d:/kingfisher.mdb"; String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" sDBQ ";DriverID=22;READONLY=true"; Connection cn = null; Statement st = null; ResultSet rs = null; String name,age,sex,flightno,from,to,departure,arrival,starttime,reachtime,seat; out.println("<tr><th>Name</th><th>Age</th><th>Sex</th><th>Flight No</th><th>From</th><th>To</th><th>Departure Date</th><th>Arrival Date</th><th>Start Time</th><th>Reach Time</th><th>Seat No</th></tr>"); try { cn = DriverManager.getConnection( database ,"",""); st = cn.createStatement(); rs = st.executeQuery( sSql ); ResultSetMetaData rsmd = rs.getMetaData(); int seat1=1; while(rs.next()) { flightno = rs.getString(1); from = rs.getString(2); to = rs.getString(3); departure = rs.getString(4); arrival = rs.getString(5); starttime = rs.getString(6);

reachtime = rs.getString(7); seat = rs.getString(8); seat1 = Integer.parseInt(seat); for(int i=1;i<=Integer.parseInt(s);i ) { name= request.getParameter("pas" i "_name"); age = request.getParameter("pas" i "_age"); sex = request.getParameter("pas" i "_sex"); flightno = request.getParameter("flight_no"); out.println("<tr><td>" name "</td><td>" age "</td><td>" sex "</td>"); out.println("<td>" flightno "</td><td>" from "</td><td>" to "</td><td>" departure "</td>");

out.println("<td>" arrival "</td><td>" starttime "</td><td>" reachtime "</td><td>" seat1 "</td>"); seat1--; } } Connection cn1 = null; Statement st1 = null; ResultSet rs1 = null; try { sSql = "update " sTable " set SeatCapacity=" seat1 " WHERE FlightNo='" request.getParameter("flight_no") "'"; rs1 = st.executeQuery( sSql ); } catch(Exception e) { } } finally { try { if( null != rs ) rs.close(); } catch( Exception ex ) {} try { if( null != st ) st.close(); } catch( Exception ex ) {} try { if( null != cn ) cn.close(); } catch( Exception ex ) {} } %> </body> </html>

SpiceJet.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> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>SpiceJet Airlines</title> </head> <body> <%@ page language="java" %> <%@ page import ="java.sql.*" %> <% String s = request.getParameter("no"); out.println("<h1><center>SpiceJet Airlines</h1><br><h3>- Have a nice trip!!!</h3></center><br>"); out.println("<br><br>Your Booking Details"); out.println("<br><br><table cellspacing=10 cellpaddin=10>"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String sTable = request.getParameter("air_type"); String sSql = "SELECT * FROM " sTable " WHERE FlightNo='" request.getParameter("flight_no") "'"; String sDBQ = "d:/SpiceJet.mdb"; String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" sDBQ ";DriverID=22;READONLY=true"; Connection cn = null; Statement st = null; ResultSet rs = null; String name,age,sex,flightno,from,to,departure,arrival,starttime,reachtime,seat; out.println("<tr><th>Name</th><th>Age</th><th>Sex</th><th>Flight No</th><th>From</th><th>To</th><th>Departure Date</th><th>Arrival Date</th><th>Start Time</th><th>Reach Time</th><th>Seat No</th></tr>"); try { cn = DriverManager.getConnection( database ,"",""); st = cn.createStatement(); rs = st.executeQuery( sSql ); ResultSetMetaData rsmd = rs.getMetaData(); int seat1=1; while(rs.next()) { flightno = rs.getString(1); from = rs.getString(2); to = rs.getString(3); departure = rs.getString(4); arrival = rs.getString(5); starttime = rs.getString(6);

reachtime = rs.getString(7); seat = rs.getString(8); seat1 = Integer.parseInt(seat); for(int i=1;i<=Integer.parseInt(s);i ) { name= request.getParameter("pas" i "_name"); age = request.getParameter("pas" i "_age"); sex = request.getParameter("pas" i "_sex"); flightno = request.getParameter("flight_no"); out.println("<tr><td>" name "</td><td>" age "</td><td>" sex "</td>"); out.println("<td>" flightno "</td><td>" from "</td><td>" to "</td><td>" departure "</td>");

out.println("<td>" arrival "</td><td>" starttime "</td><td>" reachtime "</td><td>" seat1 "</td>"); seat1--; } } Connection cn1 = null; Statement st1 = null; ResultSet rs1 = null; try { sSql = "update " sTable " set SeatCapacity=" seat1 " WHERE FlightNo='" request.getParameter("flight_no") "'"; rs1 = st.executeQuery( sSql ); } catch(Exception e) { } } finally { try { if( null != rs ) rs.close(); } catch( Exception ex ) {} try { if( null != st ) st.close(); } catch( Exception ex ) {} try { if( null != cn ) cn.close(); } catch( Exception ex ) {} } %> </body> </html>

Database

(similarly add for SpiceJet.mdb)

OUTPUT Index.jsp

airlinelist.jsp:

Kingfisher.jsp:

RESULT: Thus the program of providing Airline service has been implemented using Web Service and Database.

You might also like