21 
 
21 
 
5. Create two beans traffic light(only 3 colors –red,green,yellow)and automobile(implemented as a 
Textbox which states its state/movement).the state of the Automobile should depend on the following 
Light Transition Table. 
Light Transition                         Automobile State 
Red ->yellow                                    Ready 
TrafficPerson : 
package demo; 
import java.awt.Panel; 
import java.awt.event.*; 
import java.io.PrintStream; 
import java.io.Serializable; 
import javax.swing.JTextField; 
import java.beans.*; 
public class TrafficPerson extends Panel 
implements Serializable, PropertyChangeListener 
public TrafficPerson() 
tx = new JTextField(12); 
state="Ready"; 
tx.setHorizontalAlignment(JTextField.LEFT); 
tx.setText("Ready"); 
tx.setEnabled(false); 
add(tx); 
public void change() 
{   if(state.equals("Ready"))        
{  
state="Move"; 
tx.setText(state); 
elseif(state.equals("Move"))        
{  
state="Stopped"; 
tx.setText(state); 
elseif(state.equals("Stopped"))        
state="Ready"; 
tx.setText(state); 
}   } 
public void propertyChange(PropertyChangeEvent e) 
change(); 
private JTextField tx; 
private String state; 
Pdf signature field - C# PDF Form Data fill-in Library: auto fill-in PDF form data in C#.net, ASP.NET, MVC, WinForms, WPF
Online C# Tutorial to Automatically Fill in Field Data to PDF
change pdf to fillable form; convert pdf to pdf form fillable
Pdf signature field - VB.NET PDF Form Data fill-in library: auto fill-in PDF form data in vb.net, ASP.NET, MVC, WinForms, WPF
VB.NET PDF Form Data fill-in library: auto fill-in PDF form data in vb.net, ASP.NET, MVC, WinForms, WPF
create fillable pdf form; convert word document to pdf fillable form
22 
 
22 
 
TraficLight : 
package mypack; 
import java.awt.*; 
import java.beans.*; 
import java.io.*; 
import java.util.Date; 
public class TrafficLight extends Panel 
implements Runnable, Serializable, PropertyChangeListener 
public TrafficLight() 
setSize(50, 50); 
color = Color.red; 
label = new Label(); 
label.setSize(100,100); 
label.setBackground(Color.red); 
add(label); 
changes = new PropertyChangeSupport(this); 
changes.addPropertyChangeListener(this); 
interval = 5; 
runner = new Thread(this); 
runner.start(); 
public void addPropertyChangeListener(PropertyChangeListener propertychangelistener) 
changes.addPropertyChangeListener(propertychangelistener); 
public void removePropertyChangeListener(PropertyChangeListener propertychangelistener) 
changes.removePropertyChangeListener(propertychangelistener); 
public int getInterval() 
return interval; 
public void setInterval(int i) 
interval = i; 
if(runner != null) 
runner.interrupt(); 
public int getSeconds() 
return (int)((new Date()).getTime() / 1000L); 
public void run() 
int i = getSeconds(); 
C# PDF Digital Signature Library: add, remove, update PDF digital
things. Add a signature or an empty signature field in any PDF file page. Search unsigned signature field in PDF document. Prepare
convert an existing form into a fillable pdf form; create a fillable pdf form online
VB.NET PDF Digital Signature Library: add, remove, update PDF
things. Add a signature or an empty signature field in any PDF file page. Search unsigned signature field in PDF document. Prepare
acrobat fill in pdf forms; create fillable form pdf online
23 
 
23 
 
do 
try 
Thread.sleep(interval * 1000); 
catch(InterruptedException interruptedexception) { } 
int j = getSeconds(); 
changes.firePropertyChange("seconds", new Integer(i), new Integer(j)); 
i = j; 
} while(true); 
public void propertyChange(PropertyChangeEvent propertychangeevent) 
if(color == Color.red) 
label.setBackground(Color.orange); 
color = Color.orange; 
} else 
if(color == Color.orange) 
label.setBackground(Color.green); 
color = Color.green; 
} else 
if(color == Color.green) 
label.setBackground(Color.red); 
color = Color.red; 
private Color color; 
private Label label; 
private PropertyChangeSupport changes; 
private int interval; 
transient Thread runner; 
TraficLight.mft : 
Manifest-Version: 1.0 
Name: mypack/TrafficLight.class 
Java-Bean: True 
TraficPerson.mft : 
Manifest-Version: 1.0 
Java-Bean: True 
Name: demo/TrafficPerson.class 
Created-By: 1.6.0 (Sun Microsystems Inc.) 
C# PDF insert image Library: insert images into PDF in C#.net, ASP
field. Access to freeware download and online C#.NET class source code. How to insert and add image, picture, digital photo, scanned signature or logo into PDF
convert word document to fillable pdf form; pdf fillable form creator
How to C#: Basic SDK Concept of XDoc.PDF for .NET
To be specific, you can edit PDF password and digital signature, and set PDF file permission. Class: PasswordSetting. Class: PDFDigitalSignatureHandler.
adding a signature to a pdf form; change font size pdf fillable form
24 
 
24 
 
OUTPUT : 
After setting TrafficLight and changing interval to 10 sce.. 
After setting the TrafficPerson,TrafficLight in the  
Beanwindow…
the light is changing to yellow,,,,the person window is showing ready…. 
VB.NET PDF: Basic SDK Concept of XDoc.PDF
To be specific, you can edit PDF password and digital signature, and set PDF file permission. Class: PasswordSetting. Class: PDFDigitalSignatureHandler.
convert excel to fillable pdf form; pdf fill form
VB.NET PDF insert image library: insert images into PDF in vb.net
project. Import graphic picture, digital photo, signature and logo into PDF document. file. Insert images into PDF form field in VB.NET. An
converting a word document to a fillable pdf form; change font size in pdf fillable form
25 
 
25 
 
6. Install TOMCAT web server.  Convert the static webpages of assignments 2 into dynamic 
webpages using servlets and cookies. Hint: Users information (user id, password, credit card 
number) would be stored in web.xml. Each user should have a separate Shopping Cart. 
PROCEDURE:
First install the tomcat into the system. 
Then make a subdirectly(eg., tr) in the \tomcat\webapps. 
Under tr create WEB-INF directory and also place the html files in this tr directory only. 
Next under WEB-INF create two subclasses lib,classes and web.xml 
Next place all the class files under the classes and jar files(servlet-api.jar,classes12.jar etc…) under lib 
subdirectories. 
After this start tomcat by giving the following command at the instll_dir>tomcat>bin 
Catalina.bat run 
At the I.E(web browser) give the url as http;//localhost:8080//tr/htmlfile or servlet url pattern 
Portno 8080 is assigned for the tomcat. 
Web.xml 
<?xml version="1.0" encoding="iso-8859-1"?> 
<!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd"> 
<web-app> 
<display-name>Servlet 2.4 Examples</display-name> 
<description> 
Servlet 2.4 Examples. 
</description> 
<servlet> 
<servlet-name>reg</servlet-name> 
<servlet-class>reg</servlet-class> 
</servlet> 
<servlet> 
<servlet-name>login</servlet-name> 
<servlet-class>login</servlet-class> 
</servlet> 
<servlet> 
<servlet-name>profile</servlet-name> 
<servlet-class>profile</servlet-class> 
</servlet> 
<servlet> 
<servlet-name>catalog</servlet-name> 
<servlet-class>catalog</servlet-class> 
<servlet-mapping> 
<servlet-name>order</servlet-name> 
<url-p</servlet> 
<servlet> 
<servlet-name>order</servlet-name> 
<servlet-class>order</servlet-class> 
</servlet> 
attern>order</url-pattern> 
</servlet-mapping> 
<servlet-mapping> 
<servlet-name>catalog</servlet-name> 
<url-pattern>catalog</url-pattern> 
VB.NET PDF Library SDK to view, edit, convert, process PDF file
NET program. Password, digital signature and PDF text, image and page redaction will be used and customized. PDF Annotation Edit.
convert pdf to fillable pdf form; convert pdf to fillable form online
C# Create PDF Library SDK to convert PDF from other file formats
PDF file. What's more, you can also protect created PDF file by adding digital signature (watermark) on PDF using C# code. Create
convert word to pdf fillable form online; convert html form to pdf fillable form
26 
 
26 
 
</servlet-mapping> 
<servlet-mapping> 
<servlet-name>profile</servlet-name> 
<url-pattern>profile</url-pattern> 
</servlet-mapping> 
<servlet-mapping> 
<servlet-name>login</servlet-name> 
<url-pattern>login</url-pattern> 
</servlet-mapping> 
<servlet-mapping> 
<servlet-name>reg</servlet-name> 
<url-pattern>reg</url-pattern> 
</servlet-mapping> 
</web-app> 
Main.html 
<!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"> 
<body bgcolor="pink"> 
<br /><br /><br /><br /><br /> 
<h1 align="center"><U>ONLINE BOOK STORAGE</U></h1><br /><br /><br /> 
<h2 align="center"><pre> 
<b>Welcome to online book storage. 
Press LOGIN if you are having id 
otherwise press REGISTRATION 
</b></pre></h2> 
<br /><br /><pre> 
<div align="center"><a href="/tr/login.html">LOGIN</a> <a href="/tr/reg.html"> 
REGISTRATION</a></div></pre> 
</body> 
</html> 
Login.html 
<html> 
<body bgcolor="pink"><br /><br /><br /> 
<form name="myform" method="post" action="/tr/login"> 
<div align="center"><pre> 
LOGIN ID :<input type="text" name="id" /><br /> 
PASSWORD :<input type="password" name="pwd" /></pre><br /><br /> 
</div> 
<br /><br /> 
<div align="center"> 
<input type="submit" value="ok" onclick="validate()" /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" /> 
</div> 
</form> 
</body> 
</html> 
C# PDF remove image library: remove, delete images from PDF in C#.
in Field Data. Field: Insert, Delete, Update Field. graphic picture, digital photo, scanned signature, logo, etc. remove multiple or all images from PDF document.
create a fillable pdf form from a word document; attach image to pdf form
C# PDF Convert to Images SDK: Convert PDF to png, gif images in C#
in C#.NET class. Create image files including all PDF contents, like watermark and signature in .NET. Turn multipage PDF file into
add fillable fields to pdf; convert pdf fillable forms
27 
 
27 
 
Reg.html 
<!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"> 
<body bgcolor="pink"><br /><br /> 
<form name="myform" method="post" action="/tr/reg"> 
<div align="center"><pre> 
NAME 
:<input type="text" name="name" /><br /> 
ADDRESS   
:<input type="text" name="addr" /><br /> 
CONTACT NUMBER             :<input type="text" name="phno" /><br /> 
LOGINID   
:<input type="text" name="id" /><br /> 
PASSWORD 
:<input type="password" name="pwd" /></pre><br /><br /> 
</div> 
<br /><br /> 
<div align="center"> 
<input type="submit" value="ok" onclick="validate()" /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" /> 
</div> 
</form> 
</body> 
</html> 
Profile.html 
<!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"> 
<body bgcolor="pink"><br /><br /><br /> 
<form name="myform" method="post" action="/tr/profile"> 
<div align="center"><pre> 
LOGIN ID :<input type="text" name="id" /><br /> 
</pre><br /><br /> 
</div> 
<br /><br /> 
<div align="center"> 
<input type="submit" value="ok" onclick="validate()" /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear" /> 
</div></form></body></html>
Catalog.html 
<!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"> 
<body bgcolor="pink"><br /><br /><br /> 
<form method="post" action="/tr/catalog"> 
<div align="center"><pre> 
BOOK TITLE :<input type="text" name="title" /><br /> 
</pre><br /><br /> 
</div> 
<br /><br /> 
<div align="center"> 
<input type="submit" value="ok" name="button1"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<input type="reset" value="clear"  name="button2"/> 
</div> 
</form> 
</body></html> 
28 
 
28 
 
Order.html 
<!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"> 
<body bgcolor="pink"><br /><br /> 
<form  method="post" action="/tr/reg"> 
<div align="center"><pre> 
NAME  
:<input type="text" name="name" /><br /> 
PASSWORD   
:<input type="password" name="pwd" /> 
TITLE   
:<input type="text" name="title" /><br /> 
NO. OF BOOKS 
:<input type="text" name="no" /><br /> 
DATE   
:<input type="text" name="date" /><br /> 
CREDIT CARD NUMBER:<input type="password" name="cno" /><br /></pre><br /><br /> 
</div> 
<br /><br /> 
<div align="center"> 
<input type="submit" value="ok" name="button1"/> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="clear"  name="button2"/> 
</div> 
</form> 
</body> 
</html> 
29 
 
29 
 
Login.java 
import java.sql.*; 
import java.io.*; 
import java.util.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
public class login extends HttpServlet 
public void service(HttpServletRequest req,HttpServletResponse resp) 
throws ServletException,IOException 
PrintWriter pw=resp.getWriter(); 
pw.println("<html><body bgcolor=\"pink\"); 
String id=req.getParamenter("id"); 
String pwd=req.getParameter("pwd"); 
try 
Driver d=new oracle.jdbc.driver.OracleDriver(); 
DriverManager.registerDriver(d); 
Connection                                      
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger")
Statement stmt=con.createStatement(); 
String sqlstmt="select id,password from login"; 
ResultSet rs=stmt.executeQuery(sqlstmt); 
int flag=0; 
while(rs.next()) 
if(id.equal(rs.getString(1))&&pwd.equals(rs.getString(2))) 
flag=1; 
if(flag==0) 
pw.println("SORRY INVALID ID TRY AGAIN ID<br><br>"); 
pw.println("<a href=\"/tr/login.html\">press LOGIN to RETRY</a>"); 
else 
pw.println("VALID LOGIN ID<br><br>"); 
pw.println("<h3><ul>"); 
pw.println("<li><ahref=\"profile.html\"><fontcolor=\"black\">USER   
PROFILE</font> 
</a></li><br><br>"); 
pw.println("<li><ahref=\"catalog.html\"><fontcolor=\"black\">BOOKS 
CATALOG</font></a></li><br><br>"); 
pw.println("<li><ahref=\"order.html\"><fontcolor=\"black\">ORDER 
CONFIRMATION</font> 
</a></li><br><br>"); 
pw.println("</body></html>"); 
catch(Exception e) 
resp.sendError(500,e.toString()); 
}  
30 
 
30 
 
Reg.html 
import java.sql.*; 
import java.io.*; 
import java.util.*; 
import javax.servlet.*; 
import javax.servlet.http.*; 
public class login extends HttpServlet 
public void service(HttpServletRequest req,HttpServletResponse resp) 
throws ServletException,IOException 
PrintWriter pw=resp.getWriter(); 
pw.println("<html><body bgcolor=\"pink\"); 
String name=req.getParamenter("name"); 
String addr=req.getParameter("addr"); 
String phno=req.getParameter("phno"); 
String id=req.getParamenter("id"); 
String pwd=req.getParameter("pwd"); 
int no=Integer.parseInt(phno); 
try 
Driver d=new oracle.jdbc.driver.OracleDriver(); 
DriverManager.registerDriver(d); 
Connection     
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott","tiger")
Statement stmt=con.createStatement(); 
String sqlstmt="select id,password from login"; 
ResultSet rs=stmt.executeQuery(sqlstmt); 
int flag=0; 
while(rs.next()) 
if(id.equal(rs.getString(1))&&pwd.equals(rs.getString(2))) 
flag=1; 
}  
if(flag==1) 
pw.println("SORRY INVALID ID ALREADY EXITS TRY AGAIN WITH NEW 
ID<br><br>"); 
pw.println("<a href=\"/tr/reg.html\">press REGISTER to RETRY</a>"); 
else  
           
Statement stmt1=con.createStatement(); 
stmt1.executeUpdate("insertintologin 
values("+names","+addr+","+no+","+id+","+pwd+")"); 
pw.println("YOUR DETAILS ARE ENTERED<br><br>"); 
pw.println("<a href=\"/tr/login.html\">press LOGIN to login</a>"); 
pw.println("</body></html>"); 
catch(Exception e) 
{  
resp.sendError(500,e.toString()); 
} }} 
Documents you may be interested
Documents you may be interested