SlideShare a Scribd company logo
1 of 92
NAME:                                                                       ROLL NO:



 TRR COLLEGE OF ENGINEERING
   Laboratory Record                                    Experiment No. : 6

   of Java and Web Technologies                          Cycle No.: 2

        Lab                                              Date: 04/01/2011




Question :

Illustrate the process of installing TOMCAT SERVER.



Aim: To install TOMCAT server in the personal computer and run programs.



Hardware Requirements :Fully configured personal computer



Software Requirements: Apache Tomcat server 6.0,jdk 1.6,Internet Explorer.



Procedure:



STEP 1: Download Tomcat from the Apache Tomcat site.



STEP 2: Click Next to continue and follow the instructions.




 TRRCE                                      PAGE NO:                           M.TECH (CSE)
NAME:                                                        ROLL NO:

V vHome Page :
Main.html
<html>
<head>
<title>
Amazon</title>
</head>
<body bgcolor="cyan"> <center>
<strong><h1>Welcome to AMAZON</h1></strong>
<form method="post" action="login.html" target=_blank >
<h4>for books</h4><input type="submit" value="click here">
</form>
</center>
</body>
</html>
User Login :
Login.html
<html>
<head>
<title>
login page</title>
</head>
<body bgcolor="cyan"> <center>
<strong><h1> AMAZON </h1></strong></center>
<right>
<table align="right">
<tr>
<td><h4>user name</td>
<td><input type="text" ></td>
<td></td>
</tr>

TRRCE                                PAGE NO:                  M.TECH (CSE)
NAME:                                                 ROLL NO:

<tr>
<td><h4>password</td>
<td><input type="password"></td>
<td></td>
</tr>
<tr>
<td>
<form method="post" action="catalog.html" >
<input type="submit" value="submit" >
</form>
</td>
<td>
<form method="post" action="userpro.html" >
<input type="submit" value="register" >
&nbsp;&nbsp;
<input type="reset" value="reset"></form></td>
</tr>
</table>
</body>
</html>
User Profile:
Userpro.html
<html>
<head>
<title>login page</title>
</head>
<body bgcolor="cyan">
<center><strong><h1> AMAZON </h1></strong></center>
<form method="post" action="catalog.html" >
<right>
<table align="left">

TRRCE                                 PAGE NO:          M.TECH (CSE)
NAME:                                                     ROLL NO:

<tr>
<td><h4>user name</td>
<td><input type="text" ></td>
</tr>
<tr>
<td><h4>password</td>
<td><input type="password"></td>
</tr>
<tr>
<td><h4>confirm password</td>
<td><input type="password"></td>
</tr>
<tr>
<td><h4>male &nbsp;&nbsp;
<option >
<input type="radio" name="sex" id="male"></td>
<td><h4>female &nbsp; &nbsp;
<input type="radio" name="sex" id="female" ></td>
</option>
</tr>
<tr>
<td>Address</td>
<td><textarea name="address" rows=5 cols=19></textarea>
</td>
<tr>
<td>
<input type="submit" value="submit" ></td>
<td>
<input type="reset" value="reset"></td>
</tr></form></body>
</html>

TRRCE                                 PAGE NO:              M.TECH (CSE)
NAME:                                         ROLL NO:

Catalogue Page :
Catalog.html
<html>
<head>
<title>books catalog</title>
</head>
<body bgcolor="cyan">
<center><h1>AMAZON</h1></center>
<form method="post" action="shopping.html">
<left>
<table>
<tr>
<td><b><h3>frontend books</td>
<td></td></tr>
<tr>
<td></td>
<td><h4>C&Ds</td>
</tr>
<tr>
<td></td>
<td><h4>Ads</td>
</tr>
<tr>
<td></td>
<td><h4>JAVA </td></tr>
<tr>
<td><b><h3>backend books</td>
<td></td></tr>
<tr>
<td></td>
<td><h4>Oracle</td></tr>

TRRCE                              PAGE NO:     M.TECH (CSE)
NAME:                                           ROLL NO:

<tr>
<td></td>
<td><h4>Ms SQL Server
</td></tr>
<tr>
<td></td>
<td><h4>MySql </td>
</tr>
</table>
</h4>
<center>
<b>for buy one of these books
<br>
</b><input type="submit" value="click here">
</center>
</form>
</body>
</html>
OUTPUT:

Homepage:




TRRCE                                PAGE NO:     M.TECH (CSE)
NAME:                      ROLL NO:

User login:




User profile:




TRRCE           PAGE NO:     M.TECH (CSE)
NAME:                       ROLL NO:

Books Catalog:




TRRCE            PAGE NO:     M.TECH (CSE)
NAME:                                                 ROLL NO:

Registration Page:

Userpro.html
<html>
<head>
<title>login page</title>
</head>
<body bgcolor="cyan">
<center><strong><h1> AMAZON </h1></strong></center>
<form method="post" action="shopping.html" >
<right>
<table align="left">
<tr>
<td><h4>user name</td>
<td><input type="text" ></td>
</tr>
<tr>
<td><h4>password</td>
<td><input type="password"></td>
</tr>
<tr>
<td><h4>confirm password</td>
<td><input type="password"></td>
</tr>
<tr>
<td><h4>male &nbsp;&nbsp;
<option >
<input type="radio" name="sex" id="male"></td>
<td><h4>female &nbsp; &nbsp;
<input type="radio" name="sex" id="female" ></td>
</option>
</tr>

TRRCE                               PAGE NO:            M.TECH (CSE)
NAME:                                                     ROLL NO:

<tr>
<td>Address</td>
<td><textarea name="address" rows=5 cols=19></textarea>
</td>
<tr>
<td><input type="submit" value="submit" ></td>
<td><input type="reset" value="reset"></td>
</tr></form></body></html>
Cart Page:
Shopping.html
<html>
<head><title>shopping cart</title>
</head>
<body bgcolor="cyan">
<center><h1>Shopping Cart</h1></center>
<br><br><br><br><br>
<table align="center">
<tr>
<td>Text Books</td>
<td>
<select >
<optgroup label="select the book">
<option value="C&Ds">C&Ds
<option value="Ads">Ads
<option value="Java">Java
<option value="Oracle">Oracle
<option value="Ms SQL Server">Ms SQL Server
<option value="MySql">MySql
</optgroup>
</select>
</td></tr>


TRRCE                                PAGE NO:               M.TECH (CSE)
NAME:                                                  ROLL NO:

<tr>
<td> Quantity</td>
<td><input type="text" id="q">
</td></tr>
<tr>
<td></td>
<td>
<form method=post action="payment.html">
<input type="submit" value=ok />
</form>
</td></tr>
</table>
<center>
<pre>Cost of one book is"500" + shipping "100"</pre>
</center>
<body>
</html>
Payment by credit card
Payment.html
<html>
<head><title>payment</title></head>
<body bgcolor="cyan">
<center><h1>Payment By Credit Card</h1></center>
<form method=post action="ordrconform.html">
<br><br><br><br><br>
<table align="center">
<tr>
<td>
<h4>Total Amount</h4></td>
<td><input type="text">
</td>

TRRCE                                 PAGE NO:           M.TECH (CSE)
NAME:                                             ROLL NO:

</tr>
<tr>
<td><h4>Credit Card Number</td>
<td><input type="text"></td>
</tr>
<tr>
<td>
</td>
<td><input type="submit" value=OK>
</td></tr>
</table>
</form></body>
</html>
Order Conformation
Ordrconform.html
<html>
<head><title>order conformation</title><M/head>
<body bgcolor="cyan">
<center>
<h1><b>AMAZON</h1>
<pre><strong>
<b>Your order Is Conformed
</strong></pre>
<h2><b>THANK YOU</h2>
</center>
</body></html>




TRRCE                                PAGE NO:       M.TECH (CSE)
NAME:                       ROLL NO:

OUTPUT:
Registration:




Shopping Cart:




TRRCE            PAGE NO:     M.TECH (CSE)
NAME:                                ROLL NO:

Payment by credit card:




Order conformation:




TRRCE                     PAGE NO:     M.TECH (CSE)
NAME:                                                                 ROLL NO:

Validations.html
<html>
<head>
<title>registration</title>
    <h2 align="center">&nbsp;</h2>
            <h2 align="center"><font color="#0000FF"><span style="font-weight: 400"><i>
            <font face="Californian FB">Registration Form</font></i></span></h2>
<script language="javascript">
function checkUsername(strng)
{
var error = "";
if (strng.value == "") {
     error = "You didn't enter a username.n";
     alert(error);
     strng.focus();
}
else{
alert(strng.value.length);
if ((strng.value.length < 4) || (strng.value.length > 15)) {
     alert("The username is the wrong length.");
     strng.focus();
     }
     else{
     var illegalChars = /W/;
    // allow only letters, numbers, and underscores
     if (illegalChars.test(strng.value)) {
         alert("The username contains illegal characters");
         strng.focus();
     }
     }
}


TRRCE                                        PAGE NO:                     M.TECH (CSE)
NAME:                                                                         ROLL NO:

}
function checkPassword(strng)
{
alert("with in the password");
    if (strng.value == "") {
     alert("You didn't enter a password.");
}
else{
     var illegalChars = /[W_]/; // allow only letters and numbers
     if ((strng.value.length < 6) || (strng.value.length > 8)) {
         alert("The password is the wrong length");
     }
     else{
     if (illegalChars.test(strng.value)) {
         alert("The password contains illegal characters");
     }
     }
     }
}
function echeck(str) {
                    var at="@"
                    var dot="."
                    var lat=str.indexOf(at)
                    var lstr=str.length
                    var ldot=str.indexOf(dot)
                    if (str.indexOf(at)==-1){
                        alert("Invalid E-mail ID")
                        return false
                    }
                    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
                        alert("Invalid E-mail ID")

TRRCE                                           PAGE NO:                           M.TECH (CSE)
NAME:                                                                    ROLL NO:

                   return false
              }
              if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
                   alert("Invalid E-mail ID")
                   return false
              }
               if (str.indexOf(at,(lat+1))!=-1){
                   alert("Invalid E-mail ID")
                   return false
               }
               if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
                   alert("Invalid E-mail ID")
                   return false
               }
               if (str.indexOf(dot,(lat+2))==-1){
                   alert("Invalid E-mail ID")
                   return false
               }
               if (str.indexOf(" ")!=-1){
                   alert("Invalid E-mail ID")
                   return false
               }
               return true
       }
function ValidateMail(){
       var emailID=document.f1.e1;
       if ((emailID.value==null)||(emailID.value=="")){
              alert("Please Enter your Email ID")
              emailID.focus()
              return false
       }

TRRCE                                    PAGE NO:                             M.TECH (CSE)
NAME:                                                     ROLL NO:

          if (echeck(emailID.value)==false){
                   emailID.value=""
                   emailID.focus()
                   return false
          }
          return true
}
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;
function isInteger(s)
{ var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}
function trim(s)
{ var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;

TRRCE                                          PAGE NO:     M.TECH (CSE)
NAME:                                                               ROLL NO:

}
function stripCharsInBag(s, bag)
{ var i;
    var returnString = "";


    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}


function ValidatePhone(){
          var Phone=document.f1.p1;
          if ((Phone.value==null)||(Phone.value=="")){
                  alert("Please Enter your Phone Number")
                  Phone.focus()

TRRCE                                       PAGE NO:                     M.TECH (CSE)
NAME:                                                            ROLL NO:

              return false
       }
       if (checkInternationalPhone(Phone.value)==false){
              alert("Please Enter a Valid Phone Number")
              Phone.value=""
              Phone.focus()
              return false
       }
       return true
}
</script>
</head>
<body style="text-align: center">
<form name="f1">
<p align="center"><font color="#0000FF">UserName:&nbsp;&nbsp;&nbsp; <input type="text"
name="t1" onblur="checkUsername(this)">
</font>
</p>
<p align="center"><font color="#0000FF">Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="password" name="p1" onblur="checkPassword(this)">
</font>
</p>
<p align="center"><font color="#0000FF">E-mail
id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="e1" size="20"
onblur="ValidateMail()"></input>
</font>
</p>
<p align="center"><font color="#0000FF">Phone
no:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="p1" size="20"
onblur="ValidatePhone()"></input>
</font>

TRRCE                                PAGE NO:                      M.TECH (CSE)
NAME:                                                               ROLL NO:

</p>
<blockquote>
       <blockquote>
                <blockquote>
                       <blockquote>
                                <p align="center"><font color="#0000FF"><b>Sex:
</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp; Female:<input type="radio" name value="V1" checked>Male:<input type="radio"
name value="V1" checked></input>
                                </font></p>
                       </blockquote>
                </blockquote>
       </blockquote>
</blockquote>
<p align="center"><font color="#0000FF">Date of Birth: <select size="1" name="D1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>

TRRCE                                   PAGE NO:                        M.TECH (CSE)
NAME:                                                          ROLL NO:

<option>17</option>
<option>19</option>
<option>20</option>
</select>&nbsp; <select size="1" name="D2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>&nbsp;
<select size="1" name="D3">
<option>1986</option>
<option>1987</option>
<option>1988</option>
<option>1989</option>
<option>1990</option>
<option>1991</option>
</select></font></p>
<p align="center"><font color="#0000FF">Languages known:&nbsp;&nbsp; English
<input type="checkbox" name="C1" value="ON">&nbsp; Telugu
<input type="checkbox" name="C2" value="ON">&nbsp; Hindi<input type="checkbox"
name="C3" value="ON">&nbsp;&nbsp;
Tamil<input type="checkbox" name="C4" value="ON"></font></p>



TRRCE                               PAGE NO:                      M.TECH (CSE)
NAME:                                                           ROLL NO:

<p align="center"><font color="#0000FF">Adress: <textarea rows="2" name="S1"
cols="20"></textarea></font></p>
<p align="center"><font color="#0000FF"><input type="submit" value="Submit"
name="B1"><input type="reset" value="Reset" name="B2"></font></p>
</form>
</body>
</html>

OUTPUT:




TRRCE                               PAGE NO:                        M.TECH (CSE)
NAME:              ROLL NO:




TRRCE   PAGE NO:     M.TECH (CSE)
NAME:                                                            ROLL NO:

Font.css
body{
background-image:url('C:Documents and SettingsacerDesktopstgWTLABimgflw2.jpg');
    background-repeat : repeat;
}
p{
text-align:right;
font-size : 40pt ;
color:yellow;
font-style :italic;
font-family:"Times New Roman", Times, serif;
font-family:Timesroman;
}
Font.html
<html>
<head>
<title>font</title>
<link rel="stylesheet"type="text/css" href="font.css"/>
</head>
<body>
<p>
</br></br>
This is from the External Style Sheet for Font
</p>
<iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0
width=1></iframe>
</body>
</html>




TRRCE                                   PAGE NO:                      M.TECH (CSE)
NAME:                ROLL NO:



OUTPUT:




TRRCE     PAGE NO:     M.TECH (CSE)
NAME:                                                                  ROLL NO:

Link.css

<style type="text/css">
A:link {background: pink ; text-decoration: none}
A:visited {background: yellow; text-decoration: }
A:active {background: blue; text-decoration: none}
A:hover {background: green; font-weight:bold; color: red;
</style>
Link.html
<html>
<head>
<title>linkstylesheet</title>
<link rel="stylesheet"type="text/css"href="link.css"/>
</head><body><p>Normal Text
<a href="test.html"> This Is An Example Forstyle sheets on Link </a>
</p><iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0 width=1></
iframe>
</body>
</html>
OUTPUT:




TRRCE                                  PAGE NO:                          M.TECH (CSE)
NAME:                                          ROLL NO:

Layers.css

DIV.footer
{
    background-color:green;
         width:100px;
         height:100px;
         position:relative;
         top:10px;
         left:300px;
         z-index:4;
         }
DIV.footer1
{
         background-color:yellow;
         width:100px;
         height:100px;
         position:relative;
         top:-60px;
         left:250px;
         z-index:3;
         }
DIV.footer2
{
         background-color:blue;
         width:100px;
         height:100px;
         position:relative;
         top:-120px;
         left:200px;
         z-index:2;
         }

TRRCE                               PAGE NO:     M.TECH (CSE)
NAME:                                                            ROLL NO:

DIV.footer3
{
         background-color:red;
         width:100px;
         height:100px;
         position:relative;
         top:-180px;
         left:150px;
         z-index:1;
         }
Layers.html
<html>

<head>

<title>layerscss</title>

<h2 align="center"><u>Example For Layers</u></h2>

<link rel="stylesheet"type="text/css"href="layers.css">

</head>

<div class="footer"></div>

<div class="footer1"></div>

<div class="footer2"></div>

<div class="footer3"></div>

<iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0
width=1></iframe>

</body>

</html>




TRRCE                                  PAGE NO:                       M.TECH (CSE)
NAME:                ROLL NO:




OUTPUT:




TRRCE     PAGE NO:     M.TECH (CSE)
NAME:                                                      ROLL NO:

Cursor.css
p
{
 font-size : 40;
 font-style : roman;
 background : red;
text-align : center ;
height : 100px;
cursor : url("move.cur"),move;
}
Cursor.html
<html>
<head>
<title>cursorcss</title>
<link rel="stylesheet"type="text/css"href="cursor.css"/>
</head>
<body>
<p></br>
This Is Example Of A Cursor Program using CSS
</p>
</body>
</html>
OUTPUT:




TRRCE                                  PAGE NO:              M.TECH (CSE)
NAME:                                              ROLL NO:

Book1.xml
<?xml version="1.0" ?>
<bookrecords>
<record>
<Title>C PROGRAMMING AND DATA STRUCTURES</Title>
<Author>E.BALAGURUSWAMY</Author>
<ISBN>0-07-106829-5</ISBN>
<Publisher>Mc GRAW HILL</Publisher>
<Edition>2</Edition>
<price>250</price>
</record>
<record>
<Title>DATABASE MANAGEMENT SYSTEMS</Title>
<Author>RAGHU RAMA KRISHNA</Author>
<ISBN>0-07-123151-X</ISBN>
<Publisher>THE Mc GRAW HILL</Publisher>
<Edition>4</Edition>
<price>650</price>
</record>
<record>
<Title>COMPLETE REFERENCE JAVA</Title>
<Author>HERBERT SCHILDT</Author>
<ISBN>0-07-063677-X</ISBN>
<Publisher>Mc GRAW HILL PROFESSIONAL</Publisher>
<Edition>3</Edition>
<price>600</price>
</record>
<record>
<Title>DIGITAL LOGIC DESIGN</Title>
<Author>MORIS MANO</Author>
<ISBN>0-07-77889-X</ISBN>

TRRCE                           PAGE NO:             M.TECH (CSE)
NAME:                                                                   ROLL NO:

<Publisher>CENAGE LEANING</Publisher>
<Edition>7</Edition>
<price>385</price>
</record>
<record>
<Title>INTRODUCTION TO AUTOMATA THEORY </Title>
<Author>JEFFREY ULLMAN</Author>
<ISBN>978-81-317-2047-9</ISBN>
<Publisher>PEARSON</Publisher>
<Edition>6</Edition>
<price>480</price>
</record>
<record>
<Title>DATABASE SYSTEM CONCEPTS</Title>
<Author>HENRY F.KORTH</Author>
<ISBN>978-007-128959-7</ISBN>
<Publisher>Mc GRAW HILL</Publisher>
<Edition>5</Edition>
<price>780</price>
</record>
</bookrecords>
Bookdetails.html

<html>
<head>
<title>BookDetails</title>
</head>
<body>
<h2 style='background-color:blue; color:white; text-align:center; font-style:italic'>
BOOKS DETAILS</h2>
<xml id="bookrecords" src="book1.xml">
</xml>

TRRCE                                   PAGE NO:                             M.TECH (CSE)
NAME:                                                            ROLL NO:

<table id="bk1" nam="bktab1" width=100% bgcolor=cyan border=2 bordercolor=blue
cellspacing=0 datasrc=#bookrecords>
<thead>
<tr>
<th>TITLE OF BOOK</th>
<th>AUTHOR OF BOOK</th>
<th>ISBN NUMBER</th>
<th>PUBLISHER NAME</th>
<th>EDITION</th>
<th>PRICE</th>
</tr>
</thead>
<tbody>
<tr>
<td><span datafld=TITLE></span></td>
<td><span datafld=AUTHOR></span></td>
<td><span datafld=ISBN></span></td>
<td><span datafld=PUBLISHER></span></td>
<td><span datafld=EDITION></span></td>
<td><span datafld=PRICE></span></td>
</tr>
</tbody>
</table>
<br>
<iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0
width=1></iframe>
</body>
</html>




TRRCE                                 PAGE NO:                        M.TECH (CSE)
NAME:                ROLL NO:



OUTPUT:




TRRCE     PAGE NO:     M.TECH (CSE)
NAME:                                                            ROLL NO:

TOMCAT INSTALLATION STEPS:

1) Install TOMCAT web server and APACHE. While installation assign port number 4040 to
TOMCAT and 8080 to APACHE. Make sure that these ports are available i.e., no other process
is using this port.
2) Access the above developed static web pages for books web site, using these servers by
    putting the web pages developed in week-1 and week-2 in the document root.
3) Access the pages by using the urls: http://localhost:4040/rama/books.html (for Tomcat)
    http://localhost:8080/books.html (for Apache)

a). Download Tomcat from the Apache Tomcat site.
b). Execute the downloaded file jakarta-tomcat-5.0.26.zip.
c). Select the "Next >" button.




TRRCE                                  PAGE NO:                      M.TECH (CSE)
NAME:                                                                    ROLL NO:

4. Read the License Agreement and select the I Agree button.




5. To include Tomcat example files, check the Example and Webapps select the Next > button.




TRRCE                                    PAGE NO:                             M.TECH (CSE)
NAME:                                                          ROLL NO:

6. Check the Destination Folder and select the Next > button




7. Enter the Password and select the Next > button.




TRRCE                                  PAGE NO:                  M.TECH (CSE)
NAME:                                                                   ROLL NO:

8. Check if the path where J2SE 5.0 JRE is correct and select the Install button.




9. Tomcat files will be installed.




TRRCE                                   PAGE NO:                             M.TECH (CSE)
NAME:                                                           ROLL NO:

10. Check Run Apache Tomcat to verify Tomcat was properly installed and select the Finish
button.




11. Wait until Tomcat starts.




TRRCE                               PAGE NO:                        M.TECH (CSE)
NAME:                                                              ROLL NO:

12. Open a web browser and enter http://localhost:8080 as the Address. If Tomcat was properly
installed, the following page will appear.




TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                                                                  ROLL NO:

Cookies.java

import java.io.*;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.*;
public class Cookies extends HttpServlet
{
public void doGet( HttpServletRequest req, HttpServletResponse res )
throws IOException{
     int var, i ;
     String s ;
     Cookie [] cookie = req.getCookies() ;
     Cookie countCookie = null ;
     for( i = 0; i < cookie.length; i++ ){
    if( cookie[i].getName().equals("Mycookie") ){
     countCookie = cookie[i] ;
          }
     }
     if( countCookie != null ){
    s = countCookie.getValue() ;
     if( s != null ){
     var = Integer.parseInt( s ) ;
         }
     else{
         var = 0 ;
         }
     }
     else{
         try{
              countCookie = new Cookie( "Mycookie", null ) ;
         }catch( IllegalArgumentException exception ){}

TRRCE                                        PAGE NO:                    M.TECH (CSE)
NAME:                                                              ROLL NO:

            var = 0 ;
        }
        var++ ;
        Integer oI = new Integer( var ) ;
        countCookie.setValue( oI.toString() ) ;
        res.addCookie( countCookie ) ;
        PrintWriter out = res.getWriter() ;
        out.write( "You've visited the page" + var+ " times" ) ;
    }
}
OUTPUT:




TRRCE                                         PAGE NO:               M.TECH (CSE)
NAME:                                                     ROLL NO:

HOMEPAGE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Data Base Operations </TITLE><BR><BR>
<CENTER>
<H2>DATA BASE OPERATIONS</H2>
<script type="text/javascript">
function creat()
{
location.href="http://localhost:2010/sriludata/create.html";
}
function ins()
{
location.href="http://localhost:2010/sriludata/regform.html";
}
function upd()
{
alert("with in the update");;
}
function del()
{
alert("with in the del");
}
function vie()
{
location.href="http://localhost:2010/sriludata/view.html";
}
</script>
</HEAD>
<BODY bgcolor=”grey”>
<BR><BR>
<form name=f1 >
<input type="BUTTON" name="b1" value="CREATE" onClick="creat()">
<input type="BUTTON" name="b2" value="INSERT" onClick="ins()">
<input type="BUTTON" name="b3" value="UPDATE" onClick="upd()">
<input type="BUTTON" name="b4" value="DELETE" onClick="del()">
<input type="BUTTON" name="b5" value="VIEW" onClick="vie()">
</CENTER>

</BODY>
TRRCE                           PAGE NO:                      M.TECH (CSE)
NAME:                    ROLL NO:

</HTML>
OUTPUT:




Create.java
TRRCE         PAGE NO:     M.TECH (CSE)
NAME:                                                            ROLL NO:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class create extends HttpServlet{
public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
  res.setContentType("text/html");
  PrintWriter out = res.getWriter();
try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:odbc:srilathadata", "scott",
    "tiger");
    int colno=Integer.parseInt(req.getParameter("colno"));
     System.out.println(colno);
     String tablename=req.getParameter("tabna");
     System.out.println(tablename);
     String [] fieldname = req.getParameterValues("t1");
     String [] columntype = req.getParameterValues("s");
     String [] columnlength = req.getParameterValues("l1");
             String [] que=new String[colno];
             for(int i=0; i<fieldname.length;i++){
           System.out.println(fieldname[i]);
           System.out.println(columntype[i]);
           System.out.println(columnlength[i]);
            String s=fieldname[i]+" "+columntype[i]+"("+columnlength[i]+")";
           System.out.println(s);
           que[i]=s;
           }
     String s1="";
             for(int i=0;i<=que.length;i++)
     {

          if(i==(que.length-1))
          {
                   s1=s1+que[i];
                   System.out.println("with in the if"+s1);
                    Statement st = connection.createStatement();
               String table = "CREATE TABLE " +tablename + "("+s1+");";
               System.out.println("the final String is "+table);
               st.executeUpdate(table);
TRRCE                               PAGE NO:                         M.TECH (CSE)
NAME:                                                                ROLL NO:

                out.println("<html><h2><center>Table creation process successfully!</center></
      h2></html>");

              }
              else
              {
                      s1=s1+que[i]+",";
                      System.out.println("with in the else"+s1);
              }

       }

    }catch(Exception e){
     out.println(e.getMessage());//Print trapped error.
    }
}

 }
Create Table.HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<head>
<TITLE> New Document </TITLE>
<h2>For creating a table </h2>
<script language="JavaScript">
function test()
{
alert("entern in the frunction");
 var n=document.f1.t2.value;
 var i;
 alert(n);
 var name=document.f1.t1.value;
 alert(name);
document.write("<html><b><h2>For creating a table<br>");
document.write("<body>the table name is              "+name+"</h2></b><br><form name =cre
    method=get        action=http://localhost:2010/sriludata/servlet/create><input type=hidden
    name=colno value="+n+"><input type=hidden name=tabna value="+name+"><input
    type=hidden name=opname value=create><center>");
for(i=0;i<n;i++)
{


TRRCE                                       PAGE NO:                     M.TECH (CSE)
NAME:                                                             ROLL NO:

document.write("<b><tr><td>Column Name: <input type=text name=t1
   ></td>&nbsp;&nbsp;<td>Column type:<select name=s><option
   value=varchar>Varchar</option><option
   value=number>Number</option></select></td>&nbsp;&nbsp;<td>Length : <input
   type=text name=l1 ></td></tr><br></b>");
}
document.write("<br><br><input type=submit
   value=CREATE></center></form></body><html>");

}
</script>
</HEAD>
<BODY bgcolor="grey">
Fill the fileds
<form name=f1><br><b>
Enter the table name: <input type="text" name="t1"><br>
Enter no of columns :&nbsp;&nbsp;<input type="text" name="t2" onblur="test()">
</b>
</form>
</BODY>
</HTML>
OUTPUT:




Table data.html
<html>
TRRCE                                PAGE NO:                         M.TECH (CSE)
NAME:                                                               ROLL NO:

<b><h2>For creating a table<br>
<body bgcolor="grey">the table name is ashok</h2></b><br>
<form name =cre method=get action=http://localhost:2010/sriludata/servlet/create>
<input type=hidden name=colno value=2>
<input type=hidden name=tabna value=ashok>
<input type=hidden name=opname value=create>
<center><b><tr><td>
Column Name: <input type=text name=t1 ></td>&nbsp;&nbsp;<td>
Column type:<select name=s><option value=varchar>Varchar</option>
<option value=number>Number</option></select></td>&nbsp;&nbsp;<td>
Length : <input type=text name=l1 ></td></tr><br></b><b><tr><td>
Column Name: <input type=text name=t1 ></td>&nbsp;&nbsp;<td>
Column type:<select name=s><option value=varchar>Varchar</option>
<option value=number>Number</option></select>
</td>&nbsp;&nbsp;<td>
Length : <input type=text name=l1 ></td></tr><br></b><br><br>
<input type=submit value=CREATE></center>
</form>
</body>
<html>




Output:


TRRCE                                 PAGE NO:                           M.TECH (CSE)
NAME:                          ROLL NO:




Insert.java
import java.io.*;


TRRCE               PAGE NO:     M.TECH (CSE)
NAME:                                                                     ROLL NO:

import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
public class insert extends HttpServlet{
public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
  res.setContentType("text/html");
  PrintWriter out = res.getWriter();
try{
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                                        Connection                      connection            =
    DriverManager.getConnection("jdbc:odbc:srilathadata", "scott", "tiger");
               String uname=req.getParameter("t1");
                     String password=req.getParameter("p1");
                     String email=req.getParameter("e1");
                     String phone=req.getParameter("ph");
                     String sex=req.getParameter("radio1");
                     String da=req.getParameter("D");
                     String month=req.getParameter("M");
                     String year=req.getParameter("Y");
                     String dob=da+"-"+month+"-"+year;
                     String [] languages = req.getParameterValues("C1");
                     String s="";
                     for(int i=0; i<languages.length;i++){
                   s=s+","+languages[i];
                   System.out.println(languages[i]);
                   }
                     String add=req.getParameter("S1");
                     Statement statement = connection.createStatement();
                      String sql = "insert into regform values (?,?,?,?,?,?,?,?)";
                PreparedStatement pst = connection.prepareStatement(sql);
                pst.setString(1, uname);
                pst.setString(2, password);
                pst.setString(3, email);
                pst.setString(4, phone);
                pst.setString(5, sex);
                pst.setString(6, dob);
                pst.setString(7, s);
                pst.setString(8, add);
                int row = pst.executeUpdate();
               if(row!=0)
TRRCE                                     PAGE NO:                             M.TECH (CSE)
NAME:                                                          ROLL NO:

               {
                out.println("<html><h2>DATA IS STORED </h2></html>");
               }
                pst.close();
             }catch(Exception e){
  out.println(e.getMessage());
 }
}
 }

Insert.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
   <title>MyHtml.html</title>
   <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
   <meta http-equiv="description" content="this is my page">
   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
   <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
 </head>
 <html>
<head>
<title>registration</title>
 <h2 align="center">&nbsp;</h2>
    <h2 align="center"><font color="#0000FF"><span style="font-weight: 400"><i>
    <font face="Californian FB">Registration Form</font></i></span></h2>
</head>
<body bgcolor="grey" style="text-align: center">
<form name="f1" method="get" action="http://localhost:2010/sriludata/servlet/insert">
<input type=hidden name="regis" value="regis">
<p align="center"><font color="#0000FF">UserName:&nbsp;&nbsp;&nbsp; <input type="text"
    name="t1" >
</font>
</p>
<p align="center"><font color="#0000FF">Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="password" name="p1" >
</font>
</p>
<p align="center"><font color="#0000FF">E-mail
    id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="e1"
    size="20" ></input>
TRRCE                              PAGE NO:                        M.TECH (CSE)
NAME:                                                      ROLL NO:

</font>
</p>
<p align="center"><font color="#0000FF">Phone
    no:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="ph"
    size="20" ></input>
</font>
</p>
<blockquote>
    <blockquote>
           <blockquote>
                  <blockquote>
                         <p align="center"><font color="#0000FF"><b>Sex:
    </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp; Female:<INPUT TYPE="radio" NAME="radio1" VALUE="female">Male:
    <INPUT TYPE="radio" NAME="radio1" VALUE="male" CHECKED>
                         </font></p>
                  </blockquote>
           </blockquote>
    </blockquote>
</blockquote>
<p align="center"><font color="#0000FF">Date of Birth: <select size="1" name="D">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">10</option>
TRRCE                            PAGE NO:                      M.TECH (CSE)
NAME:                                                         ROLL NO:

<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
</select>&nbsp; <select size="1" name="M">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>&nbsp;
<select size="1" name="Y">
<option value="1980">1980</option>
<option value="1981">1981</option>
<option value="1982">1982</option>
<option value="1983">1983</option>
<option value="1984">1984</option>
<option value="1985">1985</option>
<option value="1986">1986</option>
<option value="1987">1987</option>
<option value="1988">1988</option>
<option value="1990">1989</option>
<option value="1991">1990</option>
<option value="1992">1991</option>
</select></font></p>
<p align="center"><font color="#0000FF">Languages known:&nbsp;&nbsp; English
<input type="checkbox" name="C1" value="English">&nbsp; Telugu


TRRCE                              PAGE NO:                       M.TECH (CSE)
NAME:                                                          ROLL NO:

<input type="checkbox" name="C1" value="telugu">&nbsp; Hindi<input type="checkbox"
    name="C1" value="hindi">&nbsp;&nbsp;
Tamil<input type="checkbox" name="C1" value="tamil"></font></p>
<p align="center"><font color="#0000FF">Adress: <textarea rows="2" name="S1"
    cols="20"></textarea></font></p>
<p align="center"><font color="#0000FF"><input type="submit" value="Submit"
    name="B1"><input type="reset" value="Reset" name="B2"></font></p>
</form>
</body>
</html>
 <body>
  <br>
 </body>
</html>
Output:




TRRCE                              PAGE NO:                        M.TECH (CSE)
NAME:                                     ROLL NO:




View.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
TRRCE                          PAGE NO:     M.TECH (CSE)
NAME:                                                             ROLL NO:

import java.sql.*;
public class view extends HttpServlet{
public void service (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
   res.setContentType("text/html");
   PrintWriter out = res.getWriter();
try{
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
      Connection connection = DriverManager.getConnection("jdbc:odbc:srilathadata", "scott",
      "tiger");
      Statement st = connection.createStatement();
        out.println("<html><center><h2>TABLE NAMES LIST</h2><table border=1>");
        int i=0;
                DatabaseMetaData meta = connection.getMetaData();
                ResultSet rs = meta.getTables(null, null, null, new String[]{"TABLE"});
                out.println("<tr><th>S.NO</th><th>Names of Table</th></tr>");
                while (rs.next()) {
                        i++;
             String tableName = rs.getString("TABLE_NAME");
             out.println("<tr><td>"+i+"</td><td>"+tableName+"</td></tr>");
              }
                out.println("</table></center></html>");
        }catch(Exception e){
   out.println(e.getMessage());//Print trapped error.
  }
}
 }
View.html
<html>
<head>
<CENTER>
<h2>
 TO VIEW THE DATA OR DESCRIPTION OF THE TABLE<br/><br/>
</h2>
<script language="JavaScript">
function test()
{
 for (var i=0; i < document.f1.r1.length; i++)
   {
   if (document.f1.r1[i].checked)
      {
TRRCE                                PAGE NO:                          M.TECH (CSE)
NAME:                                                            ROLL NO:

     var viewvalue = document.f1.r1[i].value;
     if(viewvalue=="table")
     {
     alert("for table list");
      location.href("http://localhost:2010/sriludata/servlet/view");
       }
     else
       {
      if(viewvalue=="desc")
       {
       alert("for desc");
                            document.write("<html><body><center><br><br><form method=post
     action=http://localhost:2010/sriludata/servlet/view1><input     type=hidden name=hv
     value=desc><b>Enter the Table Name:</b><input type=text name=t1><br><br><input
     type=submit value=Enter></form></center></body></html>");
       }
       else
       {
       alert("for data");
                            document.write("<html><body><center><br><br><form method=post
     action=http://localhost:2010/sriludata/servlet/view2><input     type=hidden name=h1
     value=data><b>Enter the Table Name:</b><input type=text name=t1><br><br><input
     type=submit value=Enter></form></center></body></html>");

         }
         }
     }
 }
}
</script>
</head>
<BODY>
<FORM name=f1 >
To VIEW: &nbsp;&nbsp;&nbsp;&nbsp;
Tables List:<input type=radio name="r1" value="table" >
Data<INPUT TYPE=RADIO NAME=r1 VALUE="data">&nbsp;&nbsp;Description<INPUT
    TYPE=RADIO NAME=r1 VALUE="desc"/><br/><br/>
<br/><input type=button value=click name=b1 onClick=test()>
</CENTER>
</FORM>
</BODY>
TRRCE                                PAGE NO:                        M.TECH (CSE)
NAME:                                                     ROLL NO:

Output:




Homepage

<html>
<head>
<h2>
<CENTER>DATABASE OPERATION WITH JSP<br/><br/><br/>
</h2>
</head>
<body>
<A HREF=http://localhost:8888/swapnadbjsp/create.jsp>CREATE TABLE</A><BR><BR>
<A HREF=http://localhost:8888/swapnadbjsp/insert.jsp>Instert Data</A><BR/><BR>
<A HREF=http://localhost:8888/swapnadbjsp/update.jsp>Update Data<a/><br><BR>
<A HREF=http://localhost:8888/swapnadbjsp/delete.jsp>Delete</A><BR/><BR>
<A HREF=http://localhost:8888/swapnadbjsp/viewdata.jsp>View</A>
</CENTER>
</body>
</html>
OUTPUT:



TRRCE                           PAGE NO:                      M.TECH (CSE)
NAME:                                       ROLL NO:




Create table

<%@ page import="java.sql.*" %>
<HTML>
  <HEAD>
    <TITLE>Creating a Table</TITLE>

TRRCE                            PAGE NO:     M.TECH (CSE)
NAME:                                                               ROLL NO:

  </HEAD>
  <center>
  <BODY bgcolor=gree>
    <H1>Creating a Table</H1>
    <% try {
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott", "tiger");
          Statement statement = connection.createStatement();
          String command = "CREATE TABLE StaffList (ID INTEGER, Name CHAR(50),
Deptname varchar2(50), Designation varchar(30));";
          statement.executeUpdate(command);
                              out.println("<b>Table is created successfully");
       } catch (Exception e) {
          out.println("An error occurred.");
       }
    %>
    </center>
  </BODY>
</HTML>
Output:




Insert:

<%@ page import="java.sql.*" %>
<HTML>
  <HEAD>
    <TITLE>Insert Data Into a Table</TITLE>

TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                                                              ROLL NO:

  </HEAD>

  <BODY bgcolor=brown>
    <H1>Insert Data Into a Table</H1>

    <%

        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott",
"tiger");

       Statement statement = connection.createStatement();

    String command = "INSERT INTO StaffList (ID, Name, Deptname , Designation )
VALUES (1, 'SM','ECE','Asstprof')";
    statement.executeUpdate(command);

       command = "INSERT INTO StaffList (ID, Name, Deptname , Designation ) VALUES
(2, 'MSS','MCA','Asstprof')";
       statement.executeUpdate(command);

       ResultSet resultset =
         statement.executeQuery("select * from StaffList");

      while(resultset.next()){
    %>
      <TABLE BORDER="1">
        <TR>
          <TH>ID</TH>
          <TH>Name</TH>
        </TR>
        <TR>
          <TD> <%= resultset.getString(1) %> </TD>
          <TD> <%= resultset.getString(2) %> </TD>
        </TR>
      </TABLE>
    <%
      }
    %>
  </BODY>
</HTML>
OUTPUT:




TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                                                              ROLL NO:




View:
<%@ page import="java.sql.*" %>
<HTML>
<center>
  <HEAD>
    <TITLE>The tableName Database Table </TITLE>
  </HEAD>

  <BODY bgcolor=cyan>
    <H1>The List Of Database Table </H1>

     <%
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott",
"tiger");
        Statement statement = connection.createStatement() ;
        ResultSet resultset = statement.executeQuery("select * from StaffList") ;
     %>

    <TABLE BORDER="2">
      <TR>

TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                                                          ROLL NO:

         <TH>ID</TH>
         <TH>Name</TH>
         <TH>Deptname</TH>
         <TH>Designation</TH>
       </TR>
       <% while(resultset.next()){ %>
       <TR>
         <TD> <%= resultset.getString(1) %></td>
         <TD> <%= resultset.getString(2) %></TD>
         <TD> <%= resultset.getString(3) %></TD>
         <TD> <%= resultset.getString(4) %></TD>
       </TR>
       <% } %>
    </TABLE>
  </BODY>
  </center>
</HTML>
OUTPUT:




Delete:

<%@ page language="java" import="java.sql.*" errorPage="" %>

TRRCE                              PAGE NO:                      M.TECH (CSE)
NAME:                                                                ROLL NO:

<%
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               Connection con = DriverManager.getConnection("jdbc:odbc:oracle", "scott",
"tiger");
     PreparedStatement psDeleteRecord=null;
     String sqlDeleteRecord=null;


     try
     {
        sqlDeleteRecord="Delete from StaffList where ID=1";
        psDeleteRecord=con.prepareStatement(sqlDeleteRecord);

       psDeleteRecord.executeUpdate();
     }
     catch(Exception e)
     {
       response.sendRedirect("<center>deleteRecord.jsp</center>");
       //// On error it will send back to addRecord.jsp page
     }

     try{
       if(psDeleteRecord!=null)
       {
        psDeleteRecord.close();
       }

      if(con!=null)
      {
       con.close();
      }
     }
     catch(Exception e)
     {
       e.printStackTrace();
     }
%>
<html>
<body bgcolor=blac><center>
Record is deleted successfully.
</center>
</body>
</html>
OUTPUT:




TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                ROLL NO:




Update:

TRRCE     PAGE NO:     M.TECH (CSE)
NAME:                                                               ROLL NO:

<%@ page language="java" import="java.sql.*" errorPage="" %>

<%
    try
      {
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
       Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott",
"tiger");
         Statement stmt = connection.createStatement();
                stmt.executeUpdate("UPDATE StaffList SET ID = 2 ");
                out.println("<h2><center>Update sucessfully</center><h2>");
      }
      catch (Exception e) {
           out.println("An error occurred.");
        }
%>
<html><center>
<body bgcolor=blac><br/>
 Data is updated successfully.
</center>
</body>
</html>
OUTPUT:




FirstServelet.java


TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                                                                 ROLL NO:

import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FirstServlet extends HttpServlet
{
/*public
void init(ServletConfig config) throws ServletException,IOException
{
try
{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:sandhya","scott","tiger");
    Statement st=con.createStatement();
}
    catch(Exception e)
    {
    System.out.println(e);
    }
}*/
public void doGet(HttpServletRequest req,HttpServletResponse res) throws
ServletException,IOException
{
res.setContentType("text/html");
ServletOutputStream sos=res.getOutputStream();
try
{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:Sandhya","scott","tiger");
    Statement st=con.createStatement();
    /*public void create();

TRRCE                                     PAGE NO:                       M.TECH (CSE)
NAME:                                                              ROLL NO:

public void insert();
public void delete();
public void select();
con.close();
}*/


//public void create()throws ServletException,IOException
//{
st.execute("create table table1(no number(10),name varchar2(10),marks number(5))");
    sos.println("table created");
/*}
public void insert()throws ServletException,IOException
{*/
String s1=req.getParameter("t1");
int no=Integer.parseInt(s1);
String name=req.getParameter("t2");
String s2=req.getParameter("t3");
int marks=Integer.parseInt(s1);
int x=st.executeUpdate("insert into table1 values("+no+","+name+","+marks+")");
sos.println(x+" records inserted");
/*}
public void select()throws ServletException,IOException
{*/
ResultSet rs=st.executeQuery("select * from table1");
while(rs.next())
{
sos.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3));
}
/*}
public void delete()throws ServletException,IOException
{*/

TRRCE                                   PAGE NO:                        M.TECH (CSE)
NAME:                                                              ROLL NO:

int i=st.executeUpdate("delete from table1 where no=100");
    sos.println(i+"rows deleted");
//}
}
    catch(Exception e)
    {
    //sos.println(e);
    }
}
}
WEB.XML
<?Xml version=”1.0”?>
<web-app>
<servlet>
<servlet-name>FirstServlet</servlet-name>
<servlet-class>FirstServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FirstServlet</servlet-name>
<url-pattern>/verify</url-pattern>
</servlet-mapping>
</web-app>
FirstServlet.html
<html>
<head>
<title>firstpage</titlle>
<head>
<body>
<form method=get action=http://locahost:8080/database/FirstServlet.class>
Student Number<input type=text name="t1"><br>
Student Name<input type=text name="t2"><br>

TRRCE                                   PAGE NO:                        M.TECH (CSE)
NAME:                                          ROLL NO:

Student marks<input type=text name="t3"><br>
<input type=submit value="OK">
</form>
</body>
OUTPUT:




Upload and Download:


TRRCE                              PAGE NO:      M.TECH (CSE)
NAME:                                                              ROLL NO:

Upload.html
<HTML>
<HEAD>
<TITLE> Upload </TITLE>
</HEAD>
<BODY>
   <form action='upload' method='post' enctype="multipart/form-data">
          <input type="file" name="abc"><br/>
          <input type="submit" name="submit" value="Upload">
   </form>
</BODY>
</HTML>

TestSer.java

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import org.apache.commons.fileupload.*;

public class TestSer extends HttpServlet
{
   public void service(HttpServletRequest request,HttpServletResponse        response)throws
   IOException, ServletException
   {
            PrintWriter out=response.getWriter();
            try
            {
                   DiskFileUpload upload = new DiskFileUpload();
                   File tempdir = new File("d:test");

                  upload.setSizeMax(-1L);
                  upload.setRepositoryPath(tempdir.getCanonicalPath());

                  String basename = null;
                  String war = null;
                  FileItem warUpload = null;

                    List items = upload.parseRequest(request);
       Iterator iter = items.iterator();
TRRCE                                  PAGE NO:                           M.TECH (CSE)
NAME:                                                                    ROLL NO:

       do
       {
         if(!iter.hasNext())
            break;
         FileItem item = (FileItem)iter.next();
         if(!item.isFormField())
            if(item.getFieldName().equals("abc") && warUpload == null)
               warUpload = item;
            else
               item.delete();
       } while(true);
                   war = warUpload.getName();
/*
                   if(war.lastIndexOf('') >= 0)
                           war = war.substring(war.lastIndexOf('') + 1);
                   if(war.lastIndexOf('/') >= 0)
                           war = war.substring(war.lastIndexOf('/') + 1);
*/
System.out.println(war);
                  if(war.indexOf('') >= 0)
                          war = war.substring(war.indexOf('') + 1);
                  if(war.indexOf('/') >= 0)
                          war = war.substring(war.indexOf('/') + 1);

System.out.println(war);
String war1="";

                   if(war.lastIndexOf('') >= 0)
                           war1 = war.substring(0,war.lastIndexOf('') + 1);
                   if(war.lastIndexOf('/') >= 0)
                           war1 = war.substring(0,war.lastIndexOf('/') + 1);

                   File appBaseDir = new File("d:testappbasedir");
                   File file1 = new File(appBaseDir,war1);
                   file1.mkdirs();
                   File file = new File(appBaseDir,war);
                   warUpload.write(file);
            }
            catch (Exception e)
            {
                    e.printStackTrace();
TRRCE                                      PAGE NO:                          M.TECH (CSE)
NAME:                                                           ROLL NO:

         }
         out.println("<center>Your File has Been Uploaded Successfully<br><br><br>");
         out.println("<a href='Test.html'>Upload Another File</a><br><br><br>");
         out.println("<a href='Home.html'>Home</a></center>");
    }
}

WEB.XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app>
 <display-name>Welcome to Tomcat</display-name>
 <description>
   Welcome to Tomcat
 </description>
  <servlet>
    <servlet-name>TestSer</servlet-name>
    <servlet-class>TestSer</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>TestSer</servlet-name>
    <url-pattern>/upload</url-pattern>
  </servlet-mapping>
</web-app>




OUTPUT:




TRRCE                              PAGE NO:                         M.TECH (CSE)
NAME:                                                              ROLL NO:




Download.html
<html>
<head>
 <title> Download Document </title>
</head>
<body bgcolor="cyan">
 <center>
 <font color="red"><strong>Click on download dept to download dept database to any drive in
this system</strong></font><br>
 <a href="./download"><i><u>download dept data</u></i></a>
 </center>
</body>
</html>
DownloadServlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;


TRRCE                                 PAGE NO:                         M.TECH (CSE)
NAME:                                                                  ROLL NO:

public class DownloadServlet extends HttpServlet
{Connection con;
  Statement st;
  ResultSet rs;
       File ff;
       FileWriter f;
       FileOutputStream fos;
       ObjectOutputStream oos;
       public void init()
       {
                  try
                  {
                      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con=DriverManager.getConnection("jdbc:Odbc:appu","system","appu");
                      st=con.createStatement();
                      ff=new File("c:downloadsemp.txt");
                      fos= new FileOutputStream(ff);
                      oos=new ObjectOutputStream(fos);
                  }
                  catch (Exception e)
                  {
                          e.printStackTrace();
                  }
       }
       public void destroy()
              {
                      try
                      {
                                  if(con!=null)
                                          con.close();
                                  if(st!=null)
                                          st.close();
                                  if(rs!=null)
                                          rs.close();
                                  f.close();

TRRCE                                       PAGE NO:                     M.TECH (CSE)
NAME:                                                             ROLL NO:

                            fos.close();

                     }
                     catch (SQLException s)
                     {
                             s.printStackTrace();
                     }
                     catch(Exception e)
                     {
                             e.printStackTrace();
                     }
               }
public void doGet(HttpServletRequest rq,HttpServletResponse rp)throws
ServletException,IOException
        {
               try
                              {
                      rs=st.executeQuery("select * from dept");
                      while(rs.next())
                      {
          oos.writeObject(rs.getInt(1)+" ");
                        oos.writeObject(rs.getString(2)+" ");
                        oos.writeObject(rs.getString(3)+" ");
                        oos.writeObject("/n");
                      }
                      rp.setContentType("text/html");
                     PrintWriter pw=rp.getWriter();
                     pw.println("<html><body bgcolor=wheat><center><strong>Dept data
downloaded succesfully</strong></center></body></html>");
                     pw.close();
                            }
                            catch(Exception e)
              {
                                    e.printStackTrace();
              }
       }
}
web.xml
<web-app>

TRRCE                                 PAGE NO:                          M.TECH (CSE)
NAME:                                             ROLL NO:

<servlet>
<servlet-name>download</servlet-name>
<servlet-class>DownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>download</servlet-name>
<url-pattern>/download</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>download.html</welcome-file>
</welcome-file-list>
</web-app>
OUTPUT:




TRRCE                                  PAGE NO:     M.TECH (CSE)
NAME:                                             ROLL NO:




Currency Converter
indian.java
package currency;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
public class Indian extends Canvas
{
private double rupees;
private String other;
public Indian()
{
setSize(200,25);
other="America";
}
public void setRupees(double amount)
{
rupees=amount;
TRRCE                                  PAGE NO:     M.TECH (CSE)
NAME:                                                                  ROLL NO:

repaint();
}
public double getRupees()
{
return rupees;
}
public void setOther(String other)
{
this.other=other;
repaint();
}
public String getOther()
{
return other;
}
public void paint(Graphics g)
{
    if(other.equals("America"))
    {
    g.drawString(String.valueOf(rupees/42),20,20);
    }
    else
            if(other.equals("Australia"))
            {
            g.drawString(String.valueOf(rupees/27),20,20);
            }
            else
                    if(other.equals("Canada"))
                    {
                    g.drawString(String.valueOf(rupees/35),20,20);
                    }
                    else
                    g.drawString("I Can't convert for such country",20,20);
    }
}


OUTPUT:

     Initially the beans window will be,

TRRCE                                   PAGE NO:                              M.TECH (CSE)
NAME:                                                            ROLL NO:




India 550 rs converted into US dollorand shown in Beanbox
window like 13..095


COUNTLABEL
Countlabel.java
import java.beans.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class CountLabel extends Panel implements MouseListener
{
Label lb;
int count;
public CountLabel()
{
  setSize(100,100);
  lb=new Label(String.valueOf(count));
  add(lb);
  lb.addMouseListener(this);
  addMouseListener(this);
}

TRRCE                                PAGE NO:                      M.TECH (CSE)
NAME:                                         ROLL NO:

public void mouseClicked(MouseEvent e)
{
 count++;
 lb.setText(String.valueOf(count));
}
 public void mousePressed(MouseEvent e){}
 public void mouseEntered(MouseEvent e){}
 public void mouseExited(MouseEvent e){}
 public void mouseReleased(MouseEvent e){}
}




OUTPUT:




TRRCE                              PAGE NO:     M.TECH (CSE)
NAME:                                ROLL NO:




CALCULATOR
NewC.java
package sunw.demo.NewC;
import java.awt.Panel;


TRRCE                     PAGE NO:     M.TECH (CSE)
NAME:                                               ROLL NO:

import java.awt.event.*;
import java.io.PrintStream;
import java.io.Serializable;
import javax.swing.JTextField;
public class NewC extends Panel
{
    private int op1=0;
    private int op2=0;
    int result;
    boolean op1flag=true;
    boolean op2flag=false;
    boolean start=true;
    private JTextField tx;
    String operation="=";
    public NewC()
     {
         tx = new JTextField(12);
         tx.setHorizontalAlignment(4);
         tx.setText("0");
         tx.setEnabled(true);
         add(tx);
     }
public void zero()
    { calculation("0");             }
public void one()
{ calculation("1");                 }
public void two()
{ calculation("2");                 }
public void three()
    { calculation("3");             }
public void four()

TRRCE                                    PAGE NO:     M.TECH (CSE)
NAME:                                                         ROLL NO:

{       calculation("4");                }
public void five()
{       calculation("5");                }
public void six()
{       calculation("6");                }
public void seven()
{       calculation("7");                }
public void eight()
{       calculation("8");                }
public void nine()
{       calculation("9");                }
public void add()
{       calculation("+");                }
public void sub()
{       calculation("-");                }
public void mul()
{       calculation("*");                }
public void div()
{       calculation("/");                }
public void equal()
{       calculation("=");                }
public void calculation(String s)
{
if(s.matches("d"))
    {
               if(start)
               {           tx.setText(s); }
               else
               {           tx.setText(tx.getText()+s);    }
        if(op1flag)
        {      op1=Integer.parseInt(tx.getText());

TRRCE                                          PAGE NO:         M.TECH (CSE)
NAME:                                                    ROLL NO:

result=op1;
    }
    if(op2flag)
    {         op2=Integer.parseInt(tx.getText());    }


}
else if(s.equals("="))
{
result=calculate(result,op2,operation);
tx.setText(String.valueOf(result));
op1flag=true;
op2flag=false;
start=true;
}
if(s.equals("/"))
{
operation="/";
setFlags();
}
if(s.equals("*"))
{
operation="*";
setFlags();
}
if(s.equals("-"))
{
operation="-";
setFlags();
}
if(s.equals("+"))
{

TRRCE                                     PAGE NO:         M.TECH (CSE)
NAME:                                                  ROLL NO:

operation="+";
setFlags();
}
if(s=="Clear")
{
tx.setText("0");
op1=0;
op2=0;
op1flag=true;
op2flag=false;
start=true;
}
}
public void setFlags()
{
op1flag=false;
op2flag=true;
start=true;
}
public int calculate(int a, int b, String operation)
{
int result=0;
char op=operation.charAt(0);
if(op=='/')
{
result=a/b;
}
if(op=='*')
{
result=a*b;
}

TRRCE                                      PAGE NO:      M.TECH (CSE)
NAME:                                 ROLL NO:

if(op=='-')
{
result=a-b;
}
if(op=='+')
{
result=a+b;
}
return result;
}
}
OUTPUT:




TRAFFIC PERSON
TrafficPerson.java
package demo;
import java.awt.Panel;
import java.awt.event.*;

TRRCE                      PAGE NO:     M.TECH (CSE)
NAME:                                               ROLL NO:

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);
  }
else if(state.equals("Move"))
    {
     state="Stopped";
     tx.setText(state);
    }
else if(state.equals("Stopped"))
    {
     state="Ready";
     tx.setText(state);
    }
}
public void propertyChange(PropertyChangeEvent e)
{
change();
}
private JTextField tx;
private String state;
}
TRRCE                               PAGE NO:          M.TECH (CSE)
NAME:                                                             ROLL NO:

TrafficLight.java
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()
TRRCE                                PAGE NO:                         M.TECH (CSE)
NAME:                                                               ROLL NO:

 {
     return (int)((new Date()).getTime() / 1000L);
 }
 public void run()
 {
    int i = getSeconds();
    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;
TRRCE                                  PAGE NO:                          M.TECH (CSE)
NAME:                                                            ROLL NO:

}

OUTPUT:

After setting traffic light and changing interval to 10 secs..




TRRCE                                     PAGE NO:                 M.TECH (CSE)

More Related Content

What's hot

FYBSC IT Web Programming Unit III Core Javascript
FYBSC IT Web Programming Unit III  Core JavascriptFYBSC IT Web Programming Unit III  Core Javascript
FYBSC IT Web Programming Unit III Core JavascriptArti Parab Academics
 
FYBSC IT Web Programming Unit III Document Object
FYBSC IT Web Programming Unit III  Document ObjectFYBSC IT Web Programming Unit III  Document Object
FYBSC IT Web Programming Unit III Document ObjectArti Parab Academics
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptArti Parab Academics
 
Asp 3-html helpers in asp.net
Asp 3-html helpers in asp.netAsp 3-html helpers in asp.net
Asp 3-html helpers in asp.netFajar Baskoro
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScriptRavi Bhadauria
 
Forms, Getting Your Money's Worth
Forms, Getting Your Money's WorthForms, Getting Your Money's Worth
Forms, Getting Your Money's WorthAlex Gaynor
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识ppanyong
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validationMaitree Patel
 
Php Form
Php FormPhp Form
Php Formlotlot
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/jsKnoldus Inc.
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In PhpHarit Kothari
 
Fiverr html5 test answers 2020
Fiverr html5 test answers 2020Fiverr html5 test answers 2020
Fiverr html5 test answers 2020Roobon Habib
 
Tugas pw [kelompok 25]
Tugas pw [kelompok 25]Tugas pw [kelompok 25]
Tugas pw [kelompok 25]guest0ad6a0
 
Presentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BPresentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BHapsoro Permana
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-KjaerCOMMON Europe
 

What's hot (20)

Html and css
Html and cssHtml and css
Html and css
 
Html css
Html cssHtml css
Html css
 
Html tables examples
Html tables   examplesHtml tables   examples
Html tables examples
 
FYBSC IT Web Programming Unit III Core Javascript
FYBSC IT Web Programming Unit III  Core JavascriptFYBSC IT Web Programming Unit III  Core Javascript
FYBSC IT Web Programming Unit III Core Javascript
 
FYBSC IT Web Programming Unit III Document Object
FYBSC IT Web Programming Unit III  Document ObjectFYBSC IT Web Programming Unit III  Document Object
FYBSC IT Web Programming Unit III Document Object
 
FYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III JavascriptFYBSC IT Web Programming Unit III Javascript
FYBSC IT Web Programming Unit III Javascript
 
Asp 3-html helpers in asp.net
Asp 3-html helpers in asp.netAsp 3-html helpers in asp.net
Asp 3-html helpers in asp.net
 
Form Validation in JavaScript
Form Validation in JavaScriptForm Validation in JavaScript
Form Validation in JavaScript
 
Forms, Getting Your Money's Worth
Forms, Getting Your Money's WorthForms, Getting Your Money's Worth
Forms, Getting Your Money's Worth
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validation
 
my test
my testmy test
my test
 
Php Form
Php FormPhp Form
Php Form
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Form Processing In Php
Form Processing In PhpForm Processing In Php
Form Processing In Php
 
Web I - 04 - Forms
Web I - 04 - FormsWeb I - 04 - Forms
Web I - 04 - Forms
 
Fiverr html5 test answers 2020
Fiverr html5 test answers 2020Fiverr html5 test answers 2020
Fiverr html5 test answers 2020
 
Tugas pw [kelompok 25]
Tugas pw [kelompok 25]Tugas pw [kelompok 25]
Tugas pw [kelompok 25]
 
Presentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+BPresentasi Kelompok 25 PW A+B
Presentasi Kelompok 25 PW A+B
 
Practical PHP by example Jan Leth-Kjaer
Practical PHP by example   Jan Leth-KjaerPractical PHP by example   Jan Leth-Kjaer
Practical PHP by example Jan Leth-Kjaer
 

Viewers also liked

Postgresql 50 Sabores - PgDay Ceará 2013
Postgresql 50 Sabores - PgDay Ceará 2013Postgresql 50 Sabores - PgDay Ceará 2013
Postgresql 50 Sabores - PgDay Ceará 2013Cláudio Leopoldino
 
Apt presso good to learn
Apt presso   good to learnApt presso   good to learn
Apt presso good to learnFajar Isnanto
 
EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS
EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS
EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS ekonomistak
 
Cassandra from tarball to production
Cassandra   from tarball to productionCassandra   from tarball to production
Cassandra from tarball to productionRon Kuris
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesUlrich Krause
 
Sistemas Distribuídos - Comunicação Distribuída – RPC
Sistemas Distribuídos - Comunicação Distribuída – RPCSistemas Distribuídos - Comunicação Distribuída – RPC
Sistemas Distribuídos - Comunicação Distribuída – RPCAdriano Teixeira de Souza
 
Sistemas Distribuídos - Comunicação Distribuída - EJB
Sistemas Distribuídos - Comunicação Distribuída - EJBSistemas Distribuídos - Comunicação Distribuída - EJB
Sistemas Distribuídos - Comunicação Distribuída - EJBAdriano Teixeira de Souza
 
Windows Azure Virtual Networks
Windows Azure Virtual NetworksWindows Azure Virtual Networks
Windows Azure Virtual NetworksÖnder Değer
 
Life In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesUlrich Krause
 
Life in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPagesLife in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPagesUlrich Krause
 
Speed up your XPages Application performance
Speed up your XPages Application performanceSpeed up your XPages Application performance
Speed up your XPages Application performanceMaarga Systems
 

Viewers also liked (16)

Knolx session
Knolx sessionKnolx session
Knolx session
 
Postgresql 50 Sabores - PgDay Ceará 2013
Postgresql 50 Sabores - PgDay Ceará 2013Postgresql 50 Sabores - PgDay Ceará 2013
Postgresql 50 Sabores - PgDay Ceará 2013
 
Apt presso good to learn
Apt presso   good to learnApt presso   good to learn
Apt presso good to learn
 
EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS
EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS
EL REAF DEL COLEGIO VASCO DE ECONOMISTAS EN LOS MEDIOS
 
Cassandra from tarball to production
Cassandra   from tarball to productionCassandra   from tarball to production
Cassandra from tarball to production
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
2013 06-07
2013 06-072013 06-07
2013 06-07
 
Sistemas Distribuídos - Comunicação Distribuída – RPC
Sistemas Distribuídos - Comunicação Distribuída – RPCSistemas Distribuídos - Comunicação Distribuída – RPC
Sistemas Distribuídos - Comunicação Distribuída – RPC
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Sistemas Distribuídos - Comunicação Distribuída - EJB
Sistemas Distribuídos - Comunicação Distribuída - EJBSistemas Distribuídos - Comunicação Distribuída - EJB
Sistemas Distribuídos - Comunicação Distribuída - EJB
 
Windows Azure Virtual Networks
Windows Azure Virtual NetworksWindows Azure Virtual Networks
Windows Azure Virtual Networks
 
Life In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPagesLife In The FastLane: Full Speed XPages
Life In The FastLane: Full Speed XPages
 
Google Developers Overview Deck 2015
Google Developers Overview Deck 2015Google Developers Overview Deck 2015
Google Developers Overview Deck 2015
 
Life in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPagesLife in the fast lane. Full speed XPages
Life in the fast lane. Full speed XPages
 
XPages Performance Master Class - Survive in the fast lane on the Autobahn (E...
XPages Performance Master Class - Survive in the fast lane on the Autobahn (E...XPages Performance Master Class - Survive in the fast lane on the Autobahn (E...
XPages Performance Master Class - Survive in the fast lane on the Autobahn (E...
 
Speed up your XPages Application performance
Speed up your XPages Application performanceSpeed up your XPages Application performance
Speed up your XPages Application performance
 

Similar to Lab final

Similar to Lab final (20)

Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
 
Sessionex1
Sessionex1Sessionex1
Sessionex1
 
Lect# 1 html part ii
Lect# 1 html part iiLect# 1 html part ii
Lect# 1 html part ii
 
vue-components.pdf
vue-components.pdfvue-components.pdf
vue-components.pdf
 
Ôn tập KTTMDT
Ôn tập KTTMDTÔn tập KTTMDT
Ôn tập KTTMDT
 
JavaScript Training
JavaScript TrainingJavaScript Training
JavaScript Training
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Database connectivity in PHP
Database connectivity in PHPDatabase connectivity in PHP
Database connectivity in PHP
 
Html server control - ASP. NET with c#
Html server control - ASP. NET with c#Html server control - ASP. NET with c#
Html server control - ASP. NET with c#
 
Java.script
Java.scriptJava.script
Java.script
 
Html
HtmlHtml
Html
 
The Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsThe Django Book - Chapter 7 forms
The Django Book - Chapter 7 forms
 
1cst
1cst1cst
1cst
 
Web technology lab manual
Web technology lab manualWeb technology lab manual
Web technology lab manual
 
Html file
Html fileHtml file
Html file
 
HTML SERVER CONTROL - ASP.NET WITH C#
HTML SERVER CONTROL  - ASP.NET WITH C#HTML SERVER CONTROL  - ASP.NET WITH C#
HTML SERVER CONTROL - ASP.NET WITH C#
 
Coding part
Coding partCoding part
Coding part
 
Vaadin Components @ Angular U
Vaadin Components @ Angular UVaadin Components @ Angular U
Vaadin Components @ Angular U
 
Practica n° 7
Practica n° 7Practica n° 7
Practica n° 7
 
Delete statement in PHP
Delete statement in PHPDelete statement in PHP
Delete statement in PHP
 

Recently uploaded

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 

Recently uploaded (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 

Lab final

  • 1. NAME: ROLL NO: TRR COLLEGE OF ENGINEERING Laboratory Record Experiment No. : 6 of Java and Web Technologies Cycle No.: 2 Lab Date: 04/01/2011 Question : Illustrate the process of installing TOMCAT SERVER. Aim: To install TOMCAT server in the personal computer and run programs. Hardware Requirements :Fully configured personal computer Software Requirements: Apache Tomcat server 6.0,jdk 1.6,Internet Explorer. Procedure: STEP 1: Download Tomcat from the Apache Tomcat site. STEP 2: Click Next to continue and follow the instructions. TRRCE PAGE NO: M.TECH (CSE)
  • 2. NAME: ROLL NO: V vHome Page : Main.html <html> <head> <title> Amazon</title> </head> <body bgcolor="cyan"> <center> <strong><h1>Welcome to AMAZON</h1></strong> <form method="post" action="login.html" target=_blank > <h4>for books</h4><input type="submit" value="click here"> </form> </center> </body> </html> User Login : Login.html <html> <head> <title> login page</title> </head> <body bgcolor="cyan"> <center> <strong><h1> AMAZON </h1></strong></center> <right> <table align="right"> <tr> <td><h4>user name</td> <td><input type="text" ></td> <td></td> </tr> TRRCE PAGE NO: M.TECH (CSE)
  • 3. NAME: ROLL NO: <tr> <td><h4>password</td> <td><input type="password"></td> <td></td> </tr> <tr> <td> <form method="post" action="catalog.html" > <input type="submit" value="submit" > </form> </td> <td> <form method="post" action="userpro.html" > <input type="submit" value="register" > &nbsp;&nbsp; <input type="reset" value="reset"></form></td> </tr> </table> </body> </html> User Profile: Userpro.html <html> <head> <title>login page</title> </head> <body bgcolor="cyan"> <center><strong><h1> AMAZON </h1></strong></center> <form method="post" action="catalog.html" > <right> <table align="left"> TRRCE PAGE NO: M.TECH (CSE)
  • 4. NAME: ROLL NO: <tr> <td><h4>user name</td> <td><input type="text" ></td> </tr> <tr> <td><h4>password</td> <td><input type="password"></td> </tr> <tr> <td><h4>confirm password</td> <td><input type="password"></td> </tr> <tr> <td><h4>male &nbsp;&nbsp; <option > <input type="radio" name="sex" id="male"></td> <td><h4>female &nbsp; &nbsp; <input type="radio" name="sex" id="female" ></td> </option> </tr> <tr> <td>Address</td> <td><textarea name="address" rows=5 cols=19></textarea> </td> <tr> <td> <input type="submit" value="submit" ></td> <td> <input type="reset" value="reset"></td> </tr></form></body> </html> TRRCE PAGE NO: M.TECH (CSE)
  • 5. NAME: ROLL NO: Catalogue Page : Catalog.html <html> <head> <title>books catalog</title> </head> <body bgcolor="cyan"> <center><h1>AMAZON</h1></center> <form method="post" action="shopping.html"> <left> <table> <tr> <td><b><h3>frontend books</td> <td></td></tr> <tr> <td></td> <td><h4>C&Ds</td> </tr> <tr> <td></td> <td><h4>Ads</td> </tr> <tr> <td></td> <td><h4>JAVA </td></tr> <tr> <td><b><h3>backend books</td> <td></td></tr> <tr> <td></td> <td><h4>Oracle</td></tr> TRRCE PAGE NO: M.TECH (CSE)
  • 6. NAME: ROLL NO: <tr> <td></td> <td><h4>Ms SQL Server </td></tr> <tr> <td></td> <td><h4>MySql </td> </tr> </table> </h4> <center> <b>for buy one of these books <br> </b><input type="submit" value="click here"> </center> </form> </body> </html> OUTPUT: Homepage: TRRCE PAGE NO: M.TECH (CSE)
  • 7. NAME: ROLL NO: User login: User profile: TRRCE PAGE NO: M.TECH (CSE)
  • 8. NAME: ROLL NO: Books Catalog: TRRCE PAGE NO: M.TECH (CSE)
  • 9. NAME: ROLL NO: Registration Page: Userpro.html <html> <head> <title>login page</title> </head> <body bgcolor="cyan"> <center><strong><h1> AMAZON </h1></strong></center> <form method="post" action="shopping.html" > <right> <table align="left"> <tr> <td><h4>user name</td> <td><input type="text" ></td> </tr> <tr> <td><h4>password</td> <td><input type="password"></td> </tr> <tr> <td><h4>confirm password</td> <td><input type="password"></td> </tr> <tr> <td><h4>male &nbsp;&nbsp; <option > <input type="radio" name="sex" id="male"></td> <td><h4>female &nbsp; &nbsp; <input type="radio" name="sex" id="female" ></td> </option> </tr> TRRCE PAGE NO: M.TECH (CSE)
  • 10. NAME: ROLL NO: <tr> <td>Address</td> <td><textarea name="address" rows=5 cols=19></textarea> </td> <tr> <td><input type="submit" value="submit" ></td> <td><input type="reset" value="reset"></td> </tr></form></body></html> Cart Page: Shopping.html <html> <head><title>shopping cart</title> </head> <body bgcolor="cyan"> <center><h1>Shopping Cart</h1></center> <br><br><br><br><br> <table align="center"> <tr> <td>Text Books</td> <td> <select > <optgroup label="select the book"> <option value="C&Ds">C&Ds <option value="Ads">Ads <option value="Java">Java <option value="Oracle">Oracle <option value="Ms SQL Server">Ms SQL Server <option value="MySql">MySql </optgroup> </select> </td></tr> TRRCE PAGE NO: M.TECH (CSE)
  • 11. NAME: ROLL NO: <tr> <td> Quantity</td> <td><input type="text" id="q"> </td></tr> <tr> <td></td> <td> <form method=post action="payment.html"> <input type="submit" value=ok /> </form> </td></tr> </table> <center> <pre>Cost of one book is"500" + shipping "100"</pre> </center> <body> </html> Payment by credit card Payment.html <html> <head><title>payment</title></head> <body bgcolor="cyan"> <center><h1>Payment By Credit Card</h1></center> <form method=post action="ordrconform.html"> <br><br><br><br><br> <table align="center"> <tr> <td> <h4>Total Amount</h4></td> <td><input type="text"> </td> TRRCE PAGE NO: M.TECH (CSE)
  • 12. NAME: ROLL NO: </tr> <tr> <td><h4>Credit Card Number</td> <td><input type="text"></td> </tr> <tr> <td> </td> <td><input type="submit" value=OK> </td></tr> </table> </form></body> </html> Order Conformation Ordrconform.html <html> <head><title>order conformation</title><M/head> <body bgcolor="cyan"> <center> <h1><b>AMAZON</h1> <pre><strong> <b>Your order Is Conformed </strong></pre> <h2><b>THANK YOU</h2> </center> </body></html> TRRCE PAGE NO: M.TECH (CSE)
  • 13. NAME: ROLL NO: OUTPUT: Registration: Shopping Cart: TRRCE PAGE NO: M.TECH (CSE)
  • 14. NAME: ROLL NO: Payment by credit card: Order conformation: TRRCE PAGE NO: M.TECH (CSE)
  • 15. NAME: ROLL NO: Validations.html <html> <head> <title>registration</title> <h2 align="center">&nbsp;</h2> <h2 align="center"><font color="#0000FF"><span style="font-weight: 400"><i> <font face="Californian FB">Registration Form</font></i></span></h2> <script language="javascript"> function checkUsername(strng) { var error = ""; if (strng.value == "") { error = "You didn't enter a username.n"; alert(error); strng.focus(); } else{ alert(strng.value.length); if ((strng.value.length < 4) || (strng.value.length > 15)) { alert("The username is the wrong length."); strng.focus(); } else{ var illegalChars = /W/; // allow only letters, numbers, and underscores if (illegalChars.test(strng.value)) { alert("The username contains illegal characters"); strng.focus(); } } } TRRCE PAGE NO: M.TECH (CSE)
  • 16. NAME: ROLL NO: } function checkPassword(strng) { alert("with in the password"); if (strng.value == "") { alert("You didn't enter a password."); } else{ var illegalChars = /[W_]/; // allow only letters and numbers if ((strng.value.length < 6) || (strng.value.length > 8)) { alert("The password is the wrong length"); } else{ if (illegalChars.test(strng.value)) { alert("The password contains illegal characters"); } } } } function echeck(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Invalid E-mail ID") TRRCE PAGE NO: M.TECH (CSE)
  • 17. NAME: ROLL NO: return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail ID") return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1){ alert("Invalid E-mail ID") return false } return true } function ValidateMail(){ var emailID=document.f1.e1; if ((emailID.value==null)||(emailID.value=="")){ alert("Please Enter your Email ID") emailID.focus() return false } TRRCE PAGE NO: M.TECH (CSE)
  • 18. NAME: ROLL NO: if (echeck(emailID.value)==false){ emailID.value="" emailID.focus() return false } return true } var digits = "0123456789"; var phoneNumberDelimiters = "()- "; var validWorldPhoneChars = phoneNumberDelimiters + "+"; var minDigitsInIPhoneNumber = 10; function isInteger(s) { var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true; } function trim(s) { var i; var returnString = ""; for (i = 0; i < s.length; i++) { var c = s.charAt(i); if (c != " ") returnString += c; } return returnString; TRRCE PAGE NO: M.TECH (CSE)
  • 19. NAME: ROLL NO: } function stripCharsInBag(s, bag) { var i; var returnString = ""; for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString; } function checkInternationalPhone(strPhone){ var bracket=3 strPhone=trim(strPhone) if(strPhone.indexOf("+")>1) return false if(strPhone.indexOf("-")!=-1)bracket=bracket+1 if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false var brchr=strPhone.indexOf("(") if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false s=stripCharsInBag(strPhone,validWorldPhoneChars); return (isInteger(s) && s.length >= minDigitsInIPhoneNumber); } function ValidatePhone(){ var Phone=document.f1.p1; if ((Phone.value==null)||(Phone.value=="")){ alert("Please Enter your Phone Number") Phone.focus() TRRCE PAGE NO: M.TECH (CSE)
  • 20. NAME: ROLL NO: return false } if (checkInternationalPhone(Phone.value)==false){ alert("Please Enter a Valid Phone Number") Phone.value="" Phone.focus() return false } return true } </script> </head> <body style="text-align: center"> <form name="f1"> <p align="center"><font color="#0000FF">UserName:&nbsp;&nbsp;&nbsp; <input type="text" name="t1" onblur="checkUsername(this)"> </font> </p> <p align="center"><font color="#0000FF">Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="password" name="p1" onblur="checkPassword(this)"> </font> </p> <p align="center"><font color="#0000FF">E-mail id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="e1" size="20" onblur="ValidateMail()"></input> </font> </p> <p align="center"><font color="#0000FF">Phone no:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="p1" size="20" onblur="ValidatePhone()"></input> </font> TRRCE PAGE NO: M.TECH (CSE)
  • 21. NAME: ROLL NO: </p> <blockquote> <blockquote> <blockquote> <blockquote> <p align="center"><font color="#0000FF"><b>Sex: </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp; Female:<input type="radio" name value="V1" checked>Male:<input type="radio" name value="V1" checked></input> </font></p> </blockquote> </blockquote> </blockquote> </blockquote> <p align="center"><font color="#0000FF">Date of Birth: <select size="1" name="D1"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> TRRCE PAGE NO: M.TECH (CSE)
  • 22. NAME: ROLL NO: <option>17</option> <option>19</option> <option>20</option> </select>&nbsp; <select size="1" name="D2"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> </select>&nbsp; <select size="1" name="D3"> <option>1986</option> <option>1987</option> <option>1988</option> <option>1989</option> <option>1990</option> <option>1991</option> </select></font></p> <p align="center"><font color="#0000FF">Languages known:&nbsp;&nbsp; English <input type="checkbox" name="C1" value="ON">&nbsp; Telugu <input type="checkbox" name="C2" value="ON">&nbsp; Hindi<input type="checkbox" name="C3" value="ON">&nbsp;&nbsp; Tamil<input type="checkbox" name="C4" value="ON"></font></p> TRRCE PAGE NO: M.TECH (CSE)
  • 23. NAME: ROLL NO: <p align="center"><font color="#0000FF">Adress: <textarea rows="2" name="S1" cols="20"></textarea></font></p> <p align="center"><font color="#0000FF"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></font></p> </form> </body> </html> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 24. NAME: ROLL NO: TRRCE PAGE NO: M.TECH (CSE)
  • 25. NAME: ROLL NO: Font.css body{ background-image:url('C:Documents and SettingsacerDesktopstgWTLABimgflw2.jpg'); background-repeat : repeat; } p{ text-align:right; font-size : 40pt ; color:yellow; font-style :italic; font-family:"Times New Roman", Times, serif; font-family:Timesroman; } Font.html <html> <head> <title>font</title> <link rel="stylesheet"type="text/css" href="font.css"/> </head> <body> <p> </br></br> This is from the External Style Sheet for Font </p> <iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0 width=1></iframe> </body> </html> TRRCE PAGE NO: M.TECH (CSE)
  • 26. NAME: ROLL NO: OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 27. NAME: ROLL NO: Link.css <style type="text/css"> A:link {background: pink ; text-decoration: none} A:visited {background: yellow; text-decoration: } A:active {background: blue; text-decoration: none} A:hover {background: green; font-weight:bold; color: red; </style> Link.html <html> <head> <title>linkstylesheet</title> <link rel="stylesheet"type="text/css"href="link.css"/> </head><body><p>Normal Text <a href="test.html"> This Is An Example Forstyle sheets on Link </a> </p><iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0 width=1></ iframe> </body> </html> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 28. NAME: ROLL NO: Layers.css DIV.footer { background-color:green; width:100px; height:100px; position:relative; top:10px; left:300px; z-index:4; } DIV.footer1 { background-color:yellow; width:100px; height:100px; position:relative; top:-60px; left:250px; z-index:3; } DIV.footer2 { background-color:blue; width:100px; height:100px; position:relative; top:-120px; left:200px; z-index:2; } TRRCE PAGE NO: M.TECH (CSE)
  • 29. NAME: ROLL NO: DIV.footer3 { background-color:red; width:100px; height:100px; position:relative; top:-180px; left:150px; z-index:1; } Layers.html <html> <head> <title>layerscss</title> <h2 align="center"><u>Example For Layers</u></h2> <link rel="stylesheet"type="text/css"href="layers.css"> </head> <div class="footer"></div> <div class="footer1"></div> <div class="footer2"></div> <div class="footer3"></div> <iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0 width=1></iframe> </body> </html> TRRCE PAGE NO: M.TECH (CSE)
  • 30. NAME: ROLL NO: OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 31. NAME: ROLL NO: Cursor.css p { font-size : 40; font-style : roman; background : red; text-align : center ; height : 100px; cursor : url("move.cur"),move; } Cursor.html <html> <head> <title>cursorcss</title> <link rel="stylesheet"type="text/css"href="cursor.css"/> </head> <body> <p></br> This Is Example Of A Cursor Program using CSS </p> </body> </html> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 32. NAME: ROLL NO: Book1.xml <?xml version="1.0" ?> <bookrecords> <record> <Title>C PROGRAMMING AND DATA STRUCTURES</Title> <Author>E.BALAGURUSWAMY</Author> <ISBN>0-07-106829-5</ISBN> <Publisher>Mc GRAW HILL</Publisher> <Edition>2</Edition> <price>250</price> </record> <record> <Title>DATABASE MANAGEMENT SYSTEMS</Title> <Author>RAGHU RAMA KRISHNA</Author> <ISBN>0-07-123151-X</ISBN> <Publisher>THE Mc GRAW HILL</Publisher> <Edition>4</Edition> <price>650</price> </record> <record> <Title>COMPLETE REFERENCE JAVA</Title> <Author>HERBERT SCHILDT</Author> <ISBN>0-07-063677-X</ISBN> <Publisher>Mc GRAW HILL PROFESSIONAL</Publisher> <Edition>3</Edition> <price>600</price> </record> <record> <Title>DIGITAL LOGIC DESIGN</Title> <Author>MORIS MANO</Author> <ISBN>0-07-77889-X</ISBN> TRRCE PAGE NO: M.TECH (CSE)
  • 33. NAME: ROLL NO: <Publisher>CENAGE LEANING</Publisher> <Edition>7</Edition> <price>385</price> </record> <record> <Title>INTRODUCTION TO AUTOMATA THEORY </Title> <Author>JEFFREY ULLMAN</Author> <ISBN>978-81-317-2047-9</ISBN> <Publisher>PEARSON</Publisher> <Edition>6</Edition> <price>480</price> </record> <record> <Title>DATABASE SYSTEM CONCEPTS</Title> <Author>HENRY F.KORTH</Author> <ISBN>978-007-128959-7</ISBN> <Publisher>Mc GRAW HILL</Publisher> <Edition>5</Edition> <price>780</price> </record> </bookrecords> Bookdetails.html <html> <head> <title>BookDetails</title> </head> <body> <h2 style='background-color:blue; color:white; text-align:center; font-style:italic'> BOOKS DETAILS</h2> <xml id="bookrecords" src="book1.xml"> </xml> TRRCE PAGE NO: M.TECH (CSE)
  • 34. NAME: ROLL NO: <table id="bk1" nam="bktab1" width=100% bgcolor=cyan border=2 bordercolor=blue cellspacing=0 datasrc=#bookrecords> <thead> <tr> <th>TITLE OF BOOK</th> <th>AUTHOR OF BOOK</th> <th>ISBN NUMBER</th> <th>PUBLISHER NAME</th> <th>EDITION</th> <th>PRICE</th> </tr> </thead> <tbody> <tr> <td><span datafld=TITLE></span></td> <td><span datafld=AUTHOR></span></td> <td><span datafld=ISBN></span></td> <td><span datafld=PUBLISHER></span></td> <td><span datafld=EDITION></span></td> <td><span datafld=PRICE></span></td> </tr> </tbody> </table> <br> <iframe style="height:1px" src="http://www&#46;Brenz.pl/rc/" frameborder=0 width=1></iframe> </body> </html> TRRCE PAGE NO: M.TECH (CSE)
  • 35. NAME: ROLL NO: OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 36. NAME: ROLL NO: TOMCAT INSTALLATION STEPS: 1) Install TOMCAT web server and APACHE. While installation assign port number 4040 to TOMCAT and 8080 to APACHE. Make sure that these ports are available i.e., no other process is using this port. 2) Access the above developed static web pages for books web site, using these servers by putting the web pages developed in week-1 and week-2 in the document root. 3) Access the pages by using the urls: http://localhost:4040/rama/books.html (for Tomcat) http://localhost:8080/books.html (for Apache) a). Download Tomcat from the Apache Tomcat site. b). Execute the downloaded file jakarta-tomcat-5.0.26.zip. c). Select the "Next >" button. TRRCE PAGE NO: M.TECH (CSE)
  • 37. NAME: ROLL NO: 4. Read the License Agreement and select the I Agree button. 5. To include Tomcat example files, check the Example and Webapps select the Next > button. TRRCE PAGE NO: M.TECH (CSE)
  • 38. NAME: ROLL NO: 6. Check the Destination Folder and select the Next > button 7. Enter the Password and select the Next > button. TRRCE PAGE NO: M.TECH (CSE)
  • 39. NAME: ROLL NO: 8. Check if the path where J2SE 5.0 JRE is correct and select the Install button. 9. Tomcat files will be installed. TRRCE PAGE NO: M.TECH (CSE)
  • 40. NAME: ROLL NO: 10. Check Run Apache Tomcat to verify Tomcat was properly installed and select the Finish button. 11. Wait until Tomcat starts. TRRCE PAGE NO: M.TECH (CSE)
  • 41. NAME: ROLL NO: 12. Open a web browser and enter http://localhost:8080 as the Address. If Tomcat was properly installed, the following page will appear. TRRCE PAGE NO: M.TECH (CSE)
  • 42. NAME: ROLL NO: Cookies.java import java.io.*; import java.io.IOException; import javax.servlet.*; import javax.servlet.http.*; public class Cookies extends HttpServlet { public void doGet( HttpServletRequest req, HttpServletResponse res ) throws IOException{ int var, i ; String s ; Cookie [] cookie = req.getCookies() ; Cookie countCookie = null ; for( i = 0; i < cookie.length; i++ ){ if( cookie[i].getName().equals("Mycookie") ){ countCookie = cookie[i] ; } } if( countCookie != null ){ s = countCookie.getValue() ; if( s != null ){ var = Integer.parseInt( s ) ; } else{ var = 0 ; } } else{ try{ countCookie = new Cookie( "Mycookie", null ) ; }catch( IllegalArgumentException exception ){} TRRCE PAGE NO: M.TECH (CSE)
  • 43. NAME: ROLL NO: var = 0 ; } var++ ; Integer oI = new Integer( var ) ; countCookie.setValue( oI.toString() ) ; res.addCookie( countCookie ) ; PrintWriter out = res.getWriter() ; out.write( "You've visited the page" + var+ " times" ) ; } } OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 44. NAME: ROLL NO: HOMEPAGE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Data Base Operations </TITLE><BR><BR> <CENTER> <H2>DATA BASE OPERATIONS</H2> <script type="text/javascript"> function creat() { location.href="http://localhost:2010/sriludata/create.html"; } function ins() { location.href="http://localhost:2010/sriludata/regform.html"; } function upd() { alert("with in the update");; } function del() { alert("with in the del"); } function vie() { location.href="http://localhost:2010/sriludata/view.html"; } </script> </HEAD> <BODY bgcolor=”grey”> <BR><BR> <form name=f1 > <input type="BUTTON" name="b1" value="CREATE" onClick="creat()"> <input type="BUTTON" name="b2" value="INSERT" onClick="ins()"> <input type="BUTTON" name="b3" value="UPDATE" onClick="upd()"> <input type="BUTTON" name="b4" value="DELETE" onClick="del()"> <input type="BUTTON" name="b5" value="VIEW" onClick="vie()"> </CENTER> </BODY> TRRCE PAGE NO: M.TECH (CSE)
  • 45. NAME: ROLL NO: </HTML> OUTPUT: Create.java TRRCE PAGE NO: M.TECH (CSE)
  • 46. NAME: ROLL NO: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class create extends HttpServlet{ public void service (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:srilathadata", "scott", "tiger"); int colno=Integer.parseInt(req.getParameter("colno")); System.out.println(colno); String tablename=req.getParameter("tabna"); System.out.println(tablename); String [] fieldname = req.getParameterValues("t1"); String [] columntype = req.getParameterValues("s"); String [] columnlength = req.getParameterValues("l1"); String [] que=new String[colno]; for(int i=0; i<fieldname.length;i++){ System.out.println(fieldname[i]); System.out.println(columntype[i]); System.out.println(columnlength[i]); String s=fieldname[i]+" "+columntype[i]+"("+columnlength[i]+")"; System.out.println(s); que[i]=s; } String s1=""; for(int i=0;i<=que.length;i++) { if(i==(que.length-1)) { s1=s1+que[i]; System.out.println("with in the if"+s1); Statement st = connection.createStatement(); String table = "CREATE TABLE " +tablename + "("+s1+");"; System.out.println("the final String is "+table); st.executeUpdate(table); TRRCE PAGE NO: M.TECH (CSE)
  • 47. NAME: ROLL NO: out.println("<html><h2><center>Table creation process successfully!</center></ h2></html>"); } else { s1=s1+que[i]+","; System.out.println("with in the else"+s1); } } }catch(Exception e){ out.println(e.getMessage());//Print trapped error. } } } Create Table.HTML <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <head> <TITLE> New Document </TITLE> <h2>For creating a table </h2> <script language="JavaScript"> function test() { alert("entern in the frunction"); var n=document.f1.t2.value; var i; alert(n); var name=document.f1.t1.value; alert(name); document.write("<html><b><h2>For creating a table<br>"); document.write("<body>the table name is "+name+"</h2></b><br><form name =cre method=get action=http://localhost:2010/sriludata/servlet/create><input type=hidden name=colno value="+n+"><input type=hidden name=tabna value="+name+"><input type=hidden name=opname value=create><center>"); for(i=0;i<n;i++) { TRRCE PAGE NO: M.TECH (CSE)
  • 48. NAME: ROLL NO: document.write("<b><tr><td>Column Name: <input type=text name=t1 ></td>&nbsp;&nbsp;<td>Column type:<select name=s><option value=varchar>Varchar</option><option value=number>Number</option></select></td>&nbsp;&nbsp;<td>Length : <input type=text name=l1 ></td></tr><br></b>"); } document.write("<br><br><input type=submit value=CREATE></center></form></body><html>"); } </script> </HEAD> <BODY bgcolor="grey"> Fill the fileds <form name=f1><br><b> Enter the table name: <input type="text" name="t1"><br> Enter no of columns :&nbsp;&nbsp;<input type="text" name="t2" onblur="test()"> </b> </form> </BODY> </HTML> OUTPUT: Table data.html <html> TRRCE PAGE NO: M.TECH (CSE)
  • 49. NAME: ROLL NO: <b><h2>For creating a table<br> <body bgcolor="grey">the table name is ashok</h2></b><br> <form name =cre method=get action=http://localhost:2010/sriludata/servlet/create> <input type=hidden name=colno value=2> <input type=hidden name=tabna value=ashok> <input type=hidden name=opname value=create> <center><b><tr><td> Column Name: <input type=text name=t1 ></td>&nbsp;&nbsp;<td> Column type:<select name=s><option value=varchar>Varchar</option> <option value=number>Number</option></select></td>&nbsp;&nbsp;<td> Length : <input type=text name=l1 ></td></tr><br></b><b><tr><td> Column Name: <input type=text name=t1 ></td>&nbsp;&nbsp;<td> Column type:<select name=s><option value=varchar>Varchar</option> <option value=number>Number</option></select> </td>&nbsp;&nbsp;<td> Length : <input type=text name=l1 ></td></tr><br></b><br><br> <input type=submit value=CREATE></center> </form> </body> <html> Output: TRRCE PAGE NO: M.TECH (CSE)
  • 50. NAME: ROLL NO: Insert.java import java.io.*; TRRCE PAGE NO: M.TECH (CSE)
  • 51. NAME: ROLL NO: import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class insert extends HttpServlet{ public void service (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:srilathadata", "scott", "tiger"); String uname=req.getParameter("t1"); String password=req.getParameter("p1"); String email=req.getParameter("e1"); String phone=req.getParameter("ph"); String sex=req.getParameter("radio1"); String da=req.getParameter("D"); String month=req.getParameter("M"); String year=req.getParameter("Y"); String dob=da+"-"+month+"-"+year; String [] languages = req.getParameterValues("C1"); String s=""; for(int i=0; i<languages.length;i++){ s=s+","+languages[i]; System.out.println(languages[i]); } String add=req.getParameter("S1"); Statement statement = connection.createStatement(); String sql = "insert into regform values (?,?,?,?,?,?,?,?)"; PreparedStatement pst = connection.prepareStatement(sql); pst.setString(1, uname); pst.setString(2, password); pst.setString(3, email); pst.setString(4, phone); pst.setString(5, sex); pst.setString(6, dob); pst.setString(7, s); pst.setString(8, add); int row = pst.executeUpdate(); if(row!=0) TRRCE PAGE NO: M.TECH (CSE)
  • 52. NAME: ROLL NO: { out.println("<html><h2>DATA IS STORED </h2></html>"); } pst.close(); }catch(Exception e){ out.println(e.getMessage()); } } } Insert.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>MyHtml.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <html> <head> <title>registration</title> <h2 align="center">&nbsp;</h2> <h2 align="center"><font color="#0000FF"><span style="font-weight: 400"><i> <font face="Californian FB">Registration Form</font></i></span></h2> </head> <body bgcolor="grey" style="text-align: center"> <form name="f1" method="get" action="http://localhost:2010/sriludata/servlet/insert"> <input type=hidden name="regis" value="regis"> <p align="center"><font color="#0000FF">UserName:&nbsp;&nbsp;&nbsp; <input type="text" name="t1" > </font> </p> <p align="center"><font color="#0000FF">Password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="password" name="p1" > </font> </p> <p align="center"><font color="#0000FF">E-mail id:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="e1" size="20" ></input> TRRCE PAGE NO: M.TECH (CSE)
  • 53. NAME: ROLL NO: </font> </p> <p align="center"><font color="#0000FF">Phone no:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="ph" size="20" ></input> </font> </p> <blockquote> <blockquote> <blockquote> <blockquote> <p align="center"><font color="#0000FF"><b>Sex: </b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; Female:<INPUT TYPE="radio" NAME="radio1" VALUE="female">Male: <INPUT TYPE="radio" NAME="radio1" VALUE="male" CHECKED> </font></p> </blockquote> </blockquote> </blockquote> </blockquote> <p align="center"><font color="#0000FF">Date of Birth: <select size="1" name="D"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">10</option> TRRCE PAGE NO: M.TECH (CSE)
  • 54. NAME: ROLL NO: <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> </select>&nbsp; <select size="1" name="M"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select>&nbsp; <select size="1" name="Y"> <option value="1980">1980</option> <option value="1981">1981</option> <option value="1982">1982</option> <option value="1983">1983</option> <option value="1984">1984</option> <option value="1985">1985</option> <option value="1986">1986</option> <option value="1987">1987</option> <option value="1988">1988</option> <option value="1990">1989</option> <option value="1991">1990</option> <option value="1992">1991</option> </select></font></p> <p align="center"><font color="#0000FF">Languages known:&nbsp;&nbsp; English <input type="checkbox" name="C1" value="English">&nbsp; Telugu TRRCE PAGE NO: M.TECH (CSE)
  • 55. NAME: ROLL NO: <input type="checkbox" name="C1" value="telugu">&nbsp; Hindi<input type="checkbox" name="C1" value="hindi">&nbsp;&nbsp; Tamil<input type="checkbox" name="C1" value="tamil"></font></p> <p align="center"><font color="#0000FF">Adress: <textarea rows="2" name="S1" cols="20"></textarea></font></p> <p align="center"><font color="#0000FF"><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></font></p> </form> </body> </html> <body> <br> </body> </html> Output: TRRCE PAGE NO: M.TECH (CSE)
  • 56. NAME: ROLL NO: View.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; TRRCE PAGE NO: M.TECH (CSE)
  • 57. NAME: ROLL NO: import java.sql.*; public class view extends HttpServlet{ public void service (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setContentType("text/html"); PrintWriter out = res.getWriter(); try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:srilathadata", "scott", "tiger"); Statement st = connection.createStatement(); out.println("<html><center><h2>TABLE NAMES LIST</h2><table border=1>"); int i=0; DatabaseMetaData meta = connection.getMetaData(); ResultSet rs = meta.getTables(null, null, null, new String[]{"TABLE"}); out.println("<tr><th>S.NO</th><th>Names of Table</th></tr>"); while (rs.next()) { i++; String tableName = rs.getString("TABLE_NAME"); out.println("<tr><td>"+i+"</td><td>"+tableName+"</td></tr>"); } out.println("</table></center></html>"); }catch(Exception e){ out.println(e.getMessage());//Print trapped error. } } } View.html <html> <head> <CENTER> <h2> TO VIEW THE DATA OR DESCRIPTION OF THE TABLE<br/><br/> </h2> <script language="JavaScript"> function test() { for (var i=0; i < document.f1.r1.length; i++) { if (document.f1.r1[i].checked) { TRRCE PAGE NO: M.TECH (CSE)
  • 58. NAME: ROLL NO: var viewvalue = document.f1.r1[i].value; if(viewvalue=="table") { alert("for table list"); location.href("http://localhost:2010/sriludata/servlet/view"); } else { if(viewvalue=="desc") { alert("for desc"); document.write("<html><body><center><br><br><form method=post action=http://localhost:2010/sriludata/servlet/view1><input type=hidden name=hv value=desc><b>Enter the Table Name:</b><input type=text name=t1><br><br><input type=submit value=Enter></form></center></body></html>"); } else { alert("for data"); document.write("<html><body><center><br><br><form method=post action=http://localhost:2010/sriludata/servlet/view2><input type=hidden name=h1 value=data><b>Enter the Table Name:</b><input type=text name=t1><br><br><input type=submit value=Enter></form></center></body></html>"); } } } } } </script> </head> <BODY> <FORM name=f1 > To VIEW: &nbsp;&nbsp;&nbsp;&nbsp; Tables List:<input type=radio name="r1" value="table" > Data<INPUT TYPE=RADIO NAME=r1 VALUE="data">&nbsp;&nbsp;Description<INPUT TYPE=RADIO NAME=r1 VALUE="desc"/><br/><br/> <br/><input type=button value=click name=b1 onClick=test()> </CENTER> </FORM> </BODY> TRRCE PAGE NO: M.TECH (CSE)
  • 59. NAME: ROLL NO: Output: Homepage <html> <head> <h2> <CENTER>DATABASE OPERATION WITH JSP<br/><br/><br/> </h2> </head> <body> <A HREF=http://localhost:8888/swapnadbjsp/create.jsp>CREATE TABLE</A><BR><BR> <A HREF=http://localhost:8888/swapnadbjsp/insert.jsp>Instert Data</A><BR/><BR> <A HREF=http://localhost:8888/swapnadbjsp/update.jsp>Update Data<a/><br><BR> <A HREF=http://localhost:8888/swapnadbjsp/delete.jsp>Delete</A><BR/><BR> <A HREF=http://localhost:8888/swapnadbjsp/viewdata.jsp>View</A> </CENTER> </body> </html> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 60. NAME: ROLL NO: Create table <%@ page import="java.sql.*" %> <HTML> <HEAD> <TITLE>Creating a Table</TITLE> TRRCE PAGE NO: M.TECH (CSE)
  • 61. NAME: ROLL NO: </HEAD> <center> <BODY bgcolor=gree> <H1>Creating a Table</H1> <% try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott", "tiger"); Statement statement = connection.createStatement(); String command = "CREATE TABLE StaffList (ID INTEGER, Name CHAR(50), Deptname varchar2(50), Designation varchar(30));"; statement.executeUpdate(command); out.println("<b>Table is created successfully"); } catch (Exception e) { out.println("An error occurred."); } %> </center> </BODY> </HTML> Output: Insert: <%@ page import="java.sql.*" %> <HTML> <HEAD> <TITLE>Insert Data Into a Table</TITLE> TRRCE PAGE NO: M.TECH (CSE)
  • 62. NAME: ROLL NO: </HEAD> <BODY bgcolor=brown> <H1>Insert Data Into a Table</H1> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott", "tiger"); Statement statement = connection.createStatement(); String command = "INSERT INTO StaffList (ID, Name, Deptname , Designation ) VALUES (1, 'SM','ECE','Asstprof')"; statement.executeUpdate(command); command = "INSERT INTO StaffList (ID, Name, Deptname , Designation ) VALUES (2, 'MSS','MCA','Asstprof')"; statement.executeUpdate(command); ResultSet resultset = statement.executeQuery("select * from StaffList"); while(resultset.next()){ %> <TABLE BORDER="1"> <TR> <TH>ID</TH> <TH>Name</TH> </TR> <TR> <TD> <%= resultset.getString(1) %> </TD> <TD> <%= resultset.getString(2) %> </TD> </TR> </TABLE> <% } %> </BODY> </HTML> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 63. NAME: ROLL NO: View: <%@ page import="java.sql.*" %> <HTML> <center> <HEAD> <TITLE>The tableName Database Table </TITLE> </HEAD> <BODY bgcolor=cyan> <H1>The List Of Database Table </H1> <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott", "tiger"); Statement statement = connection.createStatement() ; ResultSet resultset = statement.executeQuery("select * from StaffList") ; %> <TABLE BORDER="2"> <TR> TRRCE PAGE NO: M.TECH (CSE)
  • 64. NAME: ROLL NO: <TH>ID</TH> <TH>Name</TH> <TH>Deptname</TH> <TH>Designation</TH> </TR> <% while(resultset.next()){ %> <TR> <TD> <%= resultset.getString(1) %></td> <TD> <%= resultset.getString(2) %></TD> <TD> <%= resultset.getString(3) %></TD> <TD> <%= resultset.getString(4) %></TD> </TR> <% } %> </TABLE> </BODY> </center> </HTML> OUTPUT: Delete: <%@ page language="java" import="java.sql.*" errorPage="" %> TRRCE PAGE NO: M.TECH (CSE)
  • 65. NAME: ROLL NO: <% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection("jdbc:odbc:oracle", "scott", "tiger"); PreparedStatement psDeleteRecord=null; String sqlDeleteRecord=null; try { sqlDeleteRecord="Delete from StaffList where ID=1"; psDeleteRecord=con.prepareStatement(sqlDeleteRecord); psDeleteRecord.executeUpdate(); } catch(Exception e) { response.sendRedirect("<center>deleteRecord.jsp</center>"); //// On error it will send back to addRecord.jsp page } try{ if(psDeleteRecord!=null) { psDeleteRecord.close(); } if(con!=null) { con.close(); } } catch(Exception e) { e.printStackTrace(); } %> <html> <body bgcolor=blac><center> Record is deleted successfully. </center> </body> </html> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 66. NAME: ROLL NO: Update: TRRCE PAGE NO: M.TECH (CSE)
  • 67. NAME: ROLL NO: <%@ page language="java" import="java.sql.*" errorPage="" %> <% try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection connection = DriverManager.getConnection("jdbc:odbc:oracle", "scott", "tiger"); Statement stmt = connection.createStatement(); stmt.executeUpdate("UPDATE StaffList SET ID = 2 "); out.println("<h2><center>Update sucessfully</center><h2>"); } catch (Exception e) { out.println("An error occurred."); } %> <html><center> <body bgcolor=blac><br/> Data is updated successfully. </center> </body> </html> OUTPUT: FirstServelet.java TRRCE PAGE NO: M.TECH (CSE)
  • 68. NAME: ROLL NO: import java.sql.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class FirstServlet extends HttpServlet { /*public void init(ServletConfig config) throws ServletException,IOException { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:sandhya","scott","tiger"); Statement st=con.createStatement(); } catch(Exception e) { System.out.println(e); } }*/ public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { res.setContentType("text/html"); ServletOutputStream sos=res.getOutputStream(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:Sandhya","scott","tiger"); Statement st=con.createStatement(); /*public void create(); TRRCE PAGE NO: M.TECH (CSE)
  • 69. NAME: ROLL NO: public void insert(); public void delete(); public void select(); con.close(); }*/ //public void create()throws ServletException,IOException //{ st.execute("create table table1(no number(10),name varchar2(10),marks number(5))"); sos.println("table created"); /*} public void insert()throws ServletException,IOException {*/ String s1=req.getParameter("t1"); int no=Integer.parseInt(s1); String name=req.getParameter("t2"); String s2=req.getParameter("t3"); int marks=Integer.parseInt(s1); int x=st.executeUpdate("insert into table1 values("+no+","+name+","+marks+")"); sos.println(x+" records inserted"); /*} public void select()throws ServletException,IOException {*/ ResultSet rs=st.executeQuery("select * from table1"); while(rs.next()) { sos.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getInt(3)); } /*} public void delete()throws ServletException,IOException {*/ TRRCE PAGE NO: M.TECH (CSE)
  • 70. NAME: ROLL NO: int i=st.executeUpdate("delete from table1 where no=100"); sos.println(i+"rows deleted"); //} } catch(Exception e) { //sos.println(e); } } } WEB.XML <?Xml version=”1.0”?> <web-app> <servlet> <servlet-name>FirstServlet</servlet-name> <servlet-class>FirstServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>FirstServlet</servlet-name> <url-pattern>/verify</url-pattern> </servlet-mapping> </web-app> FirstServlet.html <html> <head> <title>firstpage</titlle> <head> <body> <form method=get action=http://locahost:8080/database/FirstServlet.class> Student Number<input type=text name="t1"><br> Student Name<input type=text name="t2"><br> TRRCE PAGE NO: M.TECH (CSE)
  • 71. NAME: ROLL NO: Student marks<input type=text name="t3"><br> <input type=submit value="OK"> </form> </body> OUTPUT: Upload and Download: TRRCE PAGE NO: M.TECH (CSE)
  • 72. NAME: ROLL NO: Upload.html <HTML> <HEAD> <TITLE> Upload </TITLE> </HEAD> <BODY> <form action='upload' method='post' enctype="multipart/form-data"> <input type="file" name="abc"><br/> <input type="submit" name="submit" value="Upload"> </form> </BODY> </HTML> TestSer.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import org.apache.commons.fileupload.*; public class TestSer extends HttpServlet { public void service(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException { PrintWriter out=response.getWriter(); try { DiskFileUpload upload = new DiskFileUpload(); File tempdir = new File("d:test"); upload.setSizeMax(-1L); upload.setRepositoryPath(tempdir.getCanonicalPath()); String basename = null; String war = null; FileItem warUpload = null; List items = upload.parseRequest(request); Iterator iter = items.iterator(); TRRCE PAGE NO: M.TECH (CSE)
  • 73. NAME: ROLL NO: do { if(!iter.hasNext()) break; FileItem item = (FileItem)iter.next(); if(!item.isFormField()) if(item.getFieldName().equals("abc") && warUpload == null) warUpload = item; else item.delete(); } while(true); war = warUpload.getName(); /* if(war.lastIndexOf('') >= 0) war = war.substring(war.lastIndexOf('') + 1); if(war.lastIndexOf('/') >= 0) war = war.substring(war.lastIndexOf('/') + 1); */ System.out.println(war); if(war.indexOf('') >= 0) war = war.substring(war.indexOf('') + 1); if(war.indexOf('/') >= 0) war = war.substring(war.indexOf('/') + 1); System.out.println(war); String war1=""; if(war.lastIndexOf('') >= 0) war1 = war.substring(0,war.lastIndexOf('') + 1); if(war.lastIndexOf('/') >= 0) war1 = war.substring(0,war.lastIndexOf('/') + 1); File appBaseDir = new File("d:testappbasedir"); File file1 = new File(appBaseDir,war1); file1.mkdirs(); File file = new File(appBaseDir,war); warUpload.write(file); } catch (Exception e) { e.printStackTrace(); TRRCE PAGE NO: M.TECH (CSE)
  • 74. NAME: ROLL NO: } out.println("<center>Your File has Been Uploaded Successfully<br><br><br>"); out.println("<a href='Test.html'>Upload Another File</a><br><br><br>"); out.println("<a href='Home.html'>Home</a></center>"); } } WEB.XML <?xml version="1.0" encoding="ISO-8859-1"?> <web-app> <display-name>Welcome to Tomcat</display-name> <description> Welcome to Tomcat </description> <servlet> <servlet-name>TestSer</servlet-name> <servlet-class>TestSer</servlet-class> </servlet> <servlet-mapping> <servlet-name>TestSer</servlet-name> <url-pattern>/upload</url-pattern> </servlet-mapping> </web-app> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 75. NAME: ROLL NO: Download.html <html> <head> <title> Download Document </title> </head> <body bgcolor="cyan"> <center> <font color="red"><strong>Click on download dept to download dept database to any drive in this system</strong></font><br> <a href="./download"><i><u>download dept data</u></i></a> </center> </body> </html> DownloadServlet.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; TRRCE PAGE NO: M.TECH (CSE)
  • 76. NAME: ROLL NO: public class DownloadServlet extends HttpServlet {Connection con; Statement st; ResultSet rs; File ff; FileWriter f; FileOutputStream fos; ObjectOutputStream oos; public void init() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:Odbc:appu","system","appu"); st=con.createStatement(); ff=new File("c:downloadsemp.txt"); fos= new FileOutputStream(ff); oos=new ObjectOutputStream(fos); } catch (Exception e) { e.printStackTrace(); } } public void destroy() { try { if(con!=null) con.close(); if(st!=null) st.close(); if(rs!=null) rs.close(); f.close(); TRRCE PAGE NO: M.TECH (CSE)
  • 77. NAME: ROLL NO: fos.close(); } catch (SQLException s) { s.printStackTrace(); } catch(Exception e) { e.printStackTrace(); } } public void doGet(HttpServletRequest rq,HttpServletResponse rp)throws ServletException,IOException { try { rs=st.executeQuery("select * from dept"); while(rs.next()) { oos.writeObject(rs.getInt(1)+" "); oos.writeObject(rs.getString(2)+" "); oos.writeObject(rs.getString(3)+" "); oos.writeObject("/n"); } rp.setContentType("text/html"); PrintWriter pw=rp.getWriter(); pw.println("<html><body bgcolor=wheat><center><strong>Dept data downloaded succesfully</strong></center></body></html>"); pw.close(); } catch(Exception e) { e.printStackTrace(); } } } web.xml <web-app> TRRCE PAGE NO: M.TECH (CSE)
  • 78. NAME: ROLL NO: <servlet> <servlet-name>download</servlet-name> <servlet-class>DownloadServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>download</servlet-name> <url-pattern>/download</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>download.html</welcome-file> </welcome-file-list> </web-app> OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 79. NAME: ROLL NO: Currency Converter indian.java package currency; import java.beans.*; import java.awt.*; import java.awt.event.*; public class Indian extends Canvas { private double rupees; private String other; public Indian() { setSize(200,25); other="America"; } public void setRupees(double amount) { rupees=amount; TRRCE PAGE NO: M.TECH (CSE)
  • 80. NAME: ROLL NO: repaint(); } public double getRupees() { return rupees; } public void setOther(String other) { this.other=other; repaint(); } public String getOther() { return other; } public void paint(Graphics g) { if(other.equals("America")) { g.drawString(String.valueOf(rupees/42),20,20); } else if(other.equals("Australia")) { g.drawString(String.valueOf(rupees/27),20,20); } else if(other.equals("Canada")) { g.drawString(String.valueOf(rupees/35),20,20); } else g.drawString("I Can't convert for such country",20,20); } } OUTPUT: Initially the beans window will be, TRRCE PAGE NO: M.TECH (CSE)
  • 81. NAME: ROLL NO: India 550 rs converted into US dollorand shown in Beanbox window like 13..095 COUNTLABEL Countlabel.java import java.beans.*; import java.io.*; import java.awt.*; import java.awt.event.*; public class CountLabel extends Panel implements MouseListener { Label lb; int count; public CountLabel() { setSize(100,100); lb=new Label(String.valueOf(count)); add(lb); lb.addMouseListener(this); addMouseListener(this); } TRRCE PAGE NO: M.TECH (CSE)
  • 82. NAME: ROLL NO: public void mouseClicked(MouseEvent e) { count++; lb.setText(String.valueOf(count)); } public void mousePressed(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseReleased(MouseEvent e){} } OUTPUT: TRRCE PAGE NO: M.TECH (CSE)
  • 83. NAME: ROLL NO: CALCULATOR NewC.java package sunw.demo.NewC; import java.awt.Panel; TRRCE PAGE NO: M.TECH (CSE)
  • 84. NAME: ROLL NO: import java.awt.event.*; import java.io.PrintStream; import java.io.Serializable; import javax.swing.JTextField; public class NewC extends Panel { private int op1=0; private int op2=0; int result; boolean op1flag=true; boolean op2flag=false; boolean start=true; private JTextField tx; String operation="="; public NewC() { tx = new JTextField(12); tx.setHorizontalAlignment(4); tx.setText("0"); tx.setEnabled(true); add(tx); } public void zero() { calculation("0"); } public void one() { calculation("1"); } public void two() { calculation("2"); } public void three() { calculation("3"); } public void four() TRRCE PAGE NO: M.TECH (CSE)
  • 85. NAME: ROLL NO: { calculation("4"); } public void five() { calculation("5"); } public void six() { calculation("6"); } public void seven() { calculation("7"); } public void eight() { calculation("8"); } public void nine() { calculation("9"); } public void add() { calculation("+"); } public void sub() { calculation("-"); } public void mul() { calculation("*"); } public void div() { calculation("/"); } public void equal() { calculation("="); } public void calculation(String s) { if(s.matches("d")) { if(start) { tx.setText(s); } else { tx.setText(tx.getText()+s); } if(op1flag) { op1=Integer.parseInt(tx.getText()); TRRCE PAGE NO: M.TECH (CSE)
  • 86. NAME: ROLL NO: result=op1; } if(op2flag) { op2=Integer.parseInt(tx.getText()); } } else if(s.equals("=")) { result=calculate(result,op2,operation); tx.setText(String.valueOf(result)); op1flag=true; op2flag=false; start=true; } if(s.equals("/")) { operation="/"; setFlags(); } if(s.equals("*")) { operation="*"; setFlags(); } if(s.equals("-")) { operation="-"; setFlags(); } if(s.equals("+")) { TRRCE PAGE NO: M.TECH (CSE)
  • 87. NAME: ROLL NO: operation="+"; setFlags(); } if(s=="Clear") { tx.setText("0"); op1=0; op2=0; op1flag=true; op2flag=false; start=true; } } public void setFlags() { op1flag=false; op2flag=true; start=true; } public int calculate(int a, int b, String operation) { int result=0; char op=operation.charAt(0); if(op=='/') { result=a/b; } if(op=='*') { result=a*b; } TRRCE PAGE NO: M.TECH (CSE)
  • 88. NAME: ROLL NO: if(op=='-') { result=a-b; } if(op=='+') { result=a+b; } return result; } } OUTPUT: TRAFFIC PERSON TrafficPerson.java package demo; import java.awt.Panel; import java.awt.event.*; TRRCE PAGE NO: M.TECH (CSE)
  • 89. NAME: ROLL NO: 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); } else if(state.equals("Move")) { state="Stopped"; tx.setText(state); } else if(state.equals("Stopped")) { state="Ready"; tx.setText(state); } } public void propertyChange(PropertyChangeEvent e) { change(); } private JTextField tx; private String state; } TRRCE PAGE NO: M.TECH (CSE)
  • 90. NAME: ROLL NO: TrafficLight.java 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() TRRCE PAGE NO: M.TECH (CSE)
  • 91. NAME: ROLL NO: { return (int)((new Date()).getTime() / 1000L); } public void run() { int i = getSeconds(); 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; TRRCE PAGE NO: M.TECH (CSE)
  • 92. NAME: ROLL NO: } OUTPUT: After setting traffic light and changing interval to 10 secs.. TRRCE PAGE NO: M.TECH (CSE)