Top Banner

of 41

Wp Lab Manual

Feb 28, 2018

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/25/2019 Wp Lab Manual

    1/41

    7208-HINDUSTHAN INSTITUTE OF TECHNOLOGY

    COIMBATORE-32

    DEPARTMENT OF INFORMATION TECHNOLOGY

    IT6512 & WEB PROGRAMMING LABORATORY LAB MANUAL

    PREPARED BY

    PNITHYA!AP "IT

  • 7/25/2019 Wp Lab Manual

    2/41

    E# N$%01

    D'( %

    A)*%

    Write a html program for Creation of web site with forms, frames, links, tables etc

    P+$,+*%

    H$*('*.

    Home

    F+*(1'*.

    frame H0134H0034446 78 46CH0797:

    F+*(2'*.

    frame2

  • 7/25/2019 Wp Lab Manual

    3/41

    hfont(si)e*25pt'color*pink'

    click the linkntrod&ction
    1epartments
    11633
    8eedback
    :aller%
    F+*(3'*.

    st page @7 6 0 H7A6 B:6I/'+$'*.

    intro

    Welcome to ong&nad& College of 6ngineering and 4echnolog% (ffiliated to nnaniDersit%

    EHind&sthan instit&te of 4echnolog% resolDes to mo&ld a h&man task force &sef&l to the societ%thro&gh transparent methods that lead to contin&o&s improDement of the reso&rces and state(of(the(art methodologies conforming to recogni)ed standards#F

    A'*.

    11633

  • 7/25/2019 Wp Lab Manual

    4/41

    0ame*Hind&sthan instit&te of 4echnolog%

    9ocation*coimbatore
    Contact 0o*G.25.5..
    Website* www#hind&sthan#net

    D(''*.

    1epartments

    1ept code1ept name.C36.26C6.$666.4.5A6CH

  • 7/25/2019 Wp Lab Manual

    5/41

    F(('*.

    feed

    4o giDe %o&r feedback mail to googleIfeedbackJedin

    G..'*.

    gall

    College 8ront Kiew

    SCREEN SHOTS%
  • 7/25/2019 Wp Lab Manual

    6/41

  • 7/25/2019 Wp Lab Manual

    7/41

    6;# 0o * 2

    1ate *

    im *

    1esign a web site &sing H4A9 and 1H4A9# se Masic te;t 8ormatting, mages

    Brogram *

    6;2#html

    4his te;t is normal#

    4his te;t is bold#

    4his te;t is strong#

    4his te;t is italic#

    4his te;t is emphasi)ed#

    Headings Headings 2Headings $Headings Headings 5H4A9 3mall 8ormattingH4A9 Aarked 8ormatting

    A% faDorite color is bl&e red#

    A% faDorite color is red#

    4his is s&bscripted te;t#

    4his is s&perscripted te;t#

    WW8Ns goal is to* M&ild a f&t&re where people liDe in harmon% with nat&re#

    Here is a +&ote from WW8Ns website*

    8or 5. %ears, WW8 has been protecting the f&t&re of nat&re#4he worldNs leading conserDation organi)ation,WW8 works in .. co&ntries and is s&pported b%#2 million members in the nited 3tates andclose to 5 million globall%#

    4he WH7 was fo&nded in OG#

    Written b% Lon 1oe#
    Kisit &s at*
    6;ample#com
    Mo; 5-, 1isne%land
    3
  • 7/25/2019 Wp Lab Manual

    8/41

    4his te;t will be written from right to left

    4o open a file, select*

    8ile P 7pen###

    demo#e;ample#com login* pr 2 .O*.*Q9in&; 2#-#.(grsecRgg$ReRfhs-bRnfsRgr.5.RRRp$RcaRgr2b(reslog(D-#GODar person = first0ame*"Lohn", last0ame*"1oe", age*5., e%eColor*"bl&e" Dar person = first0ame*"Lohn", last0ame*"1oe",

    age*5., e%eColor*"bl&e"

    6instein wrote*

    6 = m c2

    SCREEN SHOTS%

  • 7/25/2019 Wp Lab Manual

    9/41

  • 7/25/2019 Wp Lab Manual

    10/41

    E NO% 3

    DATE %

    AIM%

    Create a script that asks the &ser for a name, then greets the &ser with "Hello" and the &ser name

    on the page#

    PROGRAM %

    Click the b&tton#

    4r% it

    f&nction m%8&nctionTU Dar person = promptT"Blease enter %o&r name", ""U' if Tperson V= n&llU doc&ment#get6lementM%dT"demo"U#innerH4A9 = "Hello " R person R "V How are %o& toda%"'

  • 7/25/2019 Wp Lab Manual

    11/41

  • 7/25/2019 Wp Lab Manual

    12/41

    6;#0o* .

    1ate *

    A * Create a script that collects n&mbers from a page and then adds them &p and prints them to a blank

    field on the page#

    P+$,+*%

    f&nction s&mTUDar a,b,c,d,e,f'a=parsentTdoc&ment#get6lementM%dT"n"U#Dal&eU'b=parsentTdoc&ment#get6lementM%dT"n2"U#Dal&eU'c=parsentTdoc&ment#get6lementM%dT"n$"U#Dal&eU'd=parsentTdoc&ment#get6lementM%dT"n"U#Dal&eU'e=parsentTdoc&ment#get6lementM%dT"n5"U#Dal&eU'f=aRbRcRdRe'

    doc&ment#get6lementM%dT"ans"U#Dal&e=f'0&mber 0&mber 2

    0&mber $0&mber 0&mber 5nswer

    dd

  • 7/25/2019 Wp Lab Manual

    13/41

    74B4*

  • 7/25/2019 Wp Lab Manual

    14/41

    6X 0o * .5

    im*

    Create a script that prompts the &ser for a n&mber and then co&nts from to that n&mber displa%ing onl%

    the odd n&mbers#

    Brogram*

    ntitled 1oc&mentDar a=window#promptT"6nter the 0&mber",""U'forTDar i=' i

  • 7/25/2019 Wp Lab Manual

    15/41

  • 7/25/2019 Wp Lab Manual

    16/41

    6X 0o* .-

    im*

    Create a script that will check the field in ssignment for data and alert the &ser if it is blank# 4his script

    sho&ld r&n from a b&tton#

    Brogram*

    &ser registration form Dalidation &sing SaDascript with e;amplef&nction 3&bmitTU

    Dar emailege; = /YZ([a().(O#I\!?JZ([a()\!?#Z([a()\2,5]/'Dar fname = doc&ment#form#0ame#Dal&e,

    lname = doc&ment#form#9ast0ame#Dal&e,

    femail = doc&ment#form#6mail#Dal&e,freemail = doc&ment#form#enter6mail#Dal&e,fpassword = doc&ment#form#Bassword#Dal&e,fmonth = doc&ment#form#birthda%Imonth#Dal&e,fda% = doc&ment#form#birthda%Ida%#Dal&e,f%ear = doc&ment#form#birthda%I%ear#Dal&e'

    ifT fname == "" U doc&ment#form#0ame#foc&sTU '

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the first name"'

    ret&rn false'

    ifT lname == "" U doc&ment#form#9ast0ame#foc&sTU '

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the last name"' ret&rn false'

    if Tfemail == "" U

    doc&ment#form#6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the email"'ret&rn false'

    else ifTVemailege;#testTfemailUUdoc&ment#form#6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the Dalid email"'ret&rn false'

  • 7/25/2019 Wp Lab Manual

    17/41

    if Tfreemail == "" U

    doc&ment#form#enter6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "e(enter the email"'

    ret&rn false'else ifTVemailege;#testTfreemailUUdoc&ment#form#enter6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "e(enter the Dalid email"'ret&rn false'

    ifTfreemail V= femailU

    doc&ment#form#enter6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "emails are not matching,

    re(enter again"'ret&rn false'

    ifTfpassword == ""U

    doc&ment#form#Bassword#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the password"'ret&rn false'

    if Tfmonth == ""U

    doc&ment#form#birthda%Imonth#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select the birthda%

    month"' ret&rn false'

    if Tfda% == ""U doc&ment#form#birthda%Ida%#foc&sTU'

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select the birthda% da%"' ret&rn false'

    if Tf%ear == ""U doc&ment#form#birthda%I%ear#foc&sTU'

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select the birthda% %ear"' ret&rn false'

    ifTdoc&ment#form#radiob&ttonZ.\#checked == false ^^

    doc&ment#form#radiob&ttonZ\#checked == falseUdoc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select %o&r

    gender"'ret&rn false'

  • 7/25/2019 Wp Lab Manual

    18/41

    ifTfname V= NN ^^ lname V= NN ^^ femail V= NN ^^ freemail V= NN ^^ fpassword V= NN^^ fmonth V= NN ^^ fda% V= NN ^^ f%ear V= NNU

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "form s&bmitteds&ccessf&ll%"'

    ser egistration 8orm 1emo

    8orm Kalidated sing LaDascript

    Mirthda% Aonth

  • 7/25/2019 Wp Lab Manual

    19/41

    Lan 8eb Aar pr Aa%

    L&n L&l &g 3ep 7ct 0oD 1ec ^nbsp'^nbsp' 1a%

    2 $ 5 - Q G O . 2 $ 5 - Q G O 2. 2 22 2$ 2 25 2- 2Q 2G 2O $.

  • 7/25/2019 Wp Lab Manual

    20/41

    $ ^nbsp'^nbsp' @ear

    2.$ 2.2 2. 2.. 2..O 2..G 2..Q 2..- 2..5 2.. 2..$

    2..2 2.. 2... OOO OOG OOQ 8emale ^nbsp'^nbsp'^nbsp' Aale

    3ign p

  • 7/25/2019 Wp Lab Manual

    21/41

    E# N$% 07

    A)*%4o create a Web site sing C33#

    P+$,+* %

    &ser registration form Dalidation &sing SaDascript with e;ample !

    margin*.p;'padding*.p;'

    bod%font(famil%*4ahoma, :eneDa, sans(serif'

    container

    width*55.p;'backgro&nd(color*rgbaT25.,25.,252,#OU'margin*a&to'margin(top*.p;'margin(bottom*.p;'bo;(shadow*. . $p; OOO'

    containerIbod%padding*2.p;'

    #formItitle

    font(si)e*$5p;'color*G2$'te;t(align*center'padding*.p;'font(weight*normal'

    #headIparafont(si)e*Op;'color*OOa2aQ'

    te;t(align*center'font(weight*normal'

    formInamepadding*25p; . . 5p;'

    #firstnameorlastnamemargin(right*2.p;'

  • 7/25/2019 Wp Lab Manual

    22/41

    #inp&tIname

    width*2.Qp;'padding*5p;'font(si)e*Gp;'

    emailIformclear*both'padding*5p; . .p; .p;'

    #inp&tIemailwidth*$p;'padding*5p;'font(si)e*Gp;'

    eIemailIform

    padding*.p; . .p; .p;'#inp&tIeIemail

    width*$p;'padding*5p;'font(si)e*Gp;'

    passwordIformpadding*.p; . .p; .p;'

    #inp&tIpasswordwidth*$p;'padding*5p;'font(si)e*Gp;'

    #birthda%Ititlefont(si)e*-p;'color*GbOOd'font(weight*normal'padding*. . .p; .'

    selectpadding*5p;'

    birthda%font(si)e*2p;'color*GbOOd'padding(top*.p;'

    radioIb&tton

  • 7/25/2019 Wp Lab Manual

    23/41

    padding*.p; . . .'

    signI&serfont(si)e*p;'color*888'

    te;t(align*center'backgro&nd(color*$M5OOG'padding*.p;'margin(top*.p;'c&rsor* pointer'

    errorMo;color*8..'

    f&nction 3&bmitTU

    Dar emailege; = /YZ([a().(O#I\!?JZ([a()\!?#Z([a()\2,5]/'Dar fname = doc&ment#form#0ame#Dal&e,

    lname = doc&ment#form#9ast0ame#Dal&e,femail = doc&ment#form#6mail#Dal&e,freemail = doc&ment#form#enter6mail#Dal&e,fpassword = doc&ment#form#Bassword#Dal&e,fmonth = doc&ment#form#birthda%Imonth#Dal&e,fda% = doc&ment#form#birthda%Ida%#Dal&e,f%ear = doc&ment#form#birthda%I%ear#Dal&e'

    ifT fname == "" U doc&ment#form#0ame#foc&sTU '

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the first name"' ret&rn false'

    ifT lname == "" U doc&ment#form#9ast0ame#foc&sTU '

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the last name"' ret&rn false'

    if Tfemail == "" U

    doc&ment#form#6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the email"'

  • 7/25/2019 Wp Lab Manual

    24/41

    ret&rn false'else ifTVemailege;#testTfemailUU

    doc&ment#form#6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the Dalid email"'ret&rn false'

    if Tfreemail == "" U

    doc&ment#form#enter6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "e(enter the email"'ret&rn false'

    else ifTVemailege;#testTfreemailUUdoc&ment#form#enter6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "e(enter the Dalid email"'ret&rn false'

    ifTfreemail V= femailU

    doc&ment#form#enter6mail#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "emails are not matching,

    re(enter again"'ret&rn false'

    ifTfpassword == ""U

    doc&ment#form#Bassword#foc&sTU'doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "enter the password"'ret&rn false'

    if Tfmonth == ""U doc&ment#form#birthda%Imonth#foc&sTU'

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select the birthda%month"' ret&rn false'

    if Tfda% == ""U doc&ment#form#birthda%Ida%#foc&sTU'

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select the birthda% da%"' ret&rn false'

    if Tf%ear == ""U doc&ment#form#birthda%I%ear#foc&sTU'

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select the birthda% %ear"'

  • 7/25/2019 Wp Lab Manual

    25/41

    ret&rn false'

    ifTdoc&ment#form#radiob&ttonZ.\#checked == false ^^doc&ment#form#radiob&ttonZ\#checked == falseU

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "select %o&r

    gender"' ret&rn false'

    ifTfname V= NN ^^ lname V= NN ^^ femail V= NN ^^ freemail V= NN ^^ fpassword V= NN^^ fmonth V= NN ^^ fda% V= NN ^^ f%ear V= NNU

    doc&ment#get6lementM%dT"errorMo;"U#innerH4A9 = "form s&bmitteds&ccessf&ll%"'

    ser egistration 8orm 1emo

    8orm Kalidated sing LaDascript

  • 7/25/2019 Wp Lab Manual

    26/41

    Mirthda% Aonth Lan 8eb Aar pr

    Aa% L&n L&l &g 3ep 7ct 0oD 1ec ^nbsp'^nbsp' 1a% 2 $ 5 - Q G O . 2 $ 5 - Q G

  • 7/25/2019 Wp Lab Manual

    27/41

    O 2. 2 22 2$

    2 25 2- 2Q 2G 2O $. $ ^nbsp'^nbsp'

    @ear 2.$ 2.2 2. 2.. 2..O 2..G 2..Q 2..- 2..5 2.. 2..$ 2..2 2.. 2... OOO OOG OOQ OO- OO5 OO OO$ OO2 OO OO.

  • 7/25/2019 Wp Lab Manual

    28/41

    8emale ^nbsp'^nbsp'^nbsp' Aale

    3ign p

    O''%

    6; 0o * G

    im *

  • 7/25/2019 Wp Lab Manual

    29/41

    4o Create simple application to access data base &sing L1MC

    Brogram *

    import SaDa#s+l#!'p&blic class Ascess71MC

    p&blic static Doid mainT3tringZ\ argsU tr% // loading theSdbc odbc driDer Class#for0ameT"s&n#Sdbc#odbc#Ldbc7dbc1riDer"U' // creating connection toth data base Connection con = 1riDerAanager#getConnectionT"Sdbc*odbc*m%dsn","",""U' 3tatement st = con#create3tatementTU' // create an e;ec&te s+l command on database

    es&lt3et rs = st#e;ec&te_&er%T"3elect ! from st&dent order b% rollno asc"U' es&lt3etAeta1ata rsmd = rs#getAeta1ataTU' // this getCol&mnCo&nt re&rn the n&mber of col&mn in the selected table int n&mber7fCol&mns = rsmd#getCol&mnCo&ntTU' // while loop and with while loop code &se for print the data while Trs#ne;tTUU for Tint i = ' i

  • 7/25/2019 Wp Lab Manual

    30/41

    4o create a Brogram &sing BHB database f&nctions#

    Brogram *

    C$//(4'

    T(''*.

    6; 0o * .im *

    4o mplement A concept for b&ilding an% remote method of %o&r choice#

  • 7/25/2019 Wp Lab Manual

    31/41

    Brogram *

    p&blic interface 3haperea e;tends SaDa#rmi#emote

    p&blic long s+areaTint aU throws SaDa#rmi#emote6;ception'

    p&blic long recareaTint a,int bU throws SaDa#rmi#emote6;ception'

    S(A+(C.)(/'

    import SaDa#rmi#0aming'

    import SaDa#io#!'

    import SaDa#rmi#emote6;ception'

    import SaDa#net#Aalformed96;ception'

    import SaDa#rmi#0otMo&nd6;ception'

    p&blic class 3hapereaClient

    p&blic static Doid mainT3tringZ\ argsU

    tr%

    3haperea c = T3hapereaU 0aming#look&pT"rmi*//localhost/3haperea3erDice"U'

    M&fferedeader obSect = new M&fferedeaderTnew np&t3treameaderT3%stem#inUU'

    3%stem#o&t#printlnT"6nter the shape option #s+&are 2#ectangle"U'

    int a = nteger#parsentTobSect#read9ineTUU'

    switchTaU

    case *

    3%stem#o&t#printlnT"6nter the side of a s+&are*"U'

    int ;=nteger#parsentTobSect#read9ineTUU'3%stem#o&t#printlnT "4he area is"Rc#s+areaT;U U'

    break'

    case 2*

    3%stem#o&t#printlnT"6nter the 9ength ^ breadth of a ectangle*"U'

    int %=nteger#parsentTobSect#read9ineTUU'

    int )=nteger#parsentTobSect#read9ineTUU'

    3%stem#o&t#printlnT "4he area is"Rc#recareaT%,)U U'

    break'

    catch T6;ception eU

    3%stem#o&t#printlnT"e;ception"ReU'

  • 7/25/2019 Wp Lab Manual

    32/41

    S(A+(I*.

    p&blic class 3hapereampl e;tends SaDa#rmi#serDer#nicastemote7bSect implements

    3haperea

    p&blic 3hapereamplTU throws SaDa#rmi#emote6;ception

    s&perTU'

    p&blic long s+areaTint aU throws SaDa#rmi#emote6;ception

    int %= a!a'

    ret&rn %'

    p&blic long recareaTint a,int bU throws SaDa#rmi#emote6;ception

    int %= a!b'

    ret&rn %'

    S(A+(S(+(+

    import SaDa#rmi#0aming'

    p&blic class 3haperea3erDer

    p&blic 3haperea3erDerTU

    tr%

    3haperea c = new 3hapereamplTU' 0aming#rebindT"rmi*//localhost*.OO/3haperea3erDice", cU'

    catch T6;ception eU

    3%stem#o&t#printlnT"e;ception"ReU'

    p&blic static Doid mainT3tring argsZ\U

    new 3haperea3erDerTU'

    6; 0o * im *

    4o Write a program to implement web serDice for calc&lator application

  • 7/25/2019 Wp Lab Manual

    33/41

    Brogram *

    Calculator.java

    package m%pack'import SaDa;#Sws#WebAethod'

    import SaDa;#Sws#WebBaram'import SaDa;#Sws#Webes&lt'import SaDa;#Sws#Web3erDice'import SaDa;#;ml#ws#e+&estWrapper'import SaDa;#;ml#ws#esponseWrapper'/!!! 4his class was generated b% the LXW3 3#! LX(W3 2#.I.2(b.G(fcs! :enerated so&rce Dersion* 2#.!!/JWeb3erDiceTname = "Calc&lator", target0amespace = "http*//p/"Up&blic interface Calc&lator /!! !

    ! Jparam arg ! Jparam arg. ! Jret&rn ! ret&rns SaDa#lang#3tring !/ JWebAethod JWebes&ltTtarget0amespace = ""U Je+&estWrapperTlocal0ame = "s&m", target0amespace = "http*//p/", class0ame ="m%pack#3&m"U JesponseWrapperTlocal0ame = "s&mesponse", target0amespace = "http*//p/",class0ame = "m%pack#3&mesponse"U p&blic 3tring s&mT JWebBaramTname = "arg.", target0amespace = ""U int arg., JWebBaramTname = "arg", target0amespace = ""U int argU'C.4.'$+S(+)4(

    package m%pack'import SaDa#net#Aalformed96;ception'import SaDa#net#9'import SaDa;#;ml#namespace#_0ame'import SaDa;#;ml#ws#3erDice'import SaDa;#;ml#ws#Web6ndpoint'import SaDa;#;ml#ws#Web3erDiceClient'/!!! 4his class was generated b% the LXW3 3#

  • 7/25/2019 Wp Lab Manual

    34/41

    ! LX(W3 2#.I.2(b.G(fcs! :enerated so&rce Dersion* 2#.!!/JWeb3erDiceClientTname = "Calc&lator3erDice", target0amespace = "http*//p/",

    wsdl9ocation = "http*//localhost*G.G/A%Calc&latorWs/Calc&lator3erDiceW319"Up&blic class Calc&lator3erDice e;tends 3erDice priDate final static 9 C9C94736KC6IW319I97C470'

    static 9 &rl = n&ll' tr% &rl = new 9T"http*//localhost*G.G/A%Calc&latorWs/Calc&lator3erDiceW319"U'

    catch TAalformed96;ception eU e#print3tack4raceTU' C9C94736KC6IW319I97C470 = &rl'

    p&blic Calc&lator3erDiceT9 wsdl9ocation, _0ame serDice0ameU s&perTwsdl9ocation, serDice0ameU'

    p&blic Calc&lator3erDiceTU s&perTC9C94736KC6IW319I97C470, new _0ameT"http*//p/","Calc&lator3erDice"UU' /!! !

    ! Jret&rn ! ret&rns Calc&lator !/ JWeb6ndpointTname = "Calc&latorBort"U p&blic Calc&lator getCalc&latorBortTU ret&rn TCalc&latorUs&per#getBortTnew _0ameT"http*//p/", "Calc&latorBort"U,Calc&lator#classU' O(4'F4'$+9

    package m%pack'import SaDa;#;ml#bind#LXM6lement'import SaDa;#;ml#bind#annotation#Xml6lement1ecl'import SaDa;#;ml#bind#annotation#Xmlegistr%'

  • 7/25/2019 Wp Lab Manual

    35/41

    import SaDa;#;ml#namespace#_0ame'/!!! 4his obSect contains factor% methods for each! LaDa content interface and LaDa element interface! generated in the m%pack package#

    !

    n 7bSect8actor% allows %o& to programaticall%! constr&ct new instances of the LaDa representation! for XA9 content# 4he LaDa representation of XA9! content can consist of schema deriDed interfaces! and classes representing the binding of schema! t%pe definitions, element declarations and model! gro&ps# 8actor% methods for each of these are! proDided in this class#!!/JXmlegistr%

    p&blic class 7bSect8actor%

    priDate final static _0ame I3&mI_0A6 = new _0ameT"http*//p/", "s&m"U' priDate final static _0ame I3&mesponseI_0A6 = new _0ameT"http*//p/","s&mesponse"U'

    /!! ! Create a new 7bSect8actor% that can be &sed to create new instances of schemaderiDed classes for package* m%pack !

    !/ p&blic 7bSect8actor%TU

    /!! ! Create an instance of Jlink 3&m !

    !/ p&blic 3&m create3&mTU ret&rn new 3&mTU' /!! ! Create an instance of Jlink 3&mesponse !

    !/ p&blic 3&mesponse create3&mesponseTU ret&rn new 3&mesponseTU' /!! ! Create an instance of Jlink LXM6lement Jcode

  • 7/25/2019 Wp Lab Manual

    36/41

    !!/

    JXml6lement1eclTnamespace = "http*//p/", name = "s&m"U p&blic LXM6lement create3&mT3&m Dal&eU ret&rn new LXM6lementTI3&mI_0A6, 3&m#class, n&ll, Dal&eU'

    /!! ! Create an instance of Jlink LXM6lement Jcode !

    !/ JXml6lement1eclTnamespace = "http*//p/", name = "s&mesponse"U p&blic LXM6lement create3&mesponseT3&mesponse Dal&eU ret&rn new LXM6lementTI3&mesponseI_0A6,3&mesponse#class, n&ll, Dal&eU'

    4:,(-)/;$%

    JSaDa;#;ml#bind#annotation#Xml3chemaTnamespace = "http*//p/"Upackage m%pack'

    S*

    package m%pack'

    import SaDa;#;ml#bind#annotation#Xmlccess4%pe'import SaDa;#;ml#bind#annotation#Xmlccessor4%pe'import SaDa;#;ml#bind#annotation#Xml4%pe'/!!!

    LaDa class for s&m comple; t%pe#!!

    4he following schema fragment specifies the e;pected content contained withinthis class#!! ! ^lt'comple;4%pe name="s&m">

    ! ^lt'comple;Content>! ^lt'restriction base="http*//www#w$#org/2../XA93chemaan%4%pe">! ^lt'se+&ence>! ^lt'element name="arg." t%pe="http*//www#w$#org/2../XA93chemaint"/>! ^lt'element name="arg" t%pe="http*//www#w$#org/2../XA93chemaint"/>! ^lt'/se+&ence>! ^lt'/restriction>! ^lt'/comple;Content>

  • 7/25/2019 Wp Lab Manual

    37/41

  • 7/25/2019 Wp Lab Manual

    38/41

    package m%pack'

    import SaDa;#;ml#bind#annotation#Xmlccess4%pe'import SaDa;#;ml#bind#annotation#Xmlccessor4%pe'import SaDa;#;ml#bind#annotation#Xml6lement'

    import SaDa;#;ml#bind#annotation#Xml4%pe'

    /!!!

    LaDa class for s&mesponse comple; t%pe#!!

    4he following schema fragment specifies the e;pected content contained withinthis class#!! ! ^lt'comple;4%pe name="s&mesponse">! ^lt'comple;Content>

    ! ^lt'restriction base="http*//www#w$#org/2../XA93chemaan%4%pe">! ^lt'se+&ence>! ^lt'element name="ret&rn"t%pe="http*//www#w$#org/2../XA93chemastring" min7cc&rs="."/>! ^lt'/se+&ence>! ^lt'/restriction>! ^lt'/comple;Content>! ^lt'/comple;4%pe>! !!!/JXmlccessor4%peTXmlccess4%pe#8691UJXml4%peTname = "s&mesponse", prop7rder = "Iret&rn"Up&blic class 3&mesponse

    JXml6lementTname = "ret&rn"U protected 3tring Iret&rn'

    /!! ! :ets the Dal&e of the ret&rn propert%# !

    ! Jret&rn ! possible obSect is ! Jlink 3tring !

    !/ p&blic 3tring getet&rnTU

  • 7/25/2019 Wp Lab Manual

    39/41

    ret&rn Iret&rn'

    /!! ! 3ets the Dal&e of the ret&rn propert%#

    !! Jparam Dal&e ! allowed obSect is ! Jlink 3tring !

    !/ p&blic Doid setet&rnT3tring Dal&eU this#Iret&rn = Dal&e'

  • 7/25/2019 Wp Lab Manual

    40/41

    im *4o write a Brogram for eading and Writing the files &sing #0et#

    Brogram *

    ead#css*//ead a 4e;t 8ile&sing 3%stem'&sing 3%stem#7'

    namespace readwriteapp class Class

    Z344hread\static Doid AainTstringZ\ argsU

    3tring line'tr%

    //Bass the file path and file name to the 3treameader constr&ctor3treameader sr = new 3treameaderT"C*??3ample#t;t"U'

    //ead the first line of te;tline = sr#ead9ineTU'//Contin&e to read &ntil %o& reach end of filewhile Tline V= n&llU

    //write the lie to console windowConsole#Write9ineTlineU'//ead the ne;t lineline = sr#ead9ineTU'

    //close the filesr#CloseTU'Console#ead9ineTU'

    catchT6;ception eU

    Console#Write9ineT"6;ception* " R e#AessageU'finall%

    Console#Write9ineT"6;ec&ting finall% block#"U'

    Write#css*

  • 7/25/2019 Wp Lab Manual

    41/41

    &sing 3%stem'&sing 3%stem#7'

    namespace readwriteapp

    class ClassZ344hread\static Doid AainTstringZ\ argsU

    tr%//Bass the filepath and filename to the 3treamWriter Constr&ctor

    3treamWriter sw = new 3treamWriterT"C*??4est#t;t"U'//Write a line of te;tsw#Write9ineT"Hello WorldVV"U'

    //Write a second line of te;tsw#Write9ineT"8rom the 3treamWriter class"U'//Close the filesw#CloseTU'

    catchT6;ception eU

    Console#Write9ineT"6;ception* " R e#AessageU'finall%

    Console#Write9ineT"6;ec&ting finall% block#"U'