ip lab allignment1
TRANSCRIPT
-
7/30/2019 IP LAB Allignment1
1/76
LIST OF EXPERIMENTS
S.NO DATE NAME OF THE EXPERIEMENTSPAGE
NOSIGNATURE
STUDY OF BASICS AND TAGS OF HTML
1 IMAGE MAPPING
2 a.CREATION OF MENU USING EMBEDDEDCSS
b. CREATION OF MENU USING EXTERNALCSS
3. EXERCISE USING JAVA SCRIPT
4. CLIENT SIDE SCRIPT-FORM VALIDATION
IN DHTML5. COLOR PALETTE WITH MATRIX BUTTONSAND CHECK BOX
6. MAKING COLOR SLIDESS ON THE APPLET
7. TO INVOKE SERVLETS FROM HTMLFORMS
8 a.CONDUCTING ONLINE EXAMINATIONUSING SERVLET
b. DISPLAYING STUDENT MARKLIST USINGJSP
9. DOCUMENT OBJECT MODEL
10. a.PROGRAMS USING XML- SCHEMA
b. PROGRAMS USING -XSLT/XSL
11. PROGRAMS USING AJAX
12. TRAVEL AGENT AND AIRLINE SERVICEUSING JSP AND DATABASES
-
7/30/2019 IP LAB Allignment1
2/76
INTRODUCTION TO WEB TECHNOLOGIES
Internet:
The Internet is a global system of interconnected computer networks that use thestandard Internet Protocol Suite (TCP/IP) to serve billions of users worldwide. It is anetwork of networks that consists of millions of private, public, academic, business, andgovernment networks, of local to global scope, that are linked by a broad array of electronicand optical networking technologies. The Internet carries a vast range ofinformation resources and services, such as the inter-linked hypertext documents ofthe 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 areexplained in brief below
Markup Languages:
Markup is used to in text and word processing documents to describe how a documentshould look when displayed or printed. The Internet uses markup to define how Web pagesshould look when displayed in a browser or to define the data contained within a Webdocument. There are many different types of markup languages. For example, Rich TextFormatting (RTF) is a markup language that word processors use.
HTML:
HTML stands for Hypertext Markup Language. HTML is the primary markup language thatis used for Web pages. HTML tells the browser what to display on a page. For example, itspecifies text, images, and other objects and can also specify the appearance of text, such asbold or italic text. The World Wide Web Consortium (W3C) defines the specification forHTML. The current versions of HTML are HTML 4.01 and XHTML 1.1. DHTML stands forDynamic HTML. DHTML combines cascading style sheets (CSS) and scripting to createanimated Web pages and page elements that respond to user interaction.
CSS:
CSS stands for cascading style sheets. Cascading style sheets provide the ability to changethe appearance of text (such as fonts, colors, spacing) on Web pages. Using CSS, you canalso position elements on the page, make certain elements hidden, or change theappearance of the browser, such as changing the color of scroll bars in Microsoft InternetExplorer.Cascading style sheets can be used similar to FrontPage Themes. For example, you canapply a cascading style sheet across all the pages in a Web site to give the site a uniformlook and feel. Then all you need to do is to change the CSS style formatting in a single file tochange the look and feel of an entire Web site.
-
7/30/2019 IP LAB Allignment1
3/76
-
7/30/2019 IP LAB Allignment1
4/76
Although VBScript can be used for client-side scripting in Internet Explorer, most otherbrowsers do not include a VBScript interpreter. Therefore, VBScript is most commonlyused 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 UNIXbasedservers. PHP is commonly used to access databases and provide server-side formand e-commerce processing. As with ASP code, PHP code is contained within the body of anHTML page.PHP code typically runs on Linux-based and UNIX-based Web servers, and can run onWindows-based servers with an installed interpreter.
Java:
Java is a compiled object-oriented programming language that was designed for use on theInternet. In 1995, Sun Microsystems designed the Java programming language andintroduced it to Web developers as a way to include animation and dynamic elements inWeb 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 byusing 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, andInternet Explorer is the only browser that natively supports ActiveX controls. In addition,because ActiveX controls are installed on the client computer, browsers that supportActiveX controls generally allow users to accept or deny installing ActiveX controls, whichmeans that if an ActiveX control is not installed on a client machine, the page that containsit often does not function as expected. Therefore, ActiveX controls are best used in acontrolled environment, such as an intranet site, in which Internet Explorer is the standardbrowser in use.
ASP:
ASP is an abbreviation for Active Server Pages. ASP is a server-side scripting technologythat you can use to create dynamic Web pages. ASP code is generally embedded in theHTML 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 theresulting HTML.
Web Servers and Server Products:
A Web server is the computer on which you host your Web site. It is connected directly to
-
7/30/2019 IP LAB Allignment1
5/76
the Internet and sends hosted Web pages to the client using the Hypertext TransferProtocol (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 toseveral different types of Web servers. The most common Web servers available areWindows-based servers running Microsoft Internet Information Services (IIS) and
UNIXbasedservers running Apache.
Internet Information Services:
Internet Information Services (IIS) is a Web server designed to process HTTP and FTPrequests on Windows operating systems. IIS is part of the Microsoft Windows NT,Microsoft Windows 2000, and Microsoft Windows 2003 operating systems, and you caninstall and enable IIS on Windows XP-based computers for testing ASP and ASP.NETapplications.
Apache:
Apache is an open-source Web server that runs on UNIX operating systems, such as Solarisand Linux, but can also be installed on Windows-based servers. Apache Web serversprovide simple HTTP processing.
Databases:
Databases allow you to store information for easy retrieval. On the Internet, databases areused to store users' logon information, product information, and customers' orders, amongother things. There are almost as many database products as there are reasons and ways to
use databases.
Access SQL Server MySQL Oracle Database
-
7/30/2019 IP LAB Allignment1
6/76
BASICS OF HTMLHTML:
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 ofmarkup 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 tags normally come in pairs like and 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 documentsanddisplay them as web pages. The browser does not display the HTML tags, but uses the tags to
interpret the content of the page:My First Heading
My first paragraph.
Explanation:
The text between and describes the web page The text between and is the visible page content The text between and is displayed as a heading The text between
and
is displayed as a paragraph -
7/30/2019 IP LAB Allignment1
7/76
HTML TAGS AND DESCRIPTION
LIST OF HTML TAGS ORDERED ALPHABETICALLY
TAG DESCRIPTION DTD
Defines a comment STF
Defines the document type STF
Defines an anchor STF
Defines an abbreviation STF
Defines an acronym STF
Defines contact information for the author/owner of a document STF
Deprecated. Defines an embedded applet TF
Defines an area inside an image-map STF
Defines bold text STF
Defines a default address or a default target for all links on a page STF
Deprecated. Defines a default font, color, or size for the text in apage
TF
Defines the text direction STF
Defines big text STF
Defines a long quotation STF
Defines the document's body STF
Defines a single line break STFDefines a push button STF
Defines a table caption STF
Deprecated. Defines centered text TF Defines a citation STF
Defines computer code text STF
Defines attribute values for one or more columns in a table STF
Defines a group of columns in a table for formatting STF
Defines a description of a term in a definition list STF
Defines deleted text STF
Defines a definition term STF
Defines a section in a document STF
Defines a definition list STF
Defines a term (an item) in a definition list STF
Defines emphasized text STF
Defines a border around elements in a form STF
Deprecated. Defines font, color, and size for text TF
Defines an HTML form for user input STF
Defines a window (a frame) in a frameset F
Defines a set of frames F
to Defines HTML headings STF
Defines information about the document STF
Defines a horizontal line STF
Defines an HTML document STF
Defines italic text STF Defines an inline frame TF
-
7/30/2019 IP LAB Allignment1
8/76
TAG DESCRIPTION DTD
Defines an image STF
Defines an input control STF
Defines inserted text STF
Deprecated. Defines a searchable index related to a document TF Defines keyboard text STF
Defines a label for an input element STF
Defines a caption for a fieldset element STF
Defines a list item STF
Defines the relationship between a document and an externalresource
STF
Defines an image-map STF
Deprecated. Defines a menu list TF
Defines metadata about an HTML document STF
Defines an alternate content for users that do not support frames TF
Defines an alternate content for users that do not support client-side script
STF
Defines an embedded object STF
Defines an ordered list STF
Defines a group of related options in a select list STF
Defines an option in a select list STF
Defines a paragraph STF
Defines a parameter for an object STF
Defines preformatted text STF
Defines a short quotation STF
Deprecated. Defines strikethrough text TF
Defines sample computer code STF
Defines a client-side script STF
Defines a select list (drop-down list) STF
Defines small text STF
Defines a section in a document STF
Deprecated. Defines strikethrough text TF
Defines strong text STF
Defines style information for a document STF
Defines subscripted text STF Defines superscripted text STF
Defines a table STF
Groups the body content in a table STF
Defines a cell in a table STF
Defines a multi-line text input control STF
Groups the footer content in a table STF
Defines a header cell in a table STF
Groups the header content in a table STF
Defines the title of a document STF
Defines a row in a table STF Defines teletype text STF
-
7/30/2019 IP LAB Allignment1
9/76
Deprecated. Defines underlined text TF
Defines an unordered list STF
Defines a variable part of a text STF
Deprecated. Defines preformatted text STF
S=Strict, T=Transitional, and F=Frameset
-
7/30/2019 IP LAB Allignment1
10/76
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.
-
7/30/2019 IP LAB Allignment1
11/76
PROGRAM:
INDIA.HTML:
Home - States of India!!Republic of India
India is the Seventh Largest country in the world by geographical area, the secondmost populous country with over 1.2 billion people, and the most populousdemocracy in the world. India is a federal constitutional Republic with a parliamentrydemocracy consisting of 28 states and 7 Union Terrirories.
FeaturesPopulation - 1,028,610,328 (2001 census).Capital - New DelhiLargest City - MumbaiCurrency - Indian Rupee.Time Format - IST (UTC + 5:30)National Sport - HockeyCurrent PM - Manmohan SinghCurrent President - Prathiba PatilTo view the details of states please click on the specified area in themap!!
TAMILNADU.HTML:
Tamil Nadu - India(Data as on 11.004.2011)Tamil Naduis 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 isbordered 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 thesouth.
-
7/30/2019 IP LAB Allignment1
12/76
Districts - 32Capital City - ChennaiLargest City - Chennai
Governor - Surjit Singh BarnalaChief Minister - M. KarunanidhiDeputy Cheif Minister - M.StalinPopultation - 66,396,000Dance - BharthanatyamFestivals - Pongal, Alanganallur Jallikattu etc.,Cuisine - Dosai, Adai, Idly, Vadai, Pongal, Appam(Aappam), Paniyaram,Puttu(Pittu), Uppumavu(Uppuma), Santhakai(Noodles), Idiyappam and Uthappam.Tourist spots Mamallapuram (Shore Temple)
Brihadeeshwara TempleOotyKodaikanal.Kanyakumari. (Thiruvalluvar statue etc.,)Marina Beach(chennai)Madurai Meenakshi Amman Temple.Thanjavur.Velankanni.Rameswaram.
KARNATAKA.HTML:
Karnataka - India(Data as on 16.12.2010)
Karnataka
Districts - 30Capital City - BangaloreLargest City - BangaloreGovernor - Hansraj BhardwajChief Minister - B. S. Yeddyurappa
Popultation - 52,850,562
-
7/30/2019 IP LAB Allignment1
13/76
Tourist spots - Gol Gumbaz, Mysore Palace, KeshavaTemple etc.,
ANDHRAPRADESH.HTML:
Andhra Pradesh - India(Data as on 16.12.2010)
Andhra PradeshA.P., is a state situated on the southeastern coast of India. It isIndia's fourth largest state by area and fifth largest by population.
Districts - 23Capital City - HyderabadLargest City - HyderabadGovernor - E. S. L. NarasimhanChief Minister - N. Kiran Kumar ReddyPopultation - 76,210,007Tourist spots - Tirumala Tirupati, Charminar, GolcondaFort, Chandragiri Fort, Chowmahalla Palace, Falaknuma Palace etc.,
-
7/30/2019 IP LAB Allignment1
14/76
OUTPUT:
-
7/30/2019 IP LAB Allignment1
15/76
-
7/30/2019 IP LAB Allignment1
16/76
RESULT:
Thus the program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
17/76
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 tag to import CSS. Define required styles and access it on to body of the program.
PROGRAM:
#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
-
7/30/2019 IP LAB Allignment1
18/76
{background-color:lime;padding-bottom:12px;border-bottom:2px;color: #38c;
}
HomeProductsRegistrationServicesContact us
OUTPUT:
RESULT:
Thus the above program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
19/76
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;
-
7/30/2019 IP LAB Allignment1
20/76
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:
HomeMarks DetailsAttendance DetailsDues DetailsContact us
-
7/30/2019 IP LAB Allignment1
21/76
OUTPUT:
RESULT:
Thus the above program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
22/76
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 tag to import java script. Define required operations. Save the file and open this file on the browser web-browser.
ALERT BOX USING JAVASCRIPT:
function show_alert(){alert("Hello! I am an alert box!");}
:
OUTPUT
-
7/30/2019 IP LAB Allignment1
23/76
DATE FUNCTIONS IN JAVASCRIPT:
var d=new Date();document.write(d);
OUTPUT:
Sat Nov 06 2010 19:58:39 GMT+0530 (India Standard Time)
RESULT:
Thus the above program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
24/76
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. Create a HTML file with form controls2. In Script tag, set the attribute src="validationscript.js"3. In form tag, set the attribute onsubmit="return validateFormOnSubmit(this)"4. If the validation is completed the open the test.html file.5. Validate the username, password, email, phone number, and isEmpty using java script
in validationscript.js file
PROGRAM:
HTML Program:
Form ValidationForm Validation
Your user name:
Your password
Your email:
-
7/30/2019 IP LAB Allignment1
25/76
Your telephone number:
Where are you :
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;}
-
7/30/2019 IP LAB Allignment1
26/76
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
-
7/30/2019 IP LAB Allignment1
27/76
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;
}
-
7/30/2019 IP LAB Allignment1
28/76
OUTPUT:
Result:
Thus the program to validate the html form controls using java script was completed.
-
7/30/2019 IP LAB Allignment1
29/76
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.
-
7/30/2019 IP LAB Allignment1
30/76
PROGRAM:
/* */
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
-
7/30/2019 IP LAB Allignment1
31/76
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;
}}
-
7/30/2019 IP LAB Allignment1
32/76
PALETTE.HTML:
Applet Example
-
7/30/2019 IP LAB Allignment1
33/76
OUTPUT:
RESULT:
Thus the above program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
34/76
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.*;
/**/
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);
-
7/30/2019 IP LAB Allignment1
35/76
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();elseblueness = e.getValue();co=new Color(redness,greenness,blueness);setBackground(co);repaint();
}}
}
-
7/30/2019 IP LAB Allignment1
36/76
OUTPUT:
RESULT:
Thus the above program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
37/76
7- TO INVOKE SERVLETS FROM HTML FORMS
AIM:
To write programs in JAVA using Servlets to invoke Servlets fromHTML 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:
Student Information Form
Enter student information in following fieldsRoll NumberStudent NameStudent AddressPhoneTotal Marks
-
7/30/2019 IP LAB Allignment1
38/76
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();
}}
-
7/30/2019 IP LAB Allignment1
39/76
OUTPUT:
RESULT:Thus the above program has been executed and servlets are invoked from
HTML forms successfully.
-
7/30/2019 IP LAB Allignment1
40/76
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 clickServlet
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
-
7/30/2019 IP LAB Allignment1
41/76
PROGRAM:
HTML
Exam Form
QUESTIONS:
1.JavaUses:Interpreter
CompilerInterpreter&Compiler
2.Net is an OS:
yesno
3.ASP Uses:
VBScript
JavaScriptVBScript&JavaScript
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"))
-
7/30/2019 IP LAB Allignment1
42/76
s=s+5;res=req.getParameter("ans3");
if(res.equals("vbjs"))s=s+5;
out.println("
RESULT
");out.close();}
"+s+"Thanx for ur Participation}
-
7/30/2019 IP LAB Allignment1
43/76
OUTPUT:
RESULT:Thus the above program has been executed successfully.
-
7/30/2019 IP LAB Allignment1
44/76
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.
-
7/30/2019 IP LAB Allignment1
45/76
Results.html:
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;
-
7/30/2019 IP LAB Allignment1
46/76
padding-top: 10px;
color: #476403;
}
h1.header, h3.footer
{
padding: 0px;
margin: 0px;
text-align: center;
}
RRASE UNIVERSITY
Register No:
Enter your register number to view the resultsCS2358 Internet Programming Lab
-
7/30/2019 IP LAB Allignment1
47/76
displayMarks.jsp:
RRASE Student Database
-
7/30/2019 IP LAB Allignment1
48/76
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("RRASE UNIVERSITY RESULTS");
out.println("Welcome "+studName+"!");
out.println("");
out.print("REG NO: "+regno +"");
out.print("OOPS" +m1+""+flag1+"");
out.print("JAVA" +m2+""+flag2+"");
out.print("WEBTECH" +m3+""+flag3+"");
out.println("");
}
}
catch(Exception e)
{
-
7/30/2019 IP LAB Allignment1
49/76
out.println("Exception: " + e.getMessage());
}
finally
{
try
{
if(con != null)
con.close();
}
catch(SQLException e)
{
}
}
%>
-
7/30/2019 IP LAB Allignment1
50/76
StudentMarks.db
OUTPUT:
-
7/30/2019 IP LAB Allignment1
51/76
RESULT:
Thus the above three-tier applications of displaying student mark list has been
implemented successfully using JSP and Databases.
-
7/30/2019 IP LAB Allignment1
52/76
9-DOCUMENT OBJECT MODEL
Aim:To create a program for implementing the book bank application using DOM
Algorithm:
1. Create the bookstore.xml file2. Add the tags such as book, category, title, author, year, price, etc for each book.3. Set the values for each attributes in that file.4. Add more numbers of book details.5. Then create bookstore.html file6. Add script and ActiveX Control tags.7. Read the data from bookstore.xml and display it using formatting tags.
bookstore.xml:
Cooking Everyday Italian Giada De Laurentiis 2005 30.00
Children Harry Potter J K. Rowling 2005 29.99
Web XQuery Kick Start Vaidyanathan Nagarajan 2003 49.99
-
7/30/2019 IP LAB Allignment1
53/76
bookstore.html
loadDoc();
var xmlDoc = new ActiveXObject ("microsoft.xmldom") ;xmlDoc.load ("bookstore.xml") ;
function loadDoc(){if(xmlDoc.readyState=="4")
processFile();elsewindow.setTimeout("loadDoc()",4000);}
function processFile(){var rootElement, currentElement, i ;
rootElement = xmlDoc.documentElement ;
for ( i = 0 ; ( currentElement = rootElement.childNodes.item(i)) != null ; i++ ){document.write('
Category:' +currentElement.childNodes.item(0).text+ '
');document.write('
Title:' +currentElement.childNodes.item(1).text+ '
');document.write('
Author:' +currentElement.childNodes.item(2).text+ '
');document.write('
Year:' +currentElement.childNodes.item(3).text+ '
');document.write('
Price:' +currentElement.childNodes.item(4).text+ '
');document.write('');}} -
7/30/2019 IP LAB Allignment1
54/76
OUTPUT:
RESULT:Thus the program to implement DOM parser was created and executed.
-
7/30/2019 IP LAB Allignment1
55/76
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
Intel172.4256
computer.xsd
-
7/30/2019 IP LAB Allignment1
56/76
-
7/30/2019 IP LAB Allignment1
57/76
OUTPUT:
Result:
Thus the program to implement XML schema for online purchase application wascreated and executed.
-
7/30/2019 IP LAB Allignment1
58/76
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:
India
MS.Dhoni45637086AustraliaRicky Ponting445323118PakistanAfridi386150236SriLanka
Kumar Sankakara342
-
7/30/2019 IP LAB Allignment1
59/76
230112South Africa
Smith319181148
Cricket.xsl:
International Cricket Club Council DatabaseTeam-NameCaptainPlayed-matchesWonLost
-
7/30/2019 IP LAB Allignment1
60/76
OUTPUT:
RESULT:
Programs using XSLT/XSL are executed and verified the
output successfully.
-
7/30/2019 IP LAB Allignment1
61/76
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.html2. 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 form5. Check the user name and password at the server side using PHP6. If the user name and password is valid, show the welcome message.
-
7/30/2019 IP LAB Allignment1
62/76
AJAX Program:
login.html
function postRequest(strURL){var xmlHttp;if(window.XMLHttpRequest){ // For Mozilla, Safari, ...var xmlHttp = new XMLHttpRequest();}else if(window.ActiveXObject){ // For Internet Explorervar 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);}
-
7/30/2019 IP LAB Allignment1
63/76
color="#000080">LoginUserName:
Password:
PHP Program:
login.php
-
7/30/2019 IP LAB Allignment1
64/76
OUTPUT:
-
7/30/2019 IP LAB Allignment1
65/76
RESULT:
Thus the program to login in to a web page using AJAX and PHP wascompleted and executed.
-
7/30/2019 IP LAB Allignment1
66/76
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 agentand the travel agent is searching for an airline. To implement this scenario usingWeb Services and Data base.
index.jsp
Travel Agency
Travel Easy
- A Smarter way to travel
Enter your DetailsFrom
-
7/30/2019 IP LAB Allignment1
67/76
Type of FlightDomestic
Flights
-
7/30/2019 IP LAB Allignment1
68/76
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("" i " . "rs.getString(1) "
");out.println("" airline " Flights
");out.println("");out.println("Flight NoFromToDepartureDateArrival DateStart Time");out.println("Reach TimeSeats Remaining");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("" s1 "");out.println("" s2 "");out.println("" s3 "");out.println("" s4 "");
out.println("" s5 "");out.println("" s6 "");
-
7/30/2019 IP LAB Allignment1
69/76
out.println("" s7 "");out.println("" s8 "");i ;}out.println("");
if(i==1){
out.println("
Sorry!! No flights scheudleavailable
");}else{
out.println("");out.println("
Select Flight");out.println("");for(int temp=1;temp -
7/30/2019 IP LAB Allignment1
70/76
Kingfisher.jsp:
Kingfisher Airlines
-
7/30/2019 IP LAB Allignment1
71/76
reachtime = rs.getString(7);seat = rs.getString(8);seat1 = Integer.parseInt(seat);for(int i=1;i
-
7/30/2019 IP LAB Allignment1
72/76
SpiceJet.jsp
SpiceJet Airlines
-
7/30/2019 IP LAB Allignment1
73/76
reachtime = rs.getString(7);seat = rs.getString(8);seat1 = Integer.parseInt(seat);for(int i=1;i
-
7/30/2019 IP LAB Allignment1
74/76
Database
(similarly add for SpiceJet.mdb)
https://lh5.googleusercontent.com/-geYVKfIt81c/TYxvKIcE8yI/AAAAAAAAAy8/7g_j-qQrIlM/s1600/Kingfisher_Table.pnghttps://lh5.googleusercontent.com/-RFnZf4de93M/TYxvDEC4a7I/AAAAAAAAAy4/wuzCA3HQlOw/s1600/Kingfishser_Table_Design.pnghttps://lh5.googleusercontent.com/-geYVKfIt81c/TYxvKIcE8yI/AAAAAAAAAy8/7g_j-qQrIlM/s1600/Kingfisher_Table.pnghttps://lh5.googleusercontent.com/-RFnZf4de93M/TYxvDEC4a7I/AAAAAAAAAy4/wuzCA3HQlOw/s1600/Kingfishser_Table_Design.png -
7/30/2019 IP LAB Allignment1
75/76
OUTPUT
Index.jsp
airlinelist.jsp:
https://lh4.googleusercontent.com/-5Ux4j16Wz5I/TYxvYX6WVeI/AAAAAAAAAzE/veX_dt9HuNY/s1600/airlinelist.pnghttps://lh4.googleusercontent.com/-sIpg-pWvnQA/TYxvPh9dVFI/AAAAAAAAAzA/Hi_70WEUDN8/s1600/Home.pnghttps://lh4.googleusercontent.com/-5Ux4j16Wz5I/TYxvYX6WVeI/AAAAAAAAAzE/veX_dt9HuNY/s1600/airlinelist.pnghttps://lh4.googleusercontent.com/-sIpg-pWvnQA/TYxvPh9dVFI/AAAAAAAAAzA/Hi_70WEUDN8/s1600/Home.png -
7/30/2019 IP LAB Allignment1
76/76
Kingfisher.jsp:
RESULT:
https://lh3.googleusercontent.com/-7raMVWPUSIo/TYxvgKiqEQI/AAAAAAAAAzI/OBqbe4MG_OA/s1600/final.png