Vous êtes sur la page 1sur 26

Image mapping

<html> <body> <p> <b>Some Popular Planets from Solar system</b> </p> <img src="C:\Documents and Settings\User\My Documents\My Pictures\solar system.jpg" width="145" height="126" usemap="#solarmap"> <map id="solarmap" name="solarmap"> <area shape="rect" coords="10,10,40,25" alt="Mercury" href="D:\\HTML_Examples\Mercury.html"> <area shape="rect" coords="35,20,75,55" alt="venus" href="D:\\HTML_Examples\venus.htm"> <area shape="rect" coords="65,55,115,85" alt="Earth" href="D:\\HTML_Examples\earth.htm"> <area shape="rect" coords="90,85,135,120" alt="Saturn" href="D:\\HTML_Examples\saturn.htm"> </map> <p><b>Note:</b> Some Planets from our solar system are displayed here click on any planet and you will get some useful information about them</p> </body> </html>

Output:

Ex #2:

Types of Cascading Style Sheets <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head> <meta http-equiv="Content-Type" content="text/html; charset=iso-88591" /> <title>Types of CSS</title> <!--External Style Sheet--> <link rel="stylesheet" type="text/css" href=" external.css" /> <!--Internal or Embedded Style Sheet--> <style type="text/css"> h2 { background-color:#009933; background-position:center; background-repeat:repeat-x; font-family:Georgia, "Times New Roman", Times, serif; font-size:18px; } h3 { border-width:thin; border-style:dashed; border-top-color:#00FF66; border-width:thick; } </style> </head> <body> <h4 style="text-align:center">This is the output for External Stylesheet</h4> <h1>Hi</h1> <h4 style="text-align:center">This is the output for Internal or Embedded Stylesheet</h4> <h2>Hello</h2> <h3>Welcome</h3> <p> RAM is the best known form of computer memory and easy to upgrade. See more computer hardware pictures. Random access memory (RAM) is the best known form of computer memory. RAM is considered "random access" because you can access any memory cell directly if you know the row and column that intersect at that cell.

</p> <!-- Inline StyleSheet--> <h4 style="text-align:center">This is the output for InLine Stylesheet</h4> <p style="background:#CC0033; background-image:url(../../../Program Files/Apache Software Foundation/Tomcat 6.0/Sunset.jpg);"> </body>RAM is the best known form of computer memory and easy to upgrade. See more computer hardware pictures. Random access memory (RAM) is the best known form of computer memory. RAM is considered "random access" because you can access any memory cell directly if you know the row and column that intersect at that cell. </p> </html> external.css body { font-family: Arial, Helvetica, sans-serif; background:#999999; border:thin; } P { font:Arial, Helvetica, sans-serif; font-size:12px; font-size-adjust:inherit; font-stretch:ultra-condensed; font-weight:900; text-align:center; text-decoration:line-through; text-transform:uppercase; } h1 { font-family: Arial, Helvetica, sans-serif; font-variant:small-caps; color: #CC3300; }

Output:

Ex #3:

<html> <head> <title>The Student Registration Form</title> <script type=text/javascript> function validate() { var i; var name_str=document.my_form.name; var phoneID=document.my_form.ph_txt; var ph_str=document.my_form.ph_txt.value; var str=document.my_form.Email_txt.value; if((name_str.value==null)||(name_str.value=="")) { alert("Enter some name") return false } if(document.my_form.Age_txt.value=="") { alert("Enter Some Age") return false } if((document.my_form.Age_txt.value<"5")&& (document.my_form.Age_txt.value>"21")) { alert("Invalid Age") return false } if(ph_str.length<1 ||ph_str.length>11) { alert("Invalid length of Phone Number") return false } for (i = 0; i < ph_str.length; i++) { var ch = ph_str.charAt(i); if (((ch < "0") || (ch > "9"))){ alert("Invalid Phone Number") phoneID.focus() return false } } var index_at=str.indexOf("@")

var len=str.length var index_dot=str.indexOf(".") var emailID=document.my_form.Email_txt if ((emailID.value==null)||(emailID.value=="")) { alert("Please Enter your Email ID") emailID.focus() return false } if (str.indexOf("@")==-1) { alert("Invalid E-mail ID") return false } if (str.indexOf(".")==-1 || str.indexOf(".")==0 || str.indexOf(".")==index_at) { alert("Invalid E-mail ID") return false } if (str.indexOf("@",(index_at+1))!=-1) { alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1) { alert("Invalid E-mail ID") return false } if (!document.my_form.group1[0].checked && !document.my_form.group1[0].checked) { alert("Please Select Sex"); return false; } if (!document.my_form.group1[0].checked && !document.my_form.group1[0].checked) { alert("Please Select Sex"); return false; } return true }

</script> </head> <body bgcolor=aqua> <center><h3>Application Form</h3></center> <form name=my_form onsubmit=validate()> <strong>Name:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</strong> <input type=text name=name><br/> <strong>Age:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</strong> <input type=text name=Age_txt><br/> <strong>Phone No:&nbsp</strong> <input type=text name=ph_txt><br/> <strong>Email:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</strong> <input type=text name=Email_txt><br/><br/> <strong>Sex:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp </strong> <input type="radio" name="group1" value="Male">Male&nbsp&nbsp&nbsp&nbsp <input type="radio" name="group1" value="Female">Female<br/><br/><br/> <strong>Hoby: </strong> &nbsp&nbsp <input type="checkbox" name ="option1" value="Singing">Singing<br/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="checkbox" name ="option1" value="Reading">Reading<br/> &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="checkbox" name ="option1" value="T.V.">Watching T.V<br/> <br/><br/> <strong>Country:</strong> <select name="My_Menu"> <option value="India">India</option> <option value="China">China</option> <option value="Shrilanka">Shrilanka</option> </select> <center> <input type=submit value=Submit></br> </center> </body> </html>

Output:

Ex #4: Source Code: App.java

//This program changes the color of text


//It also set the background color //It also loads the image //It makes use of checkboxgroup and button import java.awt.*; import java.awt.event.*; import java.applet.*; /* <applet code="Experiment3" width=300 height=300> </applet> */ public class app extends Applet implements ItemListener { int currcolor=5; int flag=1; String text="Click any of the button"; Button buttons[]=new Button[5]; String colours[]={"Red","Blue","Green","Yellow","Magenta"}; Image img; CheckboxGroup cbg=new CheckboxGroup(); Checkbox box1=new Checkbox("Background Color",cbg,true); Checkbox box2=new Checkbox("Text Color",cbg,false); Checkbox box3=new Checkbox("Loading Image",cbg,false); public void init() { for(int i=0;i<5;i++) { buttons[i]=new Button(" "); add(buttons[i]); } buttons[0].setBackground(Color.red); buttons[1].setBackground(Color.blue); buttons[2].setBackground(Color.green); buttons[3].setBackground(Color.yellow); buttons[4].setBackground(Color.magenta); add(box1); add(box2); add(box3); box1.addItemListener(this);

box2.addItemListener(this); box3.addItemListener(this); } public void itemStateChanged(ItemEvent ev) { if(box1.getState()==true) flag=1; else if(box2.getState()==true) { text="Default color is black"; flag=2; } else if(box3.getState()==true) { img=getImage(getDocumentBase(),"cutecat.jpg"); flag=3; } repaint(); } public void paint(Graphics g) { if(flag==2) { g.drawString(text,30,100); switch(currcolor) { case 0: g.setColor(Color.red); break; case 1: g.setColor(Color.blue); break; case 2: g.setColor(Color.green); break; case 3: g.setColor(Color.yellow); break; case 4: g.setColor(Color.magenta); break; case 5: g.setColor(Color.black); break; } g.drawString(text,30,100);

} else if(flag==1) { g.drawString(text,30,100); switch(currcolor) { case 0: setBackground(Color.red); break; case 1: setBackground(Color.blue); break; case 2: setBackground(Color.green); break; case 3: setBackground(Color.yellow); break; case 4: setBackground(Color.magenta); break; case 5: setBackground(Color.white); break; } } else if(flag==3) { g.drawImage(img,20,90,this); } } public boolean action(Event e,Object o) { for(int i=0;i<5;i++) { if(e.target==buttons[i]) { currcolor=i; text="You have chosen "+colours[i]; repaint(); return true; } } return false; }

} Output:

Ex #5:

Source Code: my_servletDemo.java Servlet Program: 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(); } }

HTML Program:
<html> <head> <title>Student Information Form</title> </head> <body> <center> <form name="form1" action="http://localhost:8080/my_servletDemo" method="post"> <h3>Enter student information in following fields -</h3> <table> <tr> <td><b>Roll Number</b></td> <td><input type="text" name="Roll Number" size="25" value=" "></td> </tr>

<tr> <td><b>Student Name</b></td> <td><input type="text" name="Student Name" size="25" value=" "></td> </tr> <tr> <tr> <td><b>Student Address</b></td> <td><input type="text" name="Address" size="50" value=" "></td> </tr> <tr> <td><b>Phone</td> <td><input type="text" name="Phone" size="25" value=" "></td> </tr> <tr> <td><b>Total Marks</td> <td><input type="text" name="Total Marks" size="10" value=" "></td> </tr> </table> <input type="submit" value="submit"> </form> </center> </body> </html>

Output:

Ex #6

Source code: <%@ page language="java" import="java.sql.*" %> <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <% String SeatNum,Name; String ans1,ans2,ans3,ans4,ans5; int a1,a2,a3,a4,a5; a1=a2=a3=a4=a5=0; Connection connect=null; Statement stmt=null; ResultSet rs=null; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url = "jdbc:odbc:StudentDB1"; connect = DriverManager.getConnection(url, " ", " "); if(request.getParameter("action")!=null) { SeatNum = request.getParameter("Seat_no"); Name = request.getParameter("Name"); ans1 =request.getParameter("group1"); if(ans1.equals("True")) a1=2; else a1=0;

ans2 = request.getParameter("group2"); if(ans2.equals("True")) a2=0; else a2=2; ans3 = request.getParameter("group3"); if(ans3.equals("True")) a3=0; else a3=2; ans4 = request.getParameter("group4"); if(ans4.equals("True")) a4=2; else a4=0; ans5 = request.getParameter("group5"); if(ans5.equals("True")) a5=0; else a5=2; int Total=a1+a2+a3+a4+a5;

stmt = connect.createStatement(); String query = "INSERT INTO StudentTable (" + "Seat_no,Name,Marks" + ") VALUES ('" +SeatNum + "', '" + Name + "', '"+Total+ "')"; int result = stmt.executeUpdate(query); stmt.close(); stmt = connect.createStatement();

query = "SELECT * FROM StudentTable WHERE Name="+"'"+Name+"'"; rs = stmt.executeQuery(query); %> <html><head><title>Student Mark List</title></head> <body bgcolor=khaki> <center> <h2>Students Marksheet</h2> <h3>Name of the College:ABC College of Engineering</h3> <table border="1" cellspacing="0" cellpadding="0"> <tr> <td><b>Seat_No</b></td> <td><b>Name</b></td> <td><b>Marks</b></td> </tr> <% while(rs.next()) { %> <tr> <td><%=rs.getInt(1)%></td> <td> <%=rs.getString(2)%></td> <td> <%=rs.getString(3)%></td> </tr> <% } rs.close(); stmt.close();

connect.close(); %> </table> </center> <br/> <br/><br/> <table> <tr><td><b>Date:<%=new java.util.Date().toString() %></td></tr> <tr><td><b>Signature: X.Y.Z. <b></td></tr> </table> <div> <a href="http://127.0.0.1:8080/jsp-examples/StudExam/Exam.jsp">Click here to go back</a> </body> </html> <%}else{%> <html> <head><title>Online Examination</title> <script language="javascript"> function validation(Form_obj) { if(Form_obj.Seat_no.value.length==0) { alert("Please,fill up the Seat Number"); Form_obj.Seat_no.focus(); return false; } if(Form_obj.Name.value.length==0) {

alert("Please,fill up the Name"); Form_obj.Name.focus(); return false; } return true; } </script> </head> <body bgcolor=lightgreen> <center> <h1>OnLine Examination</h1> </center> <form action="Exam.jsp" method="post" name="entry" onSubmit="return validation(this)"> <input type="hidden" value="list" name="action"> <table> <tr> <td><h3>Seat Number:</h3></td> <td><input type="text" name="Seat_no"></td> </tr> <tr> <td><h3>Name:</h3></td> <td><input type="text" name="Name" size="50"></td> </tr> <hr/> <tr> <td><b>Total Marks:10(Each question carries equal marks) </b></td>

<td></td><td></td><td></td><td><b>Time: 15 Min.</b></td> </tr> </table> <hr/> <b>1. Apache is an open source web server</b><br/> <input type="radio" name="group1" value="True">True <input type="radio" name="group1" value="False">False<br> <br/>

<b>2. In Modern PC there is no cache memory.</b><br/> <input type="radio" name="group2" value="True">True <input type="radio" name="group2" value="False">False<br> <br/>

<b>3. Tim-Berner Lee is the originator of Java.</b><br/> <input type="radio" name="group3" value="True">True <input type="radio" name="group3" value="False">False<br> <br/>

<b>4.JPG is not a video file extension.</b><br/> <input type="radio" name="group4" value="True">True <input type="radio" name="group4" value="False">False<br> <br/>

<b>5. HTTP is a statefull protocol</b><br/> <input type="radio" name="group5" value="True">True <input type="radio" name="group5" value="False">False<br>

<hr/>

<center> <input type = "submit" value="Submit"> <input type = "reset" value="Clear"><br><br> </center> </form> <%}%> OUTPUT:

Exp:7 SimpleXML.xml <?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl" href="SimpleXml.xsl"?> <Student> <Person-Details> <name>Anand</name> <address>Pune</address> <std>Second</std> <marks>70 percent</marks> </Person-Details> <Person-Details>

<name>Anuradha</name> <address>Chennai</address> <std>Second</std> <marks>90 percent</marks> </Person-Details> <Person-Details> <name>Archana</name> <address>Mumbai</address> <std>Forth</std> <marks>80 percent</marks> </Person-Details> <Person-Details> <name>Monika</name> <address>Delhi</address> <std>Tenth</std> <marks>77 percent</marks> </Person-Details> </Student> SimpleXMl.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> <h2>Students Database</h2> <table border="1"> <tr> <th>Name</th> <th>Address</th> <th>Standard</th> <th>Marks</th> </tr> <xsl:for-each select="Student/Person-Details"> <tr> <td><xsl:value-of select="name"/></td>

<td><xsl:value-of select="address"/></td> <td><xsl:value-of select="std"/></td> <td><xsl:value-of select="marks"/></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>

OUTPUT:

Vous aimerez peut-être aussi