Download - IP LAB NEW.pdf

Transcript
  • 7/26/2019 IP LAB NEW.pdf

    1/71

    Ex No : 01

    Designing Web Pages using Client Side Scripting and DHTMLDate :

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

    }

    else

    {

    5108 GTEC 1 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    2/71

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

    }

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

    }

    function stoptimer()

    {clearTimeout(timer);

    }

    Blinking header

    First Name

    Last Name

    Address

    5108 GTEC 2 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    3/71

    City

    State

    ZIP

    would u like to be in ur mailing list

    Yes

    Grey

    Color

    Our Mid Range Item

    5108 GTEC 3 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    4/71

    Super Deluxe

    Select the Item u want

    One

    TwoThree

    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;

    }

    Output:

    Total Order Form:

    5108 GTEC 4 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    5/71

    Result:

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

    executed and verified successfully.

    Ex No : 02Client Server Scripting Programs

    Date :

    Aim:

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

    5108 GTEC 5 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    6/71

    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

    This value was evaluated on the server " "

  • 7/26/2019 IP LAB NEW.pdf

    7/71

    document.write ("

    The server and client value are not equal because our script told the

    client to add 1.

    ");

    }

    //

    --->

    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.pdf

    8/71

    Output:

    Sample Script Evaluation:

    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:

    5108 GTEC 8 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    9/71

    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.

    Source Code:Simulation of File Transfer Protocols

    Server:

    #include

    #include

    #include

    #include

    5108 GTEC 9 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    10/71

    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.pdf

    11/71

    {

    while(fgets(fileread,sizeof(fileread),fp))

    {

    if(send(newsd,fileread,sizeof(fileread),0)

  • 7/26/2019 IP LAB NEW.pdf

    12/71

    servaddr.sin_port=htons(cport);

    if(connect(csd,(struct sockaddr*)&servaddr,sizeof(servaddr))

  • 7/26/2019 IP LAB NEW.pdf

    13/71

    Client Side

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

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

    Socket is Created..

    ConnectedEnter the existing file name: net

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

    5108 GTEC 13 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    14/71

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

    {

    perror("email failure");

    exit(EXIT_FAILURE);

    }

    }}

    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 14 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    15/71

    Result:

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

    been executed and verified successfully .

    Ex No : 04Development of Web Services

    Date :

    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;

    import javax.jws.WebMethod;

    5108 GTEC 15 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    16/71

    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.pdf

    17/71

    Output:

    Web service program for factorial of a number:

    5108 GTEC 17 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    18/71

    Result:

    Thus the Client Server Scripting Programs has been executed and verified

    successfully.

    Ex No : 05

    XML and DatabasesDate :

    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

    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:

    5108 GTEC 18 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    19/71

    employees.xml

    Seagull

    367434

    Robin

    3675

    25

    Crow3676

    28

    DomParser Example.java

    a) Gettingadocumentbuilder

    private void parseXmlFile(){

    //get the factory

    DocumentBuilderFactory dbf =

    DocumentBuilderFactory.newInstance();

    try {

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

    5108 GTEC 19 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    20/71

    }

    }

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

    }

    }

    }

    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

    5108 GTEC 20 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    21/71

    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

    */

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

    }}

    5108 GTEC 21 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    22/71

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

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

    5108 GTEC 22 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    23/71

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

    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 executedand verified successfully.

    Ex No : 06Server Side Application Using JSP

    Date :

    5108 GTEC 23 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    24/71

    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

    Student database maintenance

    REGISTER

    SEARCH

    VIEW ALL

    DELETE

    Register.HTML

    registration

    5108 GTEC 24 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    25/71

    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

    5108 GTEC 25 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    26/71

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

    5108 GTEC 26 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    27/71

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

    /* INSERTING THE DATA */

    import javax.servlet.*;

    5108 GTEC 27 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    28/71

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

    5108 GTEC 28 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    29/71

    }

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

    5108 GTEC 29 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    30/71

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

    5108 GTEC 30 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    31/71

    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.*;

    5108 GTEC 31 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    32/71

    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:

    Student table:

    5108 GTEC 32 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    33/71

    5108 GTEC 33 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    34/71

    5108 GTEC 34 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    35/71

    5108 GTEC 35 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    36/71

    Result:

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

    Ex No : 07 Web Customisation

    5108 GTEC 36 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    37/71

    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

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


  • 7/26/2019 IP LAB NEW.pdf

    38/71

    Number:

    Another number:

    Operator:

  • 7/26/2019 IP LAB NEW.pdf

    39/71

  • 7/26/2019 IP LAB NEW.pdf

    40/71

    }

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

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

    5108 GTEC 40 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    41/71

    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;

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

    " is " . $pow2;

    break;

    }

    }

    }

    echo "
    ";

    ?>

    Go Back

    Output:

    calculator web application:

    5108 GTEC 41 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    42/71

    5108 GTEC 42 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    43/71

    5108 GTEC 43 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    44/71

    Result:

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

    successfully.

    Ex No : 08

    Development of E-Business ApplicationDate :

    5108 GTEC 44 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    45/71

    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.

    Source Code:

    Contact.php

    Web and

    Crafts

  • 7/26/2019 IP LAB NEW.pdf

    46/71

    }

    if(!$email == "" && (!strstr($email,"@") || !strstr($email,".")))

    {

    echo "Use Back - Enter valid e-mail\n";

    $badinput = "Feedback was NOT submitted\n";

    echo $badinput;$error=1;

    }

    if(empty($name) || empty($phonenumber) || empty($email ) || empty($message))

    {

    echo "Use Back - fill in all required fields \n";

    $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.pdf

    47/71

    *Name :

    Address :

    City :

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

    * Phone No :

    * Email :

    *Your Message :

    5108 GTEC 47 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    48/71

    Fields marked * are

    mandatory

    Output:

    5108 GTEC 48 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    49/71

    AboutUs.php:

  • 7/26/2019 IP LAB NEW.pdf

    50/71

    session_start();

    ?>

    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 50 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    51/71

    Order.php:

    EBookBiz Demo

    Selected Books



    S.No

    Book Title

    Price (Rs)

    5108 GTEC 51 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    52/71

    Total Amount (Rs)

    5108 GTEC 52 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    53/71

    DEPARTMENT.PHP:

    EBookBiz Demo





  • 7/26/2019 IP LAB NEW.pdf

    54/71

    Choose the Department

    Select Department

    Computer Science

    IT






    BOOKLIST.PHP:

  • 7/26/2019 IP LAB NEW.pdf

    55/71

    session_start();

    include ('Db.php');

    if(!isset($_SESSION['ses_username']))

    {

    header("Location:Login.php");

    }if(isset($_POST['fPlaceOrder']))

    {

    $_SESSION['orderdetails'] = $_POST; header("Location: Order.php");

    }

    ?>

    EBookBiz Demo





  • 7/26/2019 IP LAB NEW.pdf

    56/71

    Price

    Add to Cart

    Rs.

  • 7/26/2019 IP LAB NEW.pdf

    57/71

    Db.php:

    Header.php:

    E-BOOK-BIZ

    Home|

    Login|

    Department|

    Feedback

  • 7/26/2019 IP LAB NEW.pdf

    58/71

    ?>

    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!




    5108 GTEC 58 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    59/71

    EBookBiz Demo

    5108 GTEC 59 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    60/71





  • 7/26/2019 IP LAB NEW.pdf

    61/71

    New User ? Register






    Logout.php:

    Registration.php:

  • 7/26/2019 IP LAB NEW.pdf

    62/71

    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'];

    if(document.regform.fName.value == '')

    {

    alert("Please enter your Name)";

    return false;

    }

    5108 GTEC 62 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    63/71

    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 63 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    64/71

  • 7/26/2019 IP LAB NEW.pdf

    65/71

    Pincode

    Phone Number

    Email ID *

    Login ID *

    Password *

    5108 GTEC 65 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    66/71






    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;

    5108 GTEC 66 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    67/71

    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;

    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;

    5108 GTEC 67 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    68/71

    border-left:#000000 1px solid;

    border-top:#000000 1px solid;

    border-right:#000000 1px solid;

    }

    Output:

    AboutUs.php:

    Login.php:

    5108 GTEC 68 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    69/71

    RegistrationFrom.php:

    Department.php:

    5108 GTEC 69 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    70/71

    BookList.php:

    Order.php:

    5108 GTEC 70 IT9225 Internet Programming Lab

  • 7/26/2019 IP LAB NEW.pdf

    71/71

    Result:


Top Related