wt record programs

Upload: pavan-kumar-challa

Post on 05-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 WT Record Programs

    1/76

    1

    Design the static web pages for online book store website.

    1) HOME PAGE must contain 3 frames.Top Frame: logo n collge name and links to home, login, registration and cart page.

    Left Frame: Four links of navigation to display respective catalogues.Right Frame: the pages to links in left frame must be loaded here. Initially it should contain description page.

    Untitled Documentbody,td,th {

    color: #F00;font-size: 24px;

    }body {background-color: #000;

    }.text {

    color: #FF80FF;}.text {

    color: #F00;}.text {

    font-family: Palatino Linotype, Book Antiqua, Palatino, serif;}.text {

    font-family: Comic Sans MS, cursive;}VIDYA VIKAS INSTITUTE OFTECHOLOGYHOMELOGINREGISTRATIONCATALOGUE

    CART

    Week-1 Web Technologies Date: 19-07-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    2/76

    2

    OUTPUT:

    Week-1 Web Technologies Date: 19-07-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    3/76

    3

    2.LOGIN PAGE:

    Loginbody {

    background-color: #008000;}body,td,th {

    color: #FFF;}LOGIN:PASSWORD:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-1 Web Technologies Date: 19-07-2010

  • 8/2/2019 WT Record Programs

    4/76

    4

    OUTPUT:

    3) CATOLOGUE PAGE:It should contain the details as follows:1. Snap shot of cover page2. Author Name3.Publisher

    4.Price5. Add to cart button

    catalogue

    Book:xml Bible

    Author:Winston

    Publication:Wiely

    $63

    Week-1 Web Technologies Date: 19-07-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    5/76

    5

    Book:AI

    Author:S.Russel

    Publication:Princeton

    hall

    $63

    Book:JAVA2

    Author:S.Watson

    Publication:BPB

    Publications

    $35.5

    Book:HTML in 24 Hours

    Author:Sam Peter

    Publication:Sam

    Publications

    $50

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-1 Web Technologies Date: 19-07-2010

  • 8/2/2019 WT Record Programs

    6/76

    6

    OUTPUT:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-1 Web Technologies Date: 19-07-2010

  • 8/2/2019 WT Record Programs

    7/76

    7

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-2 Web Technologies Date: 26-07-2010

    4) CART PAGE:The cart page contains the details about the books which are added to cart.

    Untitled Documentbody {

    background-color: #8080FF;}body,td,th {

    color: #FF0;}

    Book namePriceQuantityAmountJava 2$35.52$70.5Xml bible

    $40.51$40.5Total amount -$130.5

  • 8/2/2019 WT Record Programs

    8/76

    8

    OUTPUT:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-2 Web Technologies Date: 26-07-2010

  • 8/2/2019 WT Record Programs

    9/76

    9

    5) REGISTRATION PAGE:

    Registration

    body {

    background-color: #34E0DC;}body,td,th {

    color: #FF0080;}Name:Password:

    E-mail ID:

    Phone Number:Gender:

    Male

    FemaleDate Of Bith:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-2 Web Technologies Date: 26-07-2010

  • 8/2/2019 WT Record Programs

    10/76

    10

    DD123

    456789101112131415161718192021222324252627282930

    31MMjanfebmaraprmayjunjulaugsep

    octnovdec

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-2 Web Technologies Date:26-07-2010

  • 8/2/2019 WT Record Programs

    11/76

    11

    YYYY19751976197719781979 198019811982 19831984 19851986198719881989

    19901991 199219931994 19951996 199719981999200020012002

    2003 200420052006 20072008 20092010Languages Known:

    EnglishTeluguHindi

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-2 Web Technologies Date:26-07-2010

  • 8/2/2019 WT Record Programs

    12/76

    12

    Tamil

    Address:

    OUTPUT:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-2 Web Technologies Date:26-07-2010

  • 8/2/2019 WT Record Programs

    13/76

    13

    Write a java script to validate the following fields of the above registration page.1. Name (Name should contain alphabets and the length should not be less than 6 characters).2. Password(Password length should not be less than 6 characters).3. E-mail id (should not containany invalid and must follow the standard [email protected]).4. Phone number(phone number should contain 10 digits only).

    function validate(Form){if((Form.name.value=="")&&(Form.name.value.length

  • 8/2/2019 WT Record Programs

    14/76

    14

    Form.phno.focus();return false;}var re=/^\d\d\d\d\d\d\d\d\d\d/;

    if(!re.test(Form.phno.value)){alert("please enter a valid phone number");return false;}alert("true");}

    Name:Password:E-mail ID:

    Phone Number:

    Week-3 Web Technologies Date:02-08-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    15/76

    15

    OUTPUT:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-3 Web Technologies Date:02-08-2010

  • 8/2/2019 WT Record Programs

    16/76

    16

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Design a web page using CSS (Cascading Style Sheets) which includes the following:

    1) Use different font, styles:In the style definition you define how each selector should work (font, color etc.).Then,in the body of your pages, you refer to these selectors to activate the styles.

    /* CSS Document */p{background-color:#FF6CFF;font:"Monotype Corsiva";color:#0000FF;}

    stylesheet

    This is an embedded style sheet

    Developed by cseStudents

    Week-4 Web Technologies Date: 09-08-2010

  • 8/2/2019 WT Record Programs

    17/76

    17

    Output:

    2)Set a background image for both the page and single elements on the page.

    /* CSS Document */body{background-image:url(../../5183.jpg);}p{background-image:url(../../5217.jpg);color:#FFF;text-decoration:underline;}

    Untitled Document

    This is a Style sheet
    A style is simply a set of formatting instructions that can be applied to a piece of text.
    There are three mechanisms by which we can apply styles to our HTML.

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date: 09-08-2010

  • 8/2/2019 WT Record Programs

    18/76

    18

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date:09-08-2010

    OUTPUT:

  • 8/2/2019 WT Record Programs

    19/76

    19

    3) Control the repetition of the image with the background-repeat property.As background-repeat: repeatTiles the image until the entire page is filled, just like an ordinary background image in plain HTML.

    /* CSS Document */body{background-image:url(5631.jpg);background-repeat:repeat;}

    RepeatIndia is a Diversified Country

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date:09-08-2010

  • 8/2/2019 WT Record Programs

    20/76

    20

    OUTPUT

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date:09-08-2010

  • 8/2/2019 WT Record Programs

    21/76

    21

    4) Define styles for links as

    A:linkA:visited

    A:activeA:hover

    /* CSS Document */A:link{text-decoration:none;}A:visited{Background-color:cyan;text-decoration:line-through;}A:active{text-decoration:line-through;font-family:"Monotype Corsiva";font-stretch:ultra-condensed;font-style:italic;}A:hover{font-size:18px;color:#00FF40;text-decoration:underline;}p

    {color:#8000FF;text-align:center;}

    CSS

    Week-4 Web Technologies Date:16-08-2010

  • 8/2/2019 WT Record Programs

    22/76

    22

    This is a link

    Nature

    OUTPUT:

    Week-4 Web Technologies Date:16-08-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    23/76

    23

    5) Work with layers:

    Layers

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date:16-08-2010

  • 8/2/2019 WT Record Programs

    24/76

    24

    OUTPUT

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date:16-08-2010

  • 8/2/2019 WT Record Programs

    25/76

    25

    6) Add a customized cursor:Selector{cursor:value}

    customized cursor.dlink{cursor:default}.clink{cursor:crosshair}.hlink{cursor:help}.mlink{cursor:move}.clink{cursor:click}.slink{cursor:scroll}.wlink{cursor:wait}.nlink{cursor:n-resize}.elink{cursor:e-resize}.plink{cursor:progress}

    default cursor
    crosshair cursor
    help cursor
    move cursor
    click cursor


    scroll cursor
    wait cursor
    n-resize cursor
    e-resize cursor
    progress cursor

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-4 Web Technologies Date: 16-08-2010

  • 8/2/2019 WT Record Programs

    26/76

    26

    OUTPUT:

    Week-4 Web Technologies Date: 16-08-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    27/76

    27

    Write an XML file which will display the Book information which includes the following:1) Title of the book2) Author Name3) ISBN number

    4) Publisher name5) Edition6) Price

    Write a Document Type Definition (DTD) to validate the above XML file.Display the XML file as follows.The contents should be displayed in a table. The header of the table should be in color GREY. And the Author namescolumn should be displayed in one color and should be capitalized and in bold. Use your own colors for remainingcolumns.Use XML schemas XSL and CSS for the above purpose.

    Book.dtd

    .

    Book.xslBook InformationTitle-of-the-bookAuthor-nameISBN-numberPublicationsEditionPrice

    Title-of-the-bookAuthor-nameISBN-numberPublicationsEditionPrice

    Week-5Web Technologies Date: 23-08-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    28/76

    28

    Book.xml

    Html in 24 hrs

    Sam peter81-265-0146-4

    Sam

    2nd

    $40

    Circuit DesignWilson81-7722-151-5Nownos3rd

    $63Electrical engineeringDarren Ashby81-265-0188-xNownos2nd$35.5A civil ActionJonathan Harr81-7722-073-xPine Dealer

    1st$50

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-5 Web Technologies Date: 23-08-2010

  • 8/2/2019 WT Record Programs

    29/76

    29

    OUTPUT

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-5 Web Technologies Date:23-08-2010

  • 8/2/2019 WT Record Programs

    30/76

    30

    Book.cssbook-info{display:block;

    }book{display:block;font-size:14pt;}Title-of-the-book{ display:block;font-family:times new roman;color:"green";font-weight:bold;font-size:25pt;}

    Author-name{ display:block;font-family:coppergatholic bold;color:magenta;font-size:20pt;}Publications,ISBN-number{ display:block;font-family:Monotypeorsiva;color:pink;font-size:15pt;margin-left:10pt;}

    Edition,Price{ display:block;font-family:arial;color:orange;font-size:10pt;margin-left:20pt;

    }

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-5 Web Technologies Date:23-08-2010

  • 8/2/2019 WT Record Programs

    31/76

    31

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-5 Web Technologies Date:23-08-2010

    Book.xsd

    BookInfo.xml

    Html in 24 hrsSam peter81-265-0146-4Sam2nd$40Circuit DesignWilson81-7722-151-5Nownos3rd$63

    Electrical engineeringDarren Ashby

  • 8/2/2019 WT Record Programs

    32/76

    32

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-5 Web Technologies Date:23-08-2010

    81-265-0188-xNownos2nd

    $35.5A civil ActionJonathan Harr81-7722-073-xPine Dealer1st$50

  • 8/2/2019 WT Record Programs

    33/76

    33

    OUTPUT

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-5 Web Technologies Date:23-08-2010

  • 8/2/2019 WT Record Programs

    34/76

    34

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-6 Web Technologies Date:30-08-2010

    Create a simple visual bean with a area filled with a color.The shape of the area depends on the property shape. If it is set to true then the shape of the area is Rectangle and it isCircle, if it is false.The color of the area should be changed dynamically for every mouse click. The color should also be changed if we change

    the color in the property window .

    packagemypack;importjava.awt.*;importjava.awt.event.*;importjava.io.serializable;public class Colors extends Canvas implements Serializable{transient private Color color;publicboolean rectangular;public Colors(){addMouseListener(new MouseAdapter(){public void mousePressed(MouseEvent me){change();}});rectangular=true;setSize(300,300);change();}publicbooleangetRectangular(){return rectangular;}

    public void setRectangular(boolean flag){this.rectangular=flag;repaint();}public void change(){color=randomColor();repaint();}private Color randomColor(){int r=(int)(255*Math.random());

    int g=(int)(255*Math.random());int b=(int)(255*Math.random());return new Color(r,g,b);}

  • 8/2/2019 WT Record Programs

    35/76

    35

    public void paint(Graphics g){g.setColor(color);if(rectangular){g.fillRect(0,0,300,300);}else{g.fillOval(0,0,300,300);}}}

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-6 Web Technologies Date:30-08-2010

  • 8/2/2019 WT Record Programs

    36/76

    36

    OUTPUT

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-6 Web Technologies Date:30-08-2010

  • 8/2/2019 WT Record Programs

    37/76

    37

    1. Installation of tomcat web server and apache serverWeek-7 Web Technologies Date:13-09-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    38/76

    38

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-7 Web Technologies Date:13-09-2010

  • 8/2/2019 WT Record Programs

    39/76

    39

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-7 Web Technologies Date:13-09-2010

  • 8/2/2019 WT Record Programs

    40/76

    40

    Week-7 Web Technologies Date:13-09-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    41/76

    41

    Week-7 Web Technologies Date:13-09-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    42/76

    42

    Week-7 Web Technologies Date:13-09-2010

    2) Access the above developed static web pages for books web site, using these

    servers by putting the web pages developed in week-1 and week-2 in the document

    root.

    Directory structure

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    43/76

    43

    Assume four users user1,user2,user3 and user4 having the passwords pwd1,pwd2,pwd3 and pwd4 respectively. Write aservelet for doing the following.

    1. Create a Cookie and add these four user ids and passwords to this Cookie.2. Read the user id and passwords entered in the Login form (week1) and authenticate with the values (user id and

    passwords ) available in the cookies.If he is a valid user(i.e., user-name and password match) you should welcome him by name(user-name) else you shoulddisplay You are not an authenticated user .

    LOGIN.HTM:

    login

    name:password:

  • 8/2/2019 WT Record Programs

    44/76

    44

    USERNAMES.HTMl:

    enter users name and passwordsName:Password:Name:

    Password:Name:Password:Name:Password:

    WELCOME.HTMl:

    Welcome to our website

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date: 20-09-2010

  • 8/2/2019 WT Record Programs

    45/76

    45

    ATHENTICATEUSER.JAVA:

    importjavax.servlet.*;importjavax.servlet.http.*;

    import java.io.*;public class AuthenticateUser extends HttpServlet{public void doGet(HttpServletRequestreq,HttpServletResponse res)throws ServletException,IOException{int i=0;int k=0;String name=req.getParameter("uname");String pass=req.getParameter("upass");Cookie a[]=req.getCookies();PrintWriter out=res.getWriter();boolean flag=false;for(i=0;i

  • 8/2/2019 WT Record Programs

    46/76

    46

    Cookie.java:

    importjavax.servlet.*;importjavax.servlet.http.*;import java.io.*;

    public class CookieProgram extends HttpServlet{public void doGet(HttpServletRequestreq,HttpServletResponse res)throws ServletException,IOException{String name1=req.getParameter("uname1");String pass1=req.getParameter("pass1");Cookie a=new Cookie("u1",name1);Cookie b=new Cookie("p1",pass1);res.addCookie(a);res.addCookie(b);

    System.out.println("Cookie is added");String name2=req.getParameter("uname2");String pass2=req.getParameter("pass2");

    Cookie c=new Cookie("u2",name2);Cookie d=new Cookie("p2",pass2);res.addCookie(c);res.addCookie(d);System.out.println("cookie is added");

    String name3=req.getParameter("uname3");String pass3=req.getParameter("pass3");Cookie e=new Cookie("u3",name3);Cookie f=new Cookie("p3",pass3);res.addCookie(e);res.addCookie(f);System.out.println("cookie is added");String name4=req.getParameter("uname4");

    String pass4=req.getParameter("pass4");Cookie g=new Cookie("u4",name4);Cookie h=new Cookie("p4",pass4);res.addCookie(g);res.addCookie(h);System.out.println("cookie is added");res.sendRedirect("http://localhost:4040/cse/login.htm");}}

    }

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date:20-09-2010

  • 8/2/2019 WT Record Programs

    47/76

    47

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date:20-09-2010

    OUTPUT

  • 8/2/2019 WT Record Programs

    48/76

    48

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date:20-09-2010

  • 8/2/2019 WT Record Programs

    49/76

    49

    Week-8 Web Technologies Date:20-09-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    50/76

    50

    Use init-parameters to do this. Store the user-names and passwords in the webinf.xml and access them in the servlet byusing the getInitParameters() method.

    LOGIN.HTML:loginname:password:

    ERROR.HTML:

    login

    user name or the password you entered are wrong please try againname:password:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date: 27-09-2010

  • 8/2/2019 WT Record Programs

    51/76

    51

    password:

    WELCOME.HTM:Welcome to our website

    INITPARA.JAVA

    importjavax.servlet.*;importjavax.servlet.http.*;import java.io.*;importjava.util.*;public class InitPara extends HttpServlet{public void doGet(HttpServletRequestreq,HttpServletResponse res)throws ServletException,IOException{String name=req.getParameter("uname");String pass=req.getParameter("upass");Enumeration e=getInitParameterNames();

    boolean flag=false;while(e.hasMoreElements()){String iname=(String)e.nextElement();if(name.equals(iname)){if(pass.equals(getInitParameter(iname))){flag=true;break;}}}

    if(flag){res.sendRedirect("http://localhost:9090/init/welcome.htm");}else{res.sendRedirect("http://localhost:9090/init/error.htm");}}}}

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date:27-09-2010

  • 8/2/2019 WT Record Programs

    52/76

    52

    WEB.XML:

    InitParametersInitParauser1pass1user2pass2user3pass3

    user4pass4InitParameters/InitParametersInitParameters/InitParameters

    Week-8 Web Technologies Date:27-09-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    53/76

    53

    OUTPUT:

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date:27-09-2010

  • 8/2/2019 WT Record Programs

    54/76

    54

    Week-8 Web Technologies Date:27-09-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    55/76

    55

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-8 Web Technologies Date:27-09-2010

  • 8/2/2019 WT Record Programs

    56/76

    56

    Create a table which should contain at least the following fields: name, password, email-id, phone number(these shoulhold the data from the registration form).Write a java program/servlet/JSP to connect to that database and extract data from the tables and display them. Experimenwith various SQL queries.Insert the details of the users who register with the web site, whenever a new user clicks the submit button in theregistration page .

    1.DATA BASE CONNECTIVITY BY USING STANDALONES

    EX.JAVA:

    importjava.sql.*;public class Ex{public static void main (String s[])throws Exception{

    DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());Connection con=DriverManager.getConnection("jdbc:odbc:dsn","scott","tiger");Statement st=con.createStatement();int i=st.executeUpdate("create table register(name varchar2(7),password varchar2(7),email varchar2(6),phonevarchar(4))");System.out.println("table was created");st.close();con.close();}}

    PREPAREDSTATEMENTTYPE.JAVAimportjava.sql.*;public class PreparedStatementType

    {public static void main(String s[])throws Exception{Class.forName("oracle.jdbc.driver.OracleDriver");

    Connectioncon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:db","scott","tiger);PreparedStatementps=con.prepareStatement("insert into register values(?,?,?,?)");

    ps.setString(1,"abc");ps.setString(2,"abc");ps.setString(3,"def");

    int Count=ps.executeUpdate();System.out.println("104 record has been inserted and count is:"+Count);ps.setString(1,"habeeb");ps.setString(2,"devi");

    ps.setString(3,"jkl");ps.setString(4,"mno");Count=ps.executeUpdate();System.out.println("105 record has been inserted and count is:"+Count);ps.close();con.close();}}

    }

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-9 Web Technologies Date: 04-10-2010

  • 8/2/2019 WT Record Programs

    57/76

    57

    STATEMENTEX.JAVA

    importjava.sql.*;

    public class StatementEx{public static void main(String s[])throws Exception{DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());Connection con=DriverManager.getConnection("jdbc:odbc:dsn","scott","tiger");Statement st=con.createStatement();int i=st.executeUpdate("update register set NAME="klm" where EMAIL="def"");System.out.println("table was created");st.close();con.close();}}

    RESULTSETEX.JAVA:importjava.sql.*;public class ResultSetEx{public static void main(String s[])throws Exception{DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());

    Connection con=DriverManager.getConnection("jdbc:odbc:dsn","scott","tiger");}PreparedStatementps=con.prepareStatement("select * from register where NAME="abc"");ps.setString(1,"abc");ps.setString(2,"abc");

    ps.setString(3,"def");ps.setString(4,"ghi");ResultSetrs=ps.executeQuery();while(rs.next()){System.out.println(rs.getString(1)+""+rs.getString(2)+""+rs.getString(3)+""+rs.getString(4));}rs.close();ps.close();con.close();}

    }

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-9 Web Technologies Date: 04-10-2010

  • 8/2/2019 WT Record Programs

    58/76

    58

    OUTPUT

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-9 Web Technologies Date: 04-10-2010

  • 8/2/2019 WT Record Programs

    59/76

    59

    2.Using servlets create table,update table ,select table .

    CREATEPRGSERimportjava.sql.*;importjavax.servlet.*;importjavax.servlet.http.*;import java.io.*;public class CreatePrgSer extends GenericServlet{Connection con;public void init(ServletConfigsc){try{DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());con=DriverManager.getConnection("jdbc:oracle:thin:@personal-7948a2:1521:oracle9","scott","tiger");

    System.out.println(con);}catch(Exception e){System.out.println("error "+e.getMessage());}}public void service(ServletRequestreq,ServletResponse res)throws IOException,ServletException{try{ResultSetrs;Statement st;

    st=con.createStatement();rs=st.executeQuery(create table student1(name varchar2(20),ambition varchar2(20)native_ofvarchar2(20));PrintWriter out=res.getWriter();out.println("Table was created");}catch(Exception e){System.out.println("ERROR "+e.getMessage());}}public void destroy(){rs.close();st.close();con.close();}

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

    Week-9 Web Technologies Date:04-10-2010

  • 8/2/2019 WT Record Programs

    60/76

    60

    INSERTPRGSER.JAVA

    importjava.sql.*;

    importjavax.servlet.*;importjavax.servlet.http.*;import java.io.*;public class InsertPrgSer extends GenericServlet{Connection con;public void init(ServletConfigsc){try{DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());con=DriverManager.getConnection("jdbc:oracle:thin:@personal-7948a2:1521:oracle9","scott","tiger");System.out.println(con);

    }catch(Exception e){System.out.println("error "+e.getMessage());}}public void service(ServletRequestreq,ServletResponse res)throws IOException,ServletException

    try{ResultSetrs;PreparedStatementpst;pst=con.prepareStatement("insert into student1 values(?,?,?)");pst.setString(1,"a");pst.setString(2,"b");pst.setString(3,"c");int c=pst.executeUpdate();pst.setString(1,"d");pst.setString(2,"e");pst.setString(3,"f");pst.executeUpdate();c++;pst.executeUpdate();c++;pst.setString(1,"g");pst.setString(2,"h");pst.setString(3,"i");

    pst.executeUpdate();c++;pst.setString(1,"j");pst.setString(2,"k");pst.setString(3,"l");

    Week-9 Web Technologies Date:04-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    61/76

    61

    pst.executeUpdate();c++;pst.setString(1,"m");pst.setString(2,"n");

    pst.setString(3,"o);pst.executeUpdate();c++;pst.setString(1,"p");pst.setString(2,"q");pst.setString(3,"r");pst.executeUpdate();c++;PrintWriter out=res.getWriter();out.println(c+" rows are inserted);}catch(Exception e){System.out.println("ERROR "+e.getMessage());

    }}public void destroy(){rs.close();pst.close();con.close();}}

    UpdatePrgSer.java:

    importjava.sql.*;importjavax.servlet.*;importjavax.servlet.http.*;import java.io.*;public class UpdatePrgSer extends GenericServlet{Connection con;public void init(ServletConfigsc){try{DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());con=DriverManager.getConnection("jdbc:oracle:thin:@personal-7948a2:1521:oracle9","scott","tiger");

    System.out.println(con);}catch(Exception e){System.out.println("error "+e.getMessage());}}

    Week-9 Web Technologies Date:04-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A050

  • 8/2/2019 WT Record Programs

    62/76

    62

    public void service(ServletRequestreq,ServletResponse res)throws IOException,ServletException{try{

    ResultSetrs;PreparedStatementpst;pst=con.prepareStatement("update student1 set name=? where ambition=?");pst.setString(1,"a");pst.setString(2,"b");int c=pst.executeUpdate();pst.setString(1,"c");

    pst.setString(2,"d);pst.executeUpdate();c++;pst.setString(1,"e");pst.setString(2,"f");pst.executeUpdate();c++;

    pst.setString(1,"g");pst.setString(2,"h");pst.executeUpdate();c++;pst.setString(1,"i");pst.setString(2,"j");pst.executeUpdate();c++;pst.setString(1,"k");pst.setString(2,"l");pst.executeUpdate();c++;PrintWriter out=res.getWriter();

    out.println(c+" rows are updated");}catch(Exception e){System.out.println("ERROR "+e.getMessage());}}public void destroy(){rs.close();st.close();con.close();}}

    Week-9 Web Technologies Date:04-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    63/76

    63

    Web.xml:

    CreatePrgSerCreatePrgSerInsertPrgSerInsertPrgSerUpdatePrgSerUpdatePrgSer

    CreatePrgSer/cpsInsertPrgSer/ipsUpdatePrgSer/ups

    OUTPUT:

    For CreatePrgSer.java:

    Week-9 Web Technologies Date:04-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A050

  • 8/2/2019 WT Record Programs

    64/76

    64

    OUTPUTS:

    For InsertPrgSer.java

    For UpdatePrgSer.java

    Week-9 Web Technologies Date:04-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A050

  • 8/2/2019 WT Record Programs

    65/76

    65

    Write a JSP which does the following job:Insert the details of the 3 or 4 users who register with the web site (week9) by usingregistration form. Authenticate the user when he submits the login form using the user

    name and password from the database ( similar to week8 instead of cookies).

    CREATING TABLE : registerQUERY: create table register(name varchar2(20),password varchar2(20));:insert into register values(user,pass1);

    : insert into register values(user2,pass2);: select * from register;

    Week-10 Web Technologies Date:11-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    66/76

    66

    VAL.HTM:

    LoginUserName:Password:

    ERROR.HTM:

    Login

    Enter password or username are incorrect

    UserName:Password:

    Week-10 Web Technologies Date:11-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    67/76

    67

    VAL.JSP:

  • 8/2/2019 WT Record Programs

    68/76

    68

    Directory structure:

    Week-10 Web Technologies Date:11-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    69/76

    69

    OUTPUT:

    Week-10 Web Technologies Date:11-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    70/76

    70

    Week-10 Web Technologies Date:11-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    71/76

    71

    Create tables in the database which contain the details of items (books in our case like Book name , Price, Quantity,

    Amount )) of each category. Modify your catalogue page (week 2)in such a way that you should connect to the database

    and extract data from the tables and display them in the catalogue page using JDBC.

    TYPE.java

    importjava.sql.*;importjava.lang.*;

    public class Type{public static void main(String s[])throws Exception{DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());Connection con=DriverManager.getConnection("jdbc:odbc:mdsn","scott","tiger");Statement st=con.createStatement();int i=st.executeUpdate("create table book2(BookName char(8),Price number(10),Quantity number(10),Amountnumber(10))");st.executeUpdate("insert into book2 values('JAVA' ,250,2,500 )");st.executeUpdate("insert into book2 values('DBMS' ,350,3,1050 )");st.executeUpdate("insert into book2 values('WT' ,100,3,300 )");ResultSetrs=st.executeQuery("select * from book2");System.out.println("table was created");while(rs.next()){System.out.println(rs.getString(1)+"\t"+rs.getInt(2)+"\t"+rs.getInt(3)+"\t"+rs.getInt(4));}}}

    DISPLAY.JSP

    Week-11 Web Technologies Date:18-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A050

  • 8/2/2019 WT Record Programs

    72/76

    72

    TITLEPRICEQUANTITYAMOUNT

    Week-11 Web Technologies Date:18-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    73/76

    73

    OUTPUT:

    Week-11 Web Technologies Date:18-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    74/76

    74

    Write a Session program to display date and time

    SESSION.JAVA

    import java.io.*;importjava.util.*;importjavax.servlet.*;importjavax.servlet.http.*;public class DateServlet extends HttpServlet{public void doGet(HttpServletRequestrequest,HttpServletResponse response)throws ServletException,IOException{HttpSessionhs=request.getSession(true);response.setContentType("text/html");PrintWriter pw=response.getWriter();pw.print("");Date date=(Date)hs.getAttribute("date");

    if(date!=null){pw.print("Last access:"+date+"
    ");}date=new Date();hs.setAttribute("date",date);pw.println("Current date:"+date);}}

    Web.xml:

    fsDateServletfs/KK

    Week-12 Web Technologies Date:25-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    75/76

    75

    COMPILATION

    Week-12 Web Technologies Date:25-10-2010

    VidyaVikas Institute of Technology Hall Ticket: 07E21A0504

  • 8/2/2019 WT Record Programs

    76/76

    76

    DIRECTORY STRUCTURE:

    OUTPUT:

    Week-12 Web Technologies Date:25-10-2010