IP LAB NEW

  • Upload
    nivitha

  • View
    230

  • Download
    0

Embed Size (px)

Citation preview

  • 7/26/2019 IP LAB NEW

    1/76

    Ex No : 01Designing Web Pages using Client Side Scripting and DHTML

    Date :

    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.

    Source Code:

    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";

    5108 GTEC 1 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    2/76

    }

    else

    {

    document.getElementById('blink').style.color="red";

    }

    timer=setTimeout("blinking_header()",100);

    }

    function stoptimer()

    {

    clearTimeout(timer);

    }

    Blinking header

    First Name

    Last Name

    5108 GTEC 2 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    3/76

    Address

    City

    State

    ZIP

    would u like to be in ur mailing list

    5108 GTEC 3 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    4/76

    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;

    5108 GTEC 4 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    5/76

    form.total.value=due;

    }

    Output:

    Total Order Form:

    5108 GTEC 5 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    6/76

    Result:

    Thus the designing web pages using client side scripting and DHTML has been

    executed and verified successfully.

    Ex No : 02

    Client Server Scripting ProgramsDate :

    Aim:

    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.

    Source Code:

    Server Scripting Program

    Sample Script Evaluation

    5108 GTEC 6 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    7/76

    This value was evaluated on the server " "

    Client scripting program

    Sample Script Evaluation

    This value was evaluated on the server 6

    5108 GTEC 7 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    8/76

    Output:

    Sample Script Evaluation:

    5108 GTEC 8 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    9/76

    Result:

    Thus the Client Server Scripting Programs has been executed and verified successfully

    Ex No : 03Simulation of Email and File Transfer Protocols

    Date :

    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.

    5108 GTEC 9 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    10/76

    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.

    Source Code:

    Simulation of File Transfer ProtocolsServer:

    #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

  • 7/26/2019 IP LAB NEW

    11/76

    a=sizeof(servaddr);

    bd=bind(sd,(struct sockaddr*)&servaddr,a);

    if(bd

  • 7/26/2019 IP LAB NEW

    12/76

    return(0);

    }

    }

    Client:

    #include

    #include

    #include

    main()

    {

    FILE *fp; int csd,n,ser,s,cli,cport,newsd;

    char name[100],rcvmsg[100],rcvg[100],fname[100];

    struct sockaddr_in servaddr;

    printf("Enter the port");scanf("%d",&cport);

    csd=socket(AF_INET,SOCK_STREAM,0);

    if(csd

  • 7/26/2019 IP LAB NEW

    13/76

    send(csd,name,sizeof(name),0);

    while(1)

    {

    s=recv(csd,rcvg,100,0);

    rcvg[s]='\0';

    if(strcmp(rcvg,"error")==0)

    printf("File is not Available...\n");

    if(strcmp(rcvg,"completed")==0)

    {

    printf("file is transferred...\n");

    fclose(fp);

    close(csd);

    break;

    }

    else

    fputs(rcvg,stdout);

    fprintf(fp,"%s",rcvg);

    }

    }

    Output:

    Server Side

    [1me16@localhost ~]$ cc ftpclient.c

    [1me16@localhost ~]$. /a.out

    Enter the port address: 8663

    Socket is Created Binded

    Connected

    Client Side[1me16@localhost ~]$ cc ftpserver.c

    [1me16@localhost ~]$. /a.out

    Socket is Created..

    Connected

    Enter the existing file name: net

    5108 GTEC 13 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    14/76

    Enter the new file name: network

    Welcome to Network Lab

    File is transferred...

    Simulation of Email

    #include

    #include

    #define cknull(x) if((x)==NULL) {perror(""); exit(EXIT_FAILURE);}

    #define cknltz(x) if((x)0x0;i++)

    {

    cknull(strcpy(tmp, email_list[i]));

    cknltz(sprintf (fpBuffer,"mail -s '%s %s' %s < %s", "Please Review:", filename,tmp,filename));

    if(system (fpBuffer)==(-1))

    {

    perror("email failure");

    exit(EXIT_FAILURE);

    5108 GTEC 14 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    15/76

    }

    }

    }

    Output:

    [1me2@localhost ~]$ vi email.c

    [1me2@localhost ~]$ cc email.c

    [1me2@localhost ~]$ /a.out

    Enter the file name: sample.c

    [1me2@localhost ~]$/home/1me1/dead.letter.saved message in

    /home/1me1/dead.letter..

    5108 GTEC 15 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    16/76

    Result:

    Thus the program for developing E-mail and file transfer protocols application has

    been executed and verified successfully .

    Ex No : 04

    Development of Web ServicesDate :

    Aim:

    To develop a web service program for calculating Factorial of a number.

    Algorithm:

    1. Start the program.

    2. Give one parameter name x

    3. Data type as int

    4. Click on ok

    5. This will create the Web Service code with the name as factorial and method name as

    fact1

    6. This will be having the annotation as @Webservice ,@Webmethod and @Webparam

    7. Stop the program

    Source Code:

    package pack1;

    5108 GTEC 16 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    17/76

    import javax.jws.WebMethod;

    import javax.jws.WebParam;

    import javax.jws.WebService;

    @WebService()

    public class factorial

    {

    int fact=1;

    @WebMethod(operationName = "fact1")

    public String fact1(@WebParam(name = "x") int x)

    {

    for (int y=1;y

  • 7/26/2019 IP LAB NEW

    18/76

    }

    Output:

    Web service program for factorial of a number:

    5108 GTEC 18 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    19/76

    Result:

    Thus the Client Server Scripting Programs has been executed and verified successfully.

    Ex No : 05XML and Databases

    Date :

    Aim:

    To Parsing an XML document using DOM and SAX Parsers.

    Algorithm:

    Using Dom:

    Step1: Get a document builder using document builder factory and parse the xml file to

    create a DOM object.

    Step 2: Get a list of employee elements from the DOM .

    Step3: For each employee element get the id, name, age and type.

    Create an employee value object and add it to the list.

    Step4: At the end iterate through the list and print the employees to verify we parsed it

    right.

    Using Sax

    5108 GTEC 19 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    20/76

    Step1: Create a Sax parser and parse the xml

    Step2: In the event handler create the employee object

    Step3 : Print out the data

    Source Code:

    UsingSax:

    employees.xml

    Seagull

    3674

    34

    Robin

    3675

    25

    Crow

    3676

    28

    DomParser Example.java

    a)Gettingadocumentbuilder

    private void parseXmlFile(){

    //get the factory

    DocumentBuilderFactory dbf =

    DocumentBuilderFactory.newInstance();

    try {

    5108 GTEC 20 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    21/76

    //Using factory get an instance of document builder

    DocumentBuilder db = dbf.newDocumentBuilder();

    //parse using builder to get DOM representation of the

    XML file

    dom = db.parse("employees.xml");

    }catch(ParserConfigurationException pce) {

    pce.printStackTrace();

    }catch(SAXException se) {

    se.printStackTrace();

    }catch(IOException ioe) {

    ioe.printStackTrace();

    }

    }

    b)Get a list of employee elements

    Get the rootElement from the DOM object.From the root element get all employee

    elements. Iterate through each employee element to load the data.

    private void parseDocument(){

    //get the root element

    Element docEle = dom.getDocumentElement();

    //get a nodelist of elements

    NodeList nl = docEle.getElementsByTagName("Employee");

    if(nl != null && nl.getLength() > 0) {

    for(int i = 0 ; i < nl.getLength();i++) {

    //get the employee element

    Element el = (Element)nl.item(i);

    //get the Employee object

    Employee e = getEmployee(el);

    //add it to list

    myEmpls.add(e);

    }

    }

    }

    5108 GTEC 21 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    22/76

    c)Reading in data from each employee.

    /**

    * I take an employee element and read the values in, create

    * an Employee object and return it

    */

    private Employee getEmployee(Element empEl) {

    //for each element get text or int values of

    //name ,id, age and name

    String name = getTextValue(empEl,"Name");

    int id = getIntValue(empEl,"Id");

    int age = getIntValue(empEl,"Age");

    String type = empEl.getAttribute("type");

    //Create a new Employee with the value read from the xml nodes

    Employee e = new Employee(name,id,age,type);

    return e;

    }

    /**

    * I take a xml element and the tag name, look for the tag and get

    * the text content

    * i.e for John xml snippet if

    * the Element points to employee node and tagName is 'name' I will

    return John

    */

    private String getTextValue(Element ele, String tagName) {

    String textVal = null;

    NodeList nl = ele.getElementsByTagName(tagName);

    if(nl != null && nl.getLength() > 0) {

    Element el = (Element)nl.item(0);

    textVal = el.getFirstChild().getNodeValue();

    }

    return textVal;

    /**

    * Calls getTextValue and returns a int value

    */

    5108 GTEC 22 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    23/76

    private int getIntValue(Element ele, String tagName) {

    //in production application you would catch the exception

    return Integer.parseInt(getTextValue(ele,tagName));

    }

    d)Iteratingandprinting.

    private void printData(){

    System.out.println("No of Employees '" + myEmpls.size() + "'.");

    Iterator it = myEmpls.iterator(); while(it.hasNext()) {

    System.out.println(it.next().toString());

    }

    }

    UsingSax:

    SAXParserExample.java

    a)Create a Sax Parser and parse the xml

    private void parseDocument() {

    //get a factory

    SAXParserFactory spf = SAXParserFactory.newInstance();

    try {

    //get a new instance of parser

    SAXParser sp = spf.newSAXParser();

    //parse the file and also register this class for call backs

    sp.parse("employees.xml", this); }

    catch(SAXException se) {

    se.printStackTrace(); }

    catch(ParserConfigurationException pce) {

    pce.printStackTrace(); }

    catch (IOException ie){

    5108 GTEC 23 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    24/76

    ie.printStackTrace();

    }

    }

    b)In the event handlers create the Employee object and call the corresponding setter

    methods.

    //Event Handlers

    public void startElement(String uri, String localName, String qName, Attributes attributes)

    throws SAXException

    {

    //reset tempVal = "";

    if(qName.equalsIgnoreCase("Employee")) {

    //create a new instance of employee

    tempEmp = new Employee();

    tempEmp.setType(attributes.getValue("type"));

    }

    }

    public void characters(char[] ch, int start, int length) throws SAXException

    {

    tempVal = new String(ch,start,length); }

    public void endElement(String uri, String localName, String qName) throws SAXException

    {

    if(qName.equalsIgnoreCase("Employee")) {

    //add it to the list myEmpls.add(tempEmp); }

    else if (qName.equalsIgnoreCase("Name"))

    { tempEmp.setName(tempVal); }

    else if (qName.equalsIgnoreCase("Id")) {

    tempEmp.setId(Integer.parseInt(tempVal));

    }

    }

    c) Iterating and printing.

    private void printData(){

    System.out.println("No of Employees '" + myEmpls.size() + "'.");

    Iterator it = myEmpls.iterator();

    5108 GTEC 24 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    25/76

    while(it.hasNext()) {

    System.out.println(it.next().toString());

    }

    }

    Output:

    Employee Details - Name:Seagull, Type:permanent, Id:3674, Age:34.

    Employee Details - Name:Robin, Type:contract, Id:3675, Age:25.

    Employee Details - Name:Crow, Type:permanent, Id:3676, Age:28.

    Result:

    Thus the Parsing an XML document using DOM and SAX Parsers has been executed

    and verified successfully.

    Ex No : 06Server Side Application Using JSP

    Date :

    Aim:

    To develop the student webpage information using java servlet and JDBC.

    Algorithm:

    Step 1: Start the program

    Step 2:Create main HTML page for student database maintenance

    Step 3: Select option to do the following operation Insertion, search, delete and modify or

    update the student recode

    Source Code:

    Main.Html

    5108 GTEC 25 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    26/76

    Student database maintenance

    REGISTER

    SEARCH

    VIEW ALL

    DELETE

    Register.HTML

    registration

    Enter Id :

    Enter Name :

    Enter Age :

    Enter Branch:

    Enter Mark1 :

    Enter Mark2 :

    Enter Mark3 :

    Enter Grade :

    5108 GTEC 26 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    27/76

    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 :

    5108 GTEC 27 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    28/76

    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(""); }

    5108 GTEC 28 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    29/76

    //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.jav

    /* INSERTING THE DATA */

    import javax.servlet.*;

    import javax.servlet.http.*;

    import java.io.*;

    5108 GTEC 29 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    30/76

    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("");

    5108 GTEC 30 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    31/76

    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");

    5108 GTEC 31 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    32/76

    // 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 {

    5108 GTEC 32 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    33/76

    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) {

    5108 GTEC 33 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    34/76

    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) {

    5108 GTEC 34 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    35/76

    System.out.println(e.getMessage()); }

    catch(Exception e) {

    e.printStackTrace();

    } }

    };

    Output:

    Student table:

    5108 GTEC 35 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    36/76

    5108 GTEC 36 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    37/76

    5108 GTEC 37 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    38/76

    Result:

    Thus student information java script program has been executed and verified successfully .

    5108 GTEC 38 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    39/76

    Ex No : 07Web Customisation

    Date :

    Aim:

    To create a calculator web application 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.

    Source Code:

    Calc.php:

    Calculator

    5108 GTEC 39 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    40/76

    All field are required, however, if you forget any, we will put a random number in for you.


  • 7/26/2019 IP LAB NEW

    41/76

  • 7/26/2019 IP LAB NEW

    42/76

    if (strpbrk($_POST['number'],"-") and strpbrk($_POST['number2'],"0.") and $_POST['opt']

    == "") {

    $errors[] = "You cannot raise a negative number to a decimal, this is impossible.

    Why?";

    $error = true;

    }

    if ($error != false) {

    echo "We found these errors:";

    echo "";

    foreach ($errors as $e) {

    echo "$e";

    }

    echo "";

    } else {

    switch ($_POST['opt']) { case "+": $result = (int)strip_tags($_POST['number']) +

    (int)strip_tags($_POST['number2']);

    echo "The answer to " . (int)strip_tags($_POST['number']) . " $_POST[opt] " .

    (int)strip_tags($_POST['number2']) . " is $result.";

    break;

    case "-";

    $result = (int)strip_tags($_POST['number']) - (int)strip_tags($_POST['number2']);

    echo "The answer to " . (int)strip_tags($_POST['number']) . " $_POST[opt] " .

    (int)strip_tags($_POST['number2']) . " is $result.";

    break;

    case "*";

    $result = (int)strip_tags($_POST['number']) * (int)strip_tags($_POST['number2']); echo "The

    answer to " . (int)strip_tags($_POST['number']) . " $_POST[opt] " . (int)$_POST['number2'] .

    " is $result.";

    break;

    case "/";

    $result = (int)strip_tags($_POST['number']) / (int)strip_tags($_POST['number2']); $a =

    ceil($result);

    echo "
    ";

    echo "";

    5108 GTEC 42 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    43/76

    echo "Rounding";

    echo "$result rounded up is $a";

    echo "
    ";

    $b = floor($result);

    echo "$result rounded down is $b";

    echo "
    ";

    $h = round($result,(int)$_POST['rounding']); echo "$result rounded to $_POST[rounding]

    digits is " . $h;

    break;

    case "2":

    $result = (int)strip_tags($_POST['number']) * (int)strip_tags($_POST['number2']); $a = (int)

    $_POST['number2'] * (int)$_POST['number2'];

    echo "The answer to " . (int)$_POST['number'] . "2 is " . $result;

    echo "
    ";

    echo "The answer to " . (int)$_POST['number2'] . "2 is " . $a;

    break;

    case "sqrt":

    $result = (int)strip_tags(sqrt($_POST['number']));

    $sqrt2 = (int)strip_tags(sqrt($_POST['number2']));

    echo "The square root of " . (int)strip_tags($_POST['number']) . " is " . $result; echo "
    ";

    echo "The square root of " . (int)strip_tags($_POST['number2']) . " is " . $sqrt2; echo "";

    echo "The square root of " . (int)strip_tags($_POST['number']) . " rounded to " .

    strip_tags($_POST[rounding]) . " digits is " . round($result,(int)$_POST['rounding']);

    echo "
    ";

    echo "The square root of " . (int)strip_tags($_POST['number2']) . " rounded to " .

    strip_tags($_POST[rounding]) . " digits is " . round($sqrt2,

    (int)strip_tags($_POST['rounding']));

    break;

    case "":

    $result = (int)strip_tags(pow($_POST['number'],$_POST['number2']));

    $pow2 = (int)strip_tags(pow($_POST['number2'],$_POST['number']));

    echo (int)$_POST['number'] . "" . strip_tags($_POST[number2]) . " is " .

    $result;

    5108 GTEC 43 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    44/76

    echo "
    "; echo (int)$_POST['number2'] . "" . strip_tags($_POST[number]) .

    " is " . $pow2;

    break;

    }

    }

    }

    echo "
    ";

    ?>

    Go Back

    Output:

    calculator web application:

    5108 GTEC 44 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    45/76

    5108 GTEC 45 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    46/76

    5108 GTEC 46 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    47/76

    Result:

    Thus the calculator web application using PHP has been executed and verified

    successfully.

    Ex No : 08Development of E-Business Application

    Date :

    Aim:

    To develop a E-Business application using PHP.

    Algorithm:

    Step1: Start the program

    Step2: Create a PHP web page contact.php

    Step3: Using form and input type tag create various buttons, textbox, radio button etc.Step4: Get the necessary field from the user.

    Step5: Using post method displays the result in next page.

    Step6: Stop the program.

    5108 GTEC 47 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    48/76

    Source Code:

    Contact.php

    Web and

    Crafts

  • 7/26/2019 IP LAB NEW

    49/76

    $error=1;

    }

    if($error!=1) {

    $todayis = date("l, F j, Y, g:i a") ;

    $attn = $subject ;

    $subject = "mail from $email";

    $message = stripcslashes($message);

    $mailmessage = " $todayis [EST] \n Subject: $subject \n Message: $message \n From:

    $name ($email)\n City: $city\n Pin/Zip code: $zip\n PhoneNo: $phonenumber\n ";

    $from ="From: $email \r\n";

    mail("[email protected]" ,$subject, $mailmessage,$from);

    echo "Thank You :";

    echo "$name("; echo "$email )";

    echo "for your interest in our services. We will contact you soon
    ";

    }

    else {

    echo "Use Back and Fill all required fields !!";

    }

    }

    else

    {

    ?>

  • 7/26/2019 IP LAB NEW

    50/76

    Address :

    City :

    < td align="right" valign="center">

    * Phone No :

    * Email :

    *Your Message :

    5108 GTEC 50 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    51/76

    Fields marked * are

    mandatory

    Output:

    5108 GTEC 51 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    52/76

    AboutUs.php:

    5108 GTEC 52 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    53/76

    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!



    5108 GTEC 53 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    54/76

    Order.php:

    EBookBiz Demo

    Selected Books

    5108 GTEC 54 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    55/76



    S.No

    Book Title

    Price (Rs)

    Total Amount (Rs)

    5108 GTEC 55 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    56/76

    DEPARTMENT.PHP:

    EBookBiz Demo

    5108 GTEC 56 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    57/76





  • 7/26/2019 IP LAB NEW

    58/76






    BOOKLIST.PHP:

    EBookBiz Demo

    5108 GTEC 58 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    59/76





    5108 GTEC 59 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    60/76

    Rs.

  • 7/26/2019 IP LAB NEW

    61/76

    $con = mysql_pconnect($db_hostname, $db_username, $db_password);

    mysql_select_db($db_dbname, $con); ?>

    Header.php:

    E-BOOK-BIZ

    Home|

    Login|

    Department|

    Feedback

    Index.php:

    5108 GTEC 61 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    62/76

    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!




    5108 GTEC 62 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    63/76

    EBookBiz Demo

  • 7/26/2019 IP LAB NEW

    64/76

    include_once 'Header.php'; ?>





  • 7/26/2019 IP LAB NEW

    65/76

    New User ? Register






    Logout.php:

    Registration.php:

  • 7/26/2019 IP LAB NEW

    66/76

    session_start();

    include ('Db.php');

    if(!empty($_REQUEST['Submit']))

    {

    //echo 'form submitted for registration...';

    $name = $_POST['fName'];

    $address1 = $_POST['fAddress1'];

    $address2 = $_POST['fAddress2'];

    $city = $_POST['fCity'];

    $state = $_POST['fState'];

    $pincode = $_POST['fPincode'];

    $phone = $_POST['fPhone'];

    $email = $_POST['fEmail'];

    $login_id = $_POST['fLoginId'];

    $password = $_POST['fPassword'];

    $query = "INSERT INTO users ( id, username, address1, address2, city, state, pincode,

    phone, email,login_id, password ) VALUES ( null, '{$name}', '{$address1}', '{$address2}',

    '{$city}','{$state}','{$pincode}','{$phone}','{$email}', '{$login_id}','{$password}' )";

    mysql_query($query, $con);

    $msg = 'Registration successful.';

    header("Location: Login.php?msg=success");

    }

    ?>

    EBookBiz Demo

    function validate()

    {

    alert("ssssssssssssss");

    var frm = document.forms['regform'];

    5108 GTEC 66 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    67/76

    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;

    }

    }





    5108 GTEC 67 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    68/76

  • 7/26/2019 IP LAB NEW

    69/76

    City

    State

    Pincode

    Phone Number

    Email ID *

    Login ID *

    5108 GTEC 69 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    70/76

    Password *






    5108 GTEC 70 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    71/76

    STYLESHEET:

    #wrapper

    {

    margin:auto;

    width: 980px;

    min-height: 600px;

    font-family:Arial, Helvetica, sans-serif;

    font-size:12px;

    color:#333333;

    border-left:#333333 1px solid;

    border-right:#333333 1px solid;

    border-top:#333333 1px solid;

    border-bottom:#333333 1px solid;

    padding: 5px 5px 5px 5px;

    }

    #header {

    width: 980px;

    height: 70px;

    border-bottom:#660000 1px dotted;

    }

    #content {

    width: 980px;

    padding:10px 10px 10px 10px;

    }

    .logoStyle {

    font-family:"Trebuchet MS";

    font-size:24px;

    font-weight:bold;

    color:#660000;

    }

    #navigation {

    padding-top:10px;

    } .navLink

    {

    font-family: Verdana, Arial, Helvetica, sans-serif;

    5108 GTEC 71 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    72/76

    font-size:12px;

    font-weight: bold;

    color:#333300;

    text-decoration:none;

    }

    .navLink:hover {

    font-family: Verdana, Arial, Helvetica, sans-serif;

    font-size:12px;

    font-weight: bold;

    color: #009900;

    text-decoration:underline;

    }

    .font14b {

    font-family:Verdana, Arial, Helvetica, sans-serif;

    font-size:14px;

    font-weight:bold;

    color: #000000;

    }

    .tabBorder {

    border-bottom:#000000 1px solid;

    border-left:#000000 1px solid;

    border-top:#000000 1px solid;

    border-right:#000000 1px solid;

    }

    Output:

    AboutUs.php:

    5108 GTEC 72 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    73/76

    Login.php:

    5108 GTEC 73 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    74/76

    RegistrationFrom.php:

    Department.php:

    5108 GTEC 74 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW

    75/76

  • 7/26/2019 IP LAB NEW

    76/76