+ All Categories
Home > Documents > Webtech Lab Manual

Webtech Lab Manual

Date post: 28-Oct-2014
Category:
Upload: abinaya-janani
View: 127 times
Download: 1 times
Share this document with a friend
Popular Tags:
102
SASURIE COLLEGE OF ENGINEERING VIJAYAMANGALAM DEPARTMENT OF INFORMATION TECHNOLOGY LAB MANUAL WEB TECHNOLOGY LAB M.TECH(II SEMESTER) PREPARED BY P.MURUGA PRIYA (LECTURER / IT)
Transcript

SASURIE COLLEGE OF ENGINEERING VIJAYAMANGALAMDEPARTMENT OF INFORMATION TECHNOLOGYLAB MANUAL

WEB TECHNOLOGY LAB M.TECH(II SEMESTER)

PREPARED BY P.MURUGA PRIYA (LECTURER / IT)

CS9228 WEB TECHNOLOGY LABORATORY

S.N o1

TOPICDesigning Web Pages using Client Side Scripting and DHTML.

PAGE NO.

2 3 4 5 6 7 8

Client Server Scripting Programs. Simulation of Email and File Transfer Protocols. Development of Web Services. XML and Databases. Server Side Application Using JSP. Web Customization. Development of E-Business Application.

CS9228 WEB TECHNOLOGY LABORATORY1. Designing Web Pages using Client Side Scripting and DHTML. Aim : To design a Web Page using Client Side Scripting and DHTML. Algorithm : 1.Start the program 2.The form will include text fields called "First Name", last Name,Address etc 3. Validation script will ensure that the user enters their name before the form is sent to the server. 4. Open this page to see it in action. 5. Try pressing the Place Order button without filling anything field will return null order 6. You might like to open the source code for this form in a separate window the page consists of a JavaScript function called validate_form() that performs the form validation, followed by the form itself. Program: function blinking_header() { if (!document.getElementById('blink').style.color) { document.getElementById('blink').style.color="red"; } if (document.getElementById('blink').style.color=="red") { document.getElementById('blink').style.color="black"; } else { document.getElementById('blink').style.color="red"; }

timer=setTimeout("blinking_header()",100); } function stoptimer() { clearTimeout(timer); } Blinking header First Name Last Name Address City

State ZIP would u like to be in ur mailing list Yes Grey Color Our Mid Range Item Super Deluxe Select the Item u want One Two Three Four Select the qty of items to order

Total Due function notify() { alert("Please be aware that mailing list is for internal use"); } function totalorder(form) { var x=form.orderitem.options[form.orderitem.selectedIndex].value; var y=form.Qty.options[form.Qty.selectedIndex].value; var due=x*y; form.total.value=due; }

Ex No: 2. Aim :

CLIENT SERVER SCRIPTING PROGRAMS.

To develop a simple Client Server Scripting Programs in a single web

page.Algorithm:

1.Start the program 2. Create a server variable, MyServerVar, and a client variable, MyClientVar. 3. It prints simple text strings to identify each value. 4.The server code marked with the server script tags, and the client script shown with tags. 5.Stop the program. Program : Server Scripting Program : Sample Script Evaluation This value was evaluated on the server " "

Client scripting program : Sample Script Evaluation This value was evaluated on the server 6

Output :

Ex No.3.

Simulation of Email and File Transfer Protocols.

AIM:

To write a C program for transferring a file using TCP.

ALGORITHM:SERVER: Step 1:Start the program. Step 2:Create an unnamed socket for the server using parameters AF_INET as domain and SOCK_STREAM as type. Step 3:Get the server port number. Step 4:Register the host address to the system by using bind() system call in server side. Step 5:Create a connection queue and wait for clients using listen() system call with the number of clients requests as parameter. Step 6:Create a Child process using fork( ) system call. Step 7:If the process identification number is equal to zero accept the connection using accept( ) system call when the client request for connection. Step 8:If pid is not equal to zero then exit the process. Step 9:Stop the Program execution. CLIENT: Step 1:Start the program. Step 2:Create an unnamed socket for the client using parameters AF_INET as domain and SOCK_STREAM as type. Step 3:Get the client port number. Step 4:Now connect the socket to server using connect( ) system call. Step 5:Enter the file name. Step 6:The file is transferred from client to server using send ( ) function. Step 7:Print the contents of the file in a new file. Step 8:Stop the program.

SERVER

#include #include #include #include main() { FILE *fp; int sd,newsd,ser,n,a,cli,pid,bd,port,clilen; char name[100],fileread[100],fname[100],ch,file[100],rcv[100]; struct sockaddr_in servaddr,cliaddr; printf("Enter the port address: "); scanf("%d",&port); sd=socket(AF_INET,SOCK_STREAM,0); if(sd Register.HTML registration Enter Id :
Enter Name :
Enter Age :
Enter Branch:
Enter Mark1 :
Enter Mark2 :

Enter Mark3 :
Enter Grade :
Click : Insert.Html registration Enter Id :
Enter Name :
Enter Age :
Enter Branch:
Enter Mark1 :
Enter Mark2 :
Enter Mark3 :
Enter Grade :
Delete.Html DELETE STUDENT RECORD Enter the ID :
Click : Second.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import java.lang.*; public class second extends HttpServlet {

public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException { loginform(res,false); }//goGet() private void loginform(HttpServletResponse res,boolean error)throws ServletException,IOException { res.setContentType("text/html"); PrintWriter pr=res.getWriter(); pr.println(""); pr.println(""); if(error) { pr.println("LOGIN FAILED, PLEASE TRY AGAIN!!!"); } pr.println(""); pr.println(" please enter your name and password"); pr.println("Username: "); pr.println("Password:
"); pr.println("Press:"); pr.println("clear:"); pr.println(""); }//loginform() public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException { String name=req.getParameter("username"); String pass=req.getParameter("password"); if(logindb(name,pass)) { RequestDispatcher rd=req.getRequestDispatcher("/main.html"); rd.forward(req,res); } else { loginform(res,true); } }//doPost() boolean logindb(String name, String pass)

{ try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:logindb"); Statement s=con.createStatement(); String sql="select * from stu where username= '" + name + "' AND password= '" + pass + "' "; ResultSet rs=s.executeQuery(sql); if(rs.next()) { return true; } con.close(); } catch(SQLException s) { s.printStackTrace(); } catch(Exception e) { e.printStackTrace(); } return false; }//login() }; Register1.java /* INSERTING THE DATA */ import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; public class register1 extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException { try { res.setContentType("Text/html"); PrintWriter pr=res.getWriter(); int id=Integer.parseInt(req.getParameter("id")); String name=req.getParameter("name");

int age=Integer.parseInt(req.getParameter("age")); String branch=req.getParameter("branch"); int m1=Integer.parseInt(req.getParameter("m1")); int m2=Integer.parseInt(req.getParameter("m2")); int m3=Integer.parseInt(req.getParameter("m3")); String grade=req.getParameter("grade"); pr.println(""); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); //pr.println("student information are successfully registered"); //pr.println("goto main page"); PreparedStatement pst=con.prepareStatement("Insert into studata values(?,?,?,?,?,?,?,?) "); pst.setInt(1,id); pst.setString(2,name); pst.setInt(3,age); pst.setString(4,branch); pst.setInt(5,m1); pst.setInt(6,m2); pst.setInt(7,m3); pst.setString(8,grade); pst.executeQuery(); pr.println("student information are successfully registered"); pr.println("goto main page"); pr.println(""); con.commit(); } catch(SQLException e) { System.out.println(e.getMessage()); } catch(Exception e) { e.printStackTrace(); } } }; Insert.java import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*;

import java.lang.*; public class register extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException { try { res.setContentType("Text/html"); PrintWriter pr=res.getWriter(); int id=Integer.parseInt(req.getParameter("id")); String name=req.getParameter("name"); int age=Integer.parseInt(req.getParameter("age")); String branch=req.getParameter("branch"); int m1=Integer.parseInt(req.getParameter("m1")); int m2=Integer.parseInt(req.getParameter("m2")); int m3=Integer.parseInt(req.getParameter("m3")); String grade=req.getParameter("grade"); pr.println(""); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); // pr.println("Get connection"); PreparedStatement pst=con.prepareStatement("Insert into studata values(?,?,?,?,?,?,?,?) "); pst.setInt(1,id); pst.setString(2,name); pst.setInt(3,age); pst.setString(4,branch); pst.setInt(5,m1); pst.setInt(6,m2); pst.setInt(7,m3); pst.setString(8,grade); pst.executeQuery(); con.commit(); pr.println("student information are successfully registered"); pr.println("goto main page"); pr.println(""); con.close(); } catch(SQLException e) { System.out.println(e.getMessage()); } catch(Exception e)

{ e.printStackTrace(); } } }; Find3.Java /* SEARCH THE PARTICULAR RECORD */ import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; public class find3 extends HttpServlet { public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException { res.setContentType("Text/html"); PrintWriter pr=res.getWriter(); pr.println(""); pr.println(""); pr.println("Enter the student ID:"); pr.println("click:"); pr.println(""); } public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException { try { res.setContentType("Text/html"); PrintWriter pr=res.getWriter(); String id =req.getParameter("id"); int idno=Integer.parseInt(id); pr.println(""); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); //PreparedStatement pst=con.prepareStatement("select * from studata where ID= '" + idno + "' "); PreparedStatement pst=con.prepareStatement("select * from studata where

ID= ? "); pst.setInt(1,idno); ResultSet r=pst.executeQuery(); while(r.next()) { pr.println(r.getInt(1)+"\t"+r.getString(2)+"\t"+r.getInt(3)+"\t"+r.getSt ring(4)+"\t"+r.getInt(5)+"\t"+r.getInt(6)+"\t"+r.getInt(7)+"\t"+r.getString(8) ); pr.println("
"); } pr.println("goto main page"); pr.println(""); } catch(SQLException e) { System.out.println(e.getMessage()); } catch(Exception e) { e.printStackTrace(); } } }; Delete2.java import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.sql.*; import java.lang.*; public class delete2 extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res)throws ServletException, IOException { try { res.setContentType("Text/html"); PrintWriter pr=res.getWriter(); pr.println(""); String idno=req.getParameter("idno"); int id=Integer.parseInt(idno); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:ss"); pr.println("get connected");

//PreparedStatement pst=con.prepareStatement("Delete from studata where ID= '" + id + "' "); PreparedStatement pst=con.prepareStatement("Delete from studata where ID= ? "); pst.setInt(1,id); pst.executeUpdate(); pr.println("student record is successfully deleted"); pr.println("goto main page"); pr.println(""); con.commit(); } catch(SQLException e) { System.out.println(e.getMessage()); } catch(Exception e) { e.printStackTrace(); } } }; Output: Studenttable.

RESULT : Thus student information java script program is successfully completed.

7. WEB CUSTOMISATION

CREATION OF WEB APPLICATION USING PHP AIM: To create a calculator web appliction using php. ALGORITHM : Step1 : Start the program Step2 : Create a php web page calc.php Step3: Using form and input type tag create various buttons, textbox, radio button etc. Step4: calcute the output for various option Step5: using post method display the result in next page. Step6: Stop the program. Coding: Calc.php: Calculator All field are required, however, if you forget any, we will put a random number in for you.
Calculator All field are required, however, if you forget any, we will put a random number in for you.
Web and Crafts EBookBiz Demo




We are an online store selling IT and Computer related books. We serve student community and offer special discounts to students.

Contact Us for more details EBookBiz
Tirupur
Phone : 0421 4255202
email : [email protected]


Register today to Shop for Books!


Order.php

EBookBiz Demo

Selected Books

S.No

Book Title Price (Rs) Total Amount (Rs)

DEPARTMENT.PHP

EBookBiz Demo





EBookBiz Demo





Rs.

Header.php

E-BOOK-BIZ Home| Login| Department| Feedback

Index.php EBookBiz Demo




Information Technology and Computer Science Books.


Low Price editions at discount to students of UG and PG courses.


Register today to Shop for Books!


EBookBiz Demo





EBookBiz Demo function validate() { alert("ssssssssssssss");

var frm = document.forms['regform']; if(document.regform.fName.value == '') { alert("Please enter your Name)"; return false; } if(frm.fEmail.value == '') { alert("Please enter your Email"); return false; } if(frm.fLoginId.value == '') { alert("Please enter your Login Id"); return false; } if(frm.fPassword.value == '') {

alert("Please enter your Password"); return false; } }






Recommended