Thursday, April 12, 2012

Displaying cricket player's profile using AJAX



DISPLAYING CRICKET PLAYER’S PROFILE USING AJAX

AIM:

      To write a program using AJAX for displaying cricket player's profile.

ALGORITHM:

1.      Create an XHTML document (AjaxDemo.html) with the following.
(a)    Insert some images of cricket players.
(b)   Call the function getContent() with respect to the onmouseover event. The function accepts an argument that is the URL of another page contains the information about the player.
(c)    Call the function clearContent() with respect to the onmouseout event.
2.      Within this XHTML document, insert AJAX based JavaScript code with the following.
(a)    Create the object for ActiveXObject (for older versions of browsers such as IE5 and IE6).
(b)   Create the object for XMLHttpRequest (for modern browsers such as IE7+, Firefox, Chrome, Safari, and Opera).
(c)    AJAX send the request with the use of send() and open() methods.
(d)   Receive the response with the use of responseText Property.
(e)    AJAX Call the function diplayProfile() with respect to the event onreadystatechange.

PROGRAM:

AjaxDemo.html
<html>
<head>
<title>Ajax Demo...</title>
<style type="text/css">
  .box{border:1px solid blue;padding:10px}
</style>
<script type="text/javascript">
var req;
function getContent(url)
{
 if(window.ActiveXObject)
 {
  req=new ActiveXObject("Microsoft.XMLHTTP");
 }
 else if(window.XMLHttpRequest)
 {
  req=new XMLHttpRequest();
 }
 req.onreadystatechange=diplayProfile;
 req.open('POST',url,true);
 req.send(null);
}
function diplayProfile()
{
 if(req.readyState==4)
 {
  document.getElementById('contentArea').innerHTML=req.responseText;
 }
}
function clearContent()
{
 document.getElementById('contentArea').innerHTML='';
}
</script>
</head>
<body bgcolor="cyan">
<h1>Mouse over the image for More Information</h1>
<img src="sachin.jpg" height="95" width="80" onmouseover='getContent("sachin.html")' onmouseout='clearContent()'/>
<img src="dravid.jpg" height="95" width="80" onmouseover='getContent("dravid.html")' onmouseout='clearContent()'/>
<img src="kohli.jpg" height="95" width="80" onmouseover='getContent("kohli.html")' onmouseout='clearContent()'/>
<img src="raina.jpg" height="95" width="80" onmouseover='getContent("raina.html")' onmouseout='clearContent()'/>
<img src="yuvi.jpg" height="95" width="80" onmouseover='getContent("yuvi.html")' onmouseout='clearContent()'/>
<img src="veeru.jpg" height="95" width="80" onmouseover='getContent("veeru.html")' onmouseout='clearContent()'/>
<img src="dhoni.jpg" height="95" width="80" onmouseover='getContent("dhoni.html")' onmouseout='clearContent()'/>
<div class="box" id="contentArea"/>
</body>
</html>
sachin.html
<html>
<body>
<b>Full name:</b> Sachin Ramesh Tendulkar<br/><br/>
<b>Born:</b> April 24, 1973, Bombay (now Mumbai), Maharashtra<br/><br/>
<b>Major teams:</b> India, Asia XI, Mumbai, Mumbai Indians, Yorkshire<br/><br/>
<b>Nickname:</b> Tendlya, Little Master<br/><br/>
<b>Playing role:</b> Top-order batsman<br/><br/>
<b>Batting style:</b> Right-hand bat<br/><br/>
<b>Bowling style:</b> Right-arm offbreak, Legbreak googly
</body>
</html>

dravid.html
<html>
<body>
<b>Full name:</b> Rahul Sharad Dravid<br/><br/>
<b>Born:</b> January 11, 1973, Indore, Madhya Pradesh <br/><br/>
<b>Major teams:</b> India, Scotland, Asia XI, ICC World XI, Karnataka, Kent,
Marylebone Cricket Club, Rajasthan Royals, Royal Challengers Bangalore<br/><br/>
<b>Nickname:</b> The Wall<br/><br/>
<b>Playing role:</b> Top-order batsman<br/><br/>
<b>Batting style:</b> Right-hand bat<br/><br/>
<b>Bowling style:</b> Right-arm offbreak
</body>
</html>

kohli.html
<html>
<body>
<b>Full name:</b> Virat Kohli<br/><br/>
<b>Born:</b>November 5, 1988, Delhi<br/><br/>
<b>Major teams:</b>India, Delhi, India Red, India Under-19s, Royal Challengers Bangalore<br/><br/>
<b>Playing role:</b>Middle-order batsman<br/><br/>
<b>Batting style:</b>Right-hand bat<br/><br/>
<b>Bowling style:</b>Right-arm medium
</body>
</html>

raina.html
<html>
<body>
<b>Full name:</b> Suresh Kumar Raina<br/><br/>
<b>Born:</b>November 27, 1986, Muradnagar, Ghaziabad, Uttar Pradesh<br/><br/>
<b>Major teams:</b>India, Chennai Super Kings, India Blue, India Under-19s, Indian Board President's XI, Rajasthan Cricket Association President's XI, Uttar Pradesh, Uttar Pradesh Under-16s<br/><br/>
<b>Playing role:</b>Middle-order batsman<br/><br/>
<b>Batting style:</b>Left-hand bat<br/><br/>
<b>Bowling style:</b> Right-arm offbreak
</body>
</html>

yuvi.html
<html>
<body>
<b>Full name:</b>Yuvraj Singh<br/><br/>
<b>Born:</b>December 12, 1981, Chandigarh<br/><br/>
<b>Major teams:</b>India, Asia XI, Kings XI Punjab, Pune Warriors, Punjab, Yorkshire<br/><br/>
<b>Playing role:</b>Middle-order batsman<br/><br/>
<b>Batting style:</b>Left-hand bat<br/><br/>
<b>Bowling style:</b>Slow left-arm orthodox
</body>
</html>

veeru.html
<html>
<body>
<b>Full name:</b>Virender Sehwag<br/><br/>
<b>Born:</b>October 20, 1978, Delhi<br/><br/>
<b>Major teams:</b>India, Asia XI, Delhi, Delhi Daredevils, ICC World XI, India Blue, Leicestershire, Rajasthan Cricket Association President's XI<br/><br/>
<b>Playing role:</b>Top-order batsman<br/><br/>
<b>Batting style:</b>Right-hand bat<br/><br/>
<b>Bowling style:</b>Right-arm offbreak
</body>
</html>

dhoni.html
<html>
<body bgcolor="cyan">
<b>Full name:</b> Mahendra Singh Dhoni<br/><br/>
<b>Born:</b>July 7, 1981, Ranchi, Bihar (now Jharkhand)<br/><br/>
<b>Major teams:</b>India, Asia XI, Bihar, Chennai Super Kings, Jharkhand<br/><br/>
<b>Playing role:</b>Wicketkeeper batsman<br/><br/>
<b>Batting style:</b>Right-hand bat<br/><br/>
<b>Bowling style:</b>Right-arm medium
</body>
</html>


 Images



dravid.jpg
kohli.jpg


raina.jpg

sachin.jpg

veeru.jpg

yuvi.jpg

dhoni.jpg














OUTPUT SCREENSHOTS








Displaying book details using XML and XSLT


DISPLAYING BOOK DETAILS USING XML AND XSLT


Aim:
         To write XML program to display book details with XSL

Algorithm:
1. Create an XSL page
2. Set styles for an XML file and save the file with extension .xsl
3. Create another file and include XML tags
4. Write code to link the XSL file
5. Save the file with extension .xml
6. Run the XML file
7. Verify the result

Simple.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
<books_menu>
<book>
<name>
Computer Architecture </name>
<price> 234.56
</price>
<description>
Computer Is an electronic device
</description>
<pages>456
</pages>
</book>
<book>
<name>
Computer Organisation </name>
<price> 234.56
</price>
<description>
Computer has input and output devices
</description>
<pages>456
</pages>
</book>
</books_menu>

simple.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xlmns="http://www.w3.org/1999/xhtml">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="books_menu/book">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold">
<xsl:value-of select="name"/>
</span>
</div>
<div style="margin-left:20px;margin-bottom:1cm;font-size:10pt">
<xsl:value-of select="description"/>
<span style="font-style:italic">
<xsl:value-of select="pages"/>
(pages in book)
</span>
</div>
</xsl:for-each>
</body>
</html>






OUTPUT SCREENSHOTS




Displaying student details using XML and XSLT


DISPLAYING STUDENT DETAILS USING XML AND XSLT

ALGORITHM:

1.      Create an XML document (stud.xml) that contains the markup tags such as <name>, <dept>, and <rno>.
2.      Create an XSL document (stud.xsl) that defines the style to display an XML document.
3.      Associate style sheet (XSL) with XML using the markup <?xml-stylesheet>
4.      Load the XML document (stud.xml) in the browser.

stud.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="stud.xsl"?>
<studInfo>
<stud>
<name>Abhilash</name>
<dept>IT</dept>
<rno>97709205001</rno>
</stud>
<stud>
<name>Akhila</name>
<dept>IT</dept>
<rno>97709205002</rno>
</stud>
<stud>
<name>Anaswara</name>
<dept>IT</dept>
<rno>97709205003</rno>
</stud>
</studInfo>
stud.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Student Details - Transformation</title>
</head>
<body>
<table border="1">
<caption>Student Details</caption>
<tr>
<th>Name</th><th>Department</th><th>Register No</th>
</tr>
<xsl:for-each select="/studInfo/stud">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="dept"/></td>
<td><xsl:value-of select="rno"/></td>
</tr>
</xsl:for-each>
</table>
</body>   
 </html>    
</xsl:template>    
</xsl:transform>

OUTPUT SCREENSHOTS



Displaying student marklist using Java Server Pages



DISPLAYING STUDENT MARK LIST USING JSP

AIM:
      To create a three tier application for displaying student mark list using JSP and database.

ALGORITHM:
1.       Design the HTML page (stud.html) with the following
a)   Create a form to get the input (Register Number) from the user.
b)   Set the URL of the server (marklist.jsp) as the value of the action attribute.
c)   Use submit button to invoke the server and send the form data to the server.
2.       Create the JSP file with the following
a)    Read the parameter value (Register Number) from the form by using the method getParameter().
b)    Server retrieves the details from the database table with respect to the form input.
c)    Server displays the mark list to the client as the response.

marklist.jsp:

<%@ page contentType="text/html" language="java" import="java.sql.*"%>
<html>
<head>
<title>Three Tier Application</title>
<style type="text/css">
  body{color:blue;font-family:courier;text-align:center}
</style>
</head>
<body>
<h2>EXAMINATION RESULT</h2><hr/>
<%
String str=request.getParameter("regno");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:markDS");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT*FROM markTab WHERE rno="+str);
while(rs.next())
{
%>
Register No:<%=rs.getObject(1)%><br/>
Name:<%=rs.getObject(2)%><br/>
<table border="1">
<th>SUBJECT</th><th>Mark</th>
<tr><td>Network Programming and Management</td><td><%=rs.getObject(3)%></td></tr>
<tr><td>Object Oriented Analysis and Design</td><td><%=rs.getObject(4)%></td></tr>
<tr><td>Cryptography and Network Security</td><td><%=rs.getObject(5)%></td></tr>
<tr><td>Embedded Systems</td><td><%=rs.getObject(6)%></td></tr>
<tr><td>Web Technology</td><td><%=rs.getObject(7)%></td></tr>
<tr><td>Software Requirement and Engineering</td><td><%=rs.getObject(8)%></td></tr>
</table>
<%
}
%>
<br/>
<a href="stud.html">Back</a>
</body>
</html>

stud.HTML:

<html>
<head>
<title>Three Tier Application</title>
<style type="text/css">
  body{color:blue;font-family:courier;text-align:center}
</style>
</head>
<body>
<h2>EXAMINATION RESULT</h2><hr/>
<form name="f1" method"GET" action="marklist.jsp">
Enter Your Reg.No:
<input type="text" name="regno"/><br/><br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" value="SUBMIT"/>
</form>
</body>
<html>


DATABASE






OUTPUT SCREENSHOTS