Beruflich Dokumente
Kultur Dokumente
LAB MANUAL
1. Develop static pages (using Only HTML) of an online Book store.The
pages should resemble: www.amazon.com. The website should consist
the following pages.
Home page
Registration and User Login
]User Profile Page
Books catalog
Shopping Cart
Payment By Credit Card
Order Conformation
PROGRAM:
frame.html
<html>
<head>
<title>frame</title>
</head>
<frameset rows="30%,*">
<frame name="frame1" src="online.html">
<frameset cols="30%,*">
<frame name="frame2" src="list.html">
<frame name="frame3" src="i.html">
</frameset>
</html>
online.html
<html>
<head></head>
<body bgcolor="pink">
<a target="frame1">
</a>
<marquee direction="right">
<h1 align="center"><u><i><font face="algerian">ONLINE BOOK
STORE</font></i></u></h1>
</marquee>
</body>
</html>
list.html
<html>
<head></head>
<body bgcolor="#aaffbb">
<a target="frame2"></a>
<a href="reg.html" target="frame3">
<center><i><font color="red"
>REGISTRATION</font></i></center></a><br>
<a href="log.html" target="frame3">
<center><i><font color="green" >LOGIN</font></i></center></a><br>
<a href="profile.html" target="frame3">
<center><i><font color="gray"
>PROFILE</font></i></center></a><br>
<a href="bc.html" target="frame3">
<center><i>BOOKS CATALOG</i></center></a><br>
<a href="sc.html" target="frame3">
<center><i><font color="black">SHOPPING
CART</font></i></center></a><br>
<a href="pc.html" target="frame3">
<center><i><font color="brown">PAYMENT BY
CREDITCARD</font></i></center>
</a>
</body>
</html>
i.html
<html>
<head></head>
<body bgcolor="#aaccbb">
<a target="frame3"></a>
<center><img src="E:\sh\images1.jpg" height="400"
width="300"></center>
</body>
</html>
reg.html
<html>
<head></head>
<body bgcolor="#bbaa66">
<h3 align="center"><i><u>REGISTRATION</u></i></h3>
Email Id:
<input type="text" size="10"></input><br><br>
Password:
<input type="password" size="8"></input><br><br>
confirm password:
<input type="password" size="8"></input><br><br>
<input type="submit" value="submit"></input>
<input type="button" value="cancel"></input>
</body>
</html>
log.html
<html>
<head></head>
<body bgcolor="#aa66dd">
<h3 align="center"><i><u>LOGIN</u></i></h3><br><br><br>
Login:
<input type="text" size="10"></input><br><br>
Password:
<input type="password" size="8"></input><br><br>
<input type="submit" value="submit"></input>
<input type="button" value="cancel"></input>
</body>
</html>
profile.html
<html>
<head></head>
<body bgcolor="#bbaacc">
<h3 align="center"><u><i>PROFILE</i></u></h3>
Name:
<input type="text" size="10"></input><br><br>
Address:
<textarea rows="4" cols="20"></textarea><br><br>
Phone No:
<input type="text" size="12" value="+91"></input><br><br>
<input type="submit" value="submit"></input>
<input type="button" value="cancel"></input>
</body>
</html>
bc.html
<html>
<head></head>
<body bgcolor="#ddaaff">
<form>
Subject:Web Technologies<br>
<select name="wt">
<option value="w">Web Programming,Chris Bates,Rs250</option>
<option value="i">Internet And World Wide Web,Dietel,Rs450</option>
<option value="wa">Web App TEchone,Niit,Phi,Rs255</option>
</select><br>
Subject:Data Ware Housing And Data Mining<br>
<select name="dmdw">
<option value="d">Data Mining
Concepts&testing,Jiaineiham,Rs280</option><br>
<option value="i">Data Mining Introduction,Margareth
Dunham,Rs380</option><br>
<option value="dw">Data Warehousing in Real
World,Samanhory,Rs255</option><br>
</select><br>
sc.html
<html>
<head></head>
<body bgcolor="#dd66aa">
<table cellspacing="100">
<tr>
<td>
<img src="E:\sh\books1.jpg"><br>
Phychedelics<br>
knuckles<br>
Rs200
</td>
<td>
<img src="E:\sh\books2.jpg"><br>
The Capitalist World Economy<br>
Dietel<br>
Rs320</td>
</tr>
<tr>
<td>
<img src="E:\sh\books3.jpg"><br>
Algebra<br>
Jiaweiham<br>
Rs.430</td>
<td>
<img src="E:\sh\books4.jpg"><br>
Technical Analysis<br>
Arun k pujjari<br>
Rs.500</td>
</tr>
</table>
</body>
</html>
pc.html
<html>
<head></head>
<body bgcolor="#ddccff">
<form>
<table align="center" cellpadding="1" cellspacing="1"
width="30%"<tr><td>card no:</td>
<td ><input type="text" name="cno" size="16"></input><br></td></tr>
<tr><td> Card Type:</td>
<td><input type="text" size="10"></input><br></td></tr>
<tr>
<td>Cvv No:</td>
<td><input type="text" size="3"></input><br></td></tr>
<tr><td>Amount:</td>
<td><input type="text" size="8"></input><br></td></tr>
<tr><td>Valid Date:</td>
<td><input type="text" size="2"></input>/
<input type="text" size="4"></input><br></td></tr></table>
<br><center>
<a href="s.html"><strong>SUBMIT</strong></a>
<input type="reset" value="reset"></input>
</center>
</form>
</body>
</html>
s.html
<html>
<head></head>
<body bgcolor="#aabbcc">
<p>
Order is confirmed. with in two days you will collect ur books.<br>
Thank You for ur registering in our Online book store</p>
</body>
</html>
3. Create and save an XML document at the server , which contains Ten
users information. Write a program which takes user id as an input and
returns the user details by taking the user information from the XML
document .
EMPLOYEE.XML
<emps><emp>
<empno>1</empno>
<ename>a</ename>
<dob>12-1-80</dob>
<phno>8514248211</phno>
<email>satheesh_pani@yahoo.co.in</email>
</emp>
<emp>
<empno>2</empno>
<ename>b</ename>
<dob>12-1-80</dob>
<phno>8514248211</phno>
<email>satheesh_pani@yahoo.co.in</email>
</emp>
<emp>
<empno>3</empno>
<ename>c</ename>
<dob>21-323</dob>
<phno>9989643186</phno>
<email>teh_12@yahoo.co.in</email>
</emp>
<emp>
<empno>4</empno>
<ename>d</ename>
<dob>80</dob>
<phno>100</phno>
<email>pani@gmail.com</email>
</emp>
<emp>
<empno>5</empno>
<ename>e</ename>
<dob>1-82-98</dob>
<phno>343276</phno>
<email>shiva_nh317@yahoo.co.in</email>
</emp>
<emp>
<empno>6</empno>
<ename>f</ename>
<dob>45-09</dob>
<phno>238922</phno>
<email>greed@gmail.com</email>
</emp>
<emp>
<empno>7</empno>
<ename>i</ename>
<dob>12</dob>
<phno>48211</phno>
<email>dd@hgjgjyahoo.co.in</email>
</emp>
<emp>
<empno>8</empno>
<ename>p</ename>
<dob>11-80</dob>
<phno>5142411</phno>
<email>hhghpani@yahoo.co.in</email>
</emp>
</emps>
EMP.HTML
<html><head>
<script src="loadxmldoc.js">
</script></head>
<body>
<script>
xmldoc=loadxmldoc("employee.xml");
x=xmldoc.getElementsByTagName("empno");
var empno=prompt("enter employee no");
for(i=0;i<x.length;i++)
{
if(x[i].childNodes[0].nodeValue==empno)
break;
}
if(i<x.length)
{
document.writeln("Name:<b>"+xmldoc.getElementsByTagName("enam
e")[i].childNodes[0].nodeValue+"</b></br>");
document.writeln("dob:<b>"+xmldoc.getElementsByTagName("dob")
[i].childNodes[0].nodeValue+"</b></br>");
document.writeln("phno:<b>"+xmldoc.getElementsByTagName("phno")
[i].childNodes[0].nodeValue+"</b></br>");
document.writeln("email:<b>"+xmldoc.getElementsByTagName("email"
)[i].childNodes[0].nodeValue+"</b></br>");
else
{
LOADXMLDOC.js
function loadxmldoc(dname)
{
xmldoc=new ActiveXObject("microsoft.XMLDOM");
xmldoc.load(dname);
return(xmldoc);
}
4. Bean Assignments
a.Create a JavaBean which gives the exchange value of INR(Indian
Rupees)
into equivalent American/Canadian/Austarlian Dollor value.
package Exchange;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
public Exchange()
{
setBackground(Color.WHITE);
}
public double getrIndianRupees()
{
return indianRupees;
}
this.indianRupees=indianRupees;
repaint();
}
public void setIndianRupees(dounle indianRupees)
{
public Dimension getMinimumSize()
{
return newDimension(180,72);
}
public void paint()
{
Font f=new Font("Dialog",Font.BOLD,12);
g.setFont(F);
g.drawString("USDOLLORS",7,22);
g.drawString("CADOLLORS",7,42);
g.drawString("AUDOLLORS",7,62);
displayExchange(g);
}
public void displayExchange(Graphics g)
{
g.drawString("USEXCHANGE",100,22);
g.drawString("CAEXCHANGE",100,42);
g.drawString("AUEXCHANGE",100,62);
}
private String getUSExchange()
{
double usvalue=indianRupees|USA_DOLLOR;
usvalue=Math.round(usvalue);
return new Double(usvalue).toString();
}
private String getCAExchange()
{
double cavalue=indianRupees|CAN_DOLLOR;
cavalue=Math.round(cavalue);
return new Double(cavalue).toString();
}
private String getAUExchange()
{
double auvalue=indianRupees|AUS_DOLLOR;
auvalue=Math.round(auvalue);
return new Double(auvalue).toString();
}
}
package Exchange;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;
import count;
public class ExchangeBeanInfo extends SimpleBeanInfo
{
public PropertyDescriptor[ ] getPropertyDescriptor()
{
try
{
PropertyDescriptor ExchangegetProperty=new
PropertyDescriptor("indianrupees",Exchange.class);
return new PropertyDescriptor[ ]
{
exchange property;
}
}
catch(Exception e)
{
return null;
}
}
}
4.Bean Assignments
PROGRAM:
package count;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphiocs;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
package count;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBaenInfo;
public class CountBeanInfo extends SimpleBeanInfo
{
public PropertyDescriptor[ ] getPropertyDescriptors()
{
try
{
PropertyDescriptor countProperty=new
PropertyDescriptor("count",count.class);
return new PropertyDescriptor[ ]
{
count Property;
}
}
catch(Exception e)
{
return null;
}
}
}
4.Bean Assignments
d.Craete two beans Traffic Light(Implemented as a Label with only three
background colours-Red,Green,Yellow) and Automobile(Implemented as
a TestBox
which states its state/movement). The state of the Automobile should
depend on
the following Light Transition Table.
PROGRAM:
package automobile;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.PropertyChangeEvent;
import java.awt.event.PropertyChangeListener;
repaint();
}
public synchriniozed void removeTransitionStateChange()
{
repaint();
}
public Dimension getMinimumSize()
{
return new Dimension(220,35);
}
public void paint(Graphics g)
{
Font f=new Font("Dialog",FONT.BOLD,12);
g.setFont(f);
g.drawString("count",7,22);
}
private String getMobileState()
{
if("GreenToRed".equals(transition))
{
return "stopped";
}
else if("RedtoOrange".equals(transition))
{
return "ready";
}
else if("OrangeToGreen".equals(transition))
{
return "move";
}
else
{
return "Invalid Transition";
}
}
public void property change(PropertyChangeEvent event)
{
int oldValue=((Integer)event.getOldValue()).intValue();
int newValue=((Integer)event.getNewValue()).intValue();
if(oldValue==RED && newValue==ORANGE)
{
transition="RedToOrange";
}
else if(oldValue==ORANGE && newValue==GREEN)
{
transition="OrangeToGreen";
}
else if(oldValue==GREEN && newValue==RED)
{
transition="GreenToRed";
}
repaint();
}
}
package trafficlight;
import java.beans.PropertyEditorSupport
{
private int signa;;
public void setValue(Object o)
{
signal=((Integer)o).intVAlue();
firePropertyChange();
}
public Object getValue()
{
return new Integer(signal);
}
public String getAsText()
{
switch(signal)
{
case TrafficLight.RED:
return TrafficLight.COLOR_RED;
case TrafficLight.ORANGE:
return TrafficLight.COLOR_ORANGE;
case TrafficLight.GREEN:
return TrafficLight.COLOR_GREEN;
default: return TrafficLight.COLOR_RED;
}
}
public void setAsText(String s) throws IllegalArgumentException
{
if(s.equalsIgnoreCase(TrafficLight.COLOR_RED))
signal=TrafficLight.RED;
else
if(s.equalsIgnoreCase(TrafficLight.COLOR_ORANGE))
signal=TrafficLight.ORANGE;
else if(s.equalsIgnoreCase(TrafficLight.COLOR_GREEN))
signal=TrafficLight.GREEN;
else
signal=TrafficLight.RED;
firePropertyChange();
}
public String[ ] getTags()
{
return new String[ ]
{
TrafficLight.COLOR_RED,
TrafficLight.COLOR_ORANGE,
TrafficLight.COLOR_GREEN
}
}
}
package trafficlight;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfp;
import stickfigure.MoodEditor;
public class TrafficLightBeanInfo extends SimpleBeanInfo
{
public Property Descriptor[ ] getPropertyDescriptor()
{
try
{
System.out.println("Calling Traffic Light Info..");
PropertyDescriptor ExchangeProperty=new
PropertyDescriptor("indianRupees",Exchange.class);
trafficLight.setPropertyEditoprClass(SignalEditor.class);
trafficLight.setBound(true);
return new PropertyDescriptor[ ]
{
exchange property;
}
}
catch(Exception e)
{
return null;
}
}
}
package tarfficlight;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
PROGRAM
login.html
<html>
<head>
<tilte>Login Page
</title>
</head>
<body>
<form action="Login" method="post">
<table>
<tr><td colspan="2">please enter the LoginID and Password</td></tr>
<tr> <td colspan="2"><font color="red"><%=strMessage%>
</font></td></tr>
<tr><td>LoginID</td>
<td><input type="text" name="loginID" value=""></td></tr>
<tr><td>Password</td>
<td><input type="password" name="loginPwd" value=""></td></tr>
<tr><td><input type="submit" name="submit" value="submit"></td>
<td><input type="reset" name="reset" value="reset"></td></tr>
</table>
</form>
</body>
</html>
LoginServlet.java
import java.io.IOException;
import java.servlet.RequestDispatcher;
import java.servlet.ServletConfig;
import java.servlet.ServletException;
import java.servlet.http.HttpServlet;
import java.servlet.http.HttpServletRequest;
import java.servlet.http.HttpServletResponse;
public class LoginServlet extends HttpServlet
{
private String userID;
private String userPassword;
public void init(ServletConfig config)
{
userID=config.getInitParameter("userid");
userPassword=config.getInitParameter("userpassword");
}
public void doPost(HttpServletRequest
request,HttpServletResponse response) throws
ServletException,IOException
{
String loginID=rquest.getParameter("loginID");
String loginID=rquest.getParameter("loginPwd");
if(loginID!=null && loginPwd!=NULL)
{
if(checkAuthentication(loginID,loginPwd))
{
response.sendRedirect("Success.html");
}
else
{
System.out.println("Invalid Login....");
String strMessage="Invalid LoginID|
Password";
request.setAttribute("message",setMessage);
RequestDispatcher
dispatch=request.getRequestDispatcher("Login.jsp");
dispatch.forward(request,response);
}
}
else
{
response.sendRedirect("Login.jsp");
}
}
private Boolean checkAuthentication(String loginID,String
loginPwd)
{
boolean flag=false;
System.out.println("Checking Login.....");
if(loginID.equalsIgnoreCase(userId) &&
loginPwd.equals(userPassword))
{
falg=true;
}
System.out.println("Flag is"+flag);
return flag;
}
}
success.html
<html>
<head>
<title>Login Success
</title>
</head>
<body>
<h1>Successfully Logged In!</h12>
</body>
</html>
Web.xml
PROGRAM
jspSuccess.jsp