0% found this document useful (0 votes)
31 views28 pages

WT Practical File Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views28 pages

WT Practical File Final

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Exp1 Creation of HTML Table

<html>

<head>

<title> html table </title>

</head>

<body>

<table border="1">

<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>

<tr><td>Amit</td><td>Yadav</td><td>85</td></tr>

<tr><td>pradeep</td><td>singh</td><td>80</td></tr>

<tr><td>hemant</td><td>tiwari</td><td>82</td></tr>

<tr><td>vinay</td><td>sharma</td><td>72</td></tr>

</table>

</body>

</html>
Output-

Exp2 Creation of HTML Form

<form action="#">

<table>

<tr>

<td class="tdLabel"><label for="register_name" class="label">Enter name:</label></td>

<td><input type="text" name="name" value="" id="register_name" style="width:160px"/></td>

</tr>

<tr>

<td class="tdLabel"><label for="register_password" class="label">Enter password:</label></td>

<td><input type="password" name="password" id="register_password"style="width:160px"/></td>

</tr>

<tr>
<td class="tdLabel"><label for="register_email" class="label">Enter Email:</label></td>

<td

><input type="email" name="email" value="" id="register_email" style="width:160px"/></td>

</tr>

<tr>

<td class="tdLabel"><label for="register_gender" class="label">Enter Gender:</label></td>

<td>

<input type="radio" name="gender" id="register_gendermale" value="male"/>

<label for="register_gendermale">male</label>

<input type="radio" name="gender" id="register_genderfemale" value="female"/>

<label for="register_genderfemale">female</label>

</td>

</tr>

<tr>

<td class="tdLabel"><label for="register_country" class="label">Select Country:</label></td>

<td><select name="country" id="register_country" style="width:160px">

<option value="india">india</option>

<option value="pakistan">pakistan</option>

<option value="africa">africa</option>

<option value="china">china</option>

<option value="other">other</option>

</select>

</td>

</tr>

<tr>
<td colspan="2"><div align="right"><input type="submit" id="register_0" value="register"/>

</div></td>

</tr>

</table>

</form>

Output
Exp 3 JavaScript example

<html>

<head>

<title>Variables!!!</title>

<script type="text/javascript">

var one = 22;

var two = 3;

var add = one + two;

var minus = one - two;

var multiply = one * two;

var divide = one/two;

document.write("First No: = " + one + "<br />Second No: = " + two + " <br />");

document.write(one + " + " + two + " = " + add + "<br/>");

document.write(one + " - " + two + " = " + minus + "<br/>");

document.write(one + " * " + two + " = " + multiply + "<br/>");

document.write(one + " / " + two + " = " + divide + "<br/>");

</script>

</head>

<body>

</body>

</html>
Output-

Exp 4 JavaScript Login Validation

HTML Code

<html>

<head>

<title>Javascript Login Form Validation</title>

<!-- include css file here-->

<link rel="stylesheet" href="css/style.css"/>

<!-- include javascript file here-->

<script src="js/login.js"></script>
</head>

<body>

<div class="container">

<div class="main">

<h2>Javascript Login Form Validation</h2><hr/>

<form id="form_id" method="post" name="myform">

<label>User Name :</label></br>

<input type="text" name="username" id="username"/></br>

<label>Password :</label></br>

<input type="password" name="password" id="password"/></br>

<input type="button" value="Login" id="submit" onclick="validate()"/>

</form>

<span><b class="note">Note : </b>For this demo use following username and


password. <br/><b class="valid">User Name : Formget<br/>Password : formget#123</b></span>

</div>

</div>

</body>

</html>

Login.js

var attempt = 3; //Variable to count number of attempts


//Below function Executes on click of login button

function validate(){

var username = document.getElementById("username").value;

var password = document.getElementById("password").value;

if ( username == "Formget" && password == "formget#123"){

alert ("Login successfully");

window.location = "success.html"; //redirecting to other page

return false;

else{

attempt --;//Decrementing by one

alert("You have left "+attempt+" attempt;");

//Disabling fields after 3 attempts

if( attempt == 0){

document.getElementById("username").disabled = true;

document.getElementById("password").disabled = true;

document.getElementById("submit").disabled = true;

return false;

}
Output
Write programs using Java script for Web Page to
Exp5

display browsers information.

<html>
<head>
<title>Browser Information</title>
</head>
<body>
<h1>Browser Information</h1>
<hr>
<p>
The <b>navigator</b> object contains the following information
about the browser you are using.
</p>
<ul>
<script LANGUAGE="JavaScript" type="text/javascript">
document.write("<li><b>Code Name:</b> " +
navigator.appCodeName);
document.write("<li><b>App Name:</b> " +
navigator.appName);
document.write("<li><b>App Version:</b> " +
navigator.appVersion);
document.write("<li><b>User Agent:</b> " +
navigator.userAgent);
document.write("<li><b>Language:</b> " +
navigator.language);
document.write("<li><b>Platform:</b> " + navigator.platform);
</script>
</ul>
<hr>
</body>
</html>

Output-

Create an applet which will have a line, an Oval & a


Exp 6

Rectangle

• import java.applet.Applet;
• import java.awt.*;
• public class GraphicsDemo extends Applet{
• public void paint(Graphics g){
• g.setColor(Color.red);
• g.drawString("Welcome",50, 50);
• g.drawLine(20,30,20,300);
• g.drawRect(70,100,30,30);
• g.fillRect(170,100,30,30);
• g.drawOval(70,200,30,30);
• g.setColor(Color.pink);
• g.fillOval(170,200,30,30);
• g.drawArc(90,150,30,30,30,270);
• g.fillArc(270,150,30,30,0,180);
• } }
/*
<applet code="GraphicsDemo.class" width="300"
height="300">
</applet>
*/
Output-

Exp 7 Program- SimpleArray.java

class SimpleArray

public static void main(String args[])

int array[] = new int[9];

for (int count=0;count<9;count++)


{

array[count]=count+1;

for (int count=0;count<9;count++)

System.out.println("array["+count+"] = "+array[count]);

Output-SimpleArray.java
Exp 8 WAP in java for try-catch block.

Program- try-catch

public class MyExceptionHandle {

public static void main(String a[]){

try{

for(int i=5;i>=0;i--){

System.out.println(10/i);

} catch(Exception ex){

System.out.println("Exception Message: "+ex.getMessage());

ex.printStackTrace();

System.out.println("After for loop...");

}}

Output-
Exp 9 WAP in java for create simple Thread using extends keyword.

Program-

//create thread

class MyThread extends Thread {

public void run() {

System.out.println(" this thread is running ... ");

}}

class ThreadEx1 {

public static void main(String [] args ) {

MyThread t = new MyThread();

t.start();

}}

Output-
Exp 10 WAP in java for creating Simple interface.

Program-amimal.java

interface Animal

public void eat();

public void travel();

//MammalInt.java

public class MammalInt implements Animal{

public void eat(){

System.out.println("Mammal eats");

public void travel(){

System.out.println("Mammal travels");
}

public int noOfLegs(){

return 0;

public static void main(String args[]){

MammalInt m = new MammalInt();

m.eat();

m.travel();}}

Output-

Exp 11 WAP in java for multiple inheritances.

Program-

// multiple inheritance in java

interface Printable
{

void print();

interface showable

void show();

class AA implements Printable,showable

public void print()

System.out.println("Hello");

public void show()

System.out.println("welcome");

public static void main(String args[])

AA obj=new AA();

obj.print();

obj.show();
}

Output-

Exp 12 WAP in java for ReadFileUsingBufferedInputStream.

Program-

import java.io.*;

public class ReadFileUsingBufferedInputStream {

public static void main(String[] args) {

File file = new File("C://java.txt");

BufferedInputStream bin = null;

try{

FileInputStream fin = new FileInputStream(file);

bin = new BufferedInputStream(fin);


while( bin.available() > 0 ){

System.out.print((char)bin.read());

}}

catch(FileNotFoundException e)

System.out.println("File not found" + e);

catch(IOException ioe)

System.out.println("Exception while reading the file " + ioe);

Finally{

try{

if(bin != null)

bin.close();

}catch(IOException ioe)

System.out.println("Error while closing the stream : " + ioe);

}}}}
Output-

Exp 13 WAP in java for Socket Programming (MyClient.java & MyServer.java).

Program-

// MyClient.java

import java.io.*;

import java.net.*;

public class MyClient {

public static void main(String[] args) {

try{

Socket s=new Socket("localhost",6666);

DataOutputStream dout=new DataOutputStream(s.getOutputStream());


dout.writeUTF("Hello Server");

dout.flush();

dout.close();

s.close();

}catch(Exception e){System.out.println(e);}

}}

// MyServer.java

import java.io.*;

import java.net.*;

public class MyServer {

public static void main(String[] args){

try{

ServerSocket ss=new ServerSocket(6666);

Socket s=ss.accept();//establishes connection

DataInputStream dis=new DataInputStream(s.getInputStream());

String str=(String)dis.readUTF();

System.out.println("message= "+str);

ss.close();

}catch(Exception e){System.out.println(e);}

}}
Output-

Exp 14 WAP in java for InetAddress class.

Program-

import java.io.*;

import java.net.*;

public class InetDemo{

public static void main(String[] args){

try{

InetAddress ip=InetAddress.getByName("www.fmcarbscollege.in");

System.out.println("Host Name: "+ip.getHostName());

System.out.println("IP Address: "+ip.getHostAddress());

}catch(Exception e){System.out.println(e);}
}}

Output-

Exp 15 Create a package in java

• //save as Simple.java

• package mypack;

• public class Simple{

• public static void main(String args[]){

• System.out.println("Welcome to package");

• }

• }

• javac -d . Simple.java

Exp 16 Example of JDBC

import java.sql.*;
class OracleCon

public static void main(String args[])

try

//step1 load the driver class

Class.forName("oracle.jdbc.driver.OracleDriver");

//step2 create the connection object

Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","hr","hr");

//step3 create the statement object

Statement stmt=con.createStatement();

//step4 execute query

ResultSet rs=stmt.executeQuery("select * from employees");

while(rs.next())

System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "+rs.getString(3));

//step5 close the connection object

con.close();

catch(Exception e)
{

System.out.println(e);

Output-

Exp 17 Display of student detail using XML

<?xml version="1.0" encoding="utf-8"?>


<?xml-stylesheet type="text/xsl" href="student.xsl"?><VTU>
<STUDENT>
<USN>1GD11CS001</USN>
<NAME>Arun Kumar</NAME>
<COLLEGE> College of Engineering</COLLEGE>
<BRANCH>Computer Science and Engineering</BRANCH>
<YEAR>2011</YEAR>
<EMAILID>[email protected]</EMAILID>
</STUDENT>
<STUDENT>
<USN>1GD10ME012</USN>
<NAME>Swaroop J</NAME>
<COLLEGE> College of Engineering</COLLEGE>
<BRANCH>Mechanical Engineering</BRANCH>
<YEAR>2010</YEAR>
<EMAILID>[email protected]</EMAILID>
</STUDENT>
<STUDENT>
<USN>1GD12CS030</USN>
<NAME>Pradeep L</NAME>
<COLLEGE>College of Engineering</COLLEGE>
<BRANCH> Computer Science and Engineering </BRANCH>
<YEAR>2012</YEAR>
<EMAILID>[email protected]</EMAILID>
</STUDENT>
</VTU>

You might also like