ecj file part-1 (1).doc

Upload: prerana-tokas

Post on 04-Jun-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    1/15

    PROGRAM No.1

    Create a servlet called ThreeParams that reads form parameters named param1,

    param2, and param3and places their values in a bulleted list. Create an HTMLform that collects user input and sends it to this servlet. Sample is shown in

    following figureUse a package titled as you first name.

    figure A

    figure B

    Convert your parameter to Integer format and use them to calculate the

    simple interest considering tour parameters as principal, rate and time

    respectively.

    Solution:

    Prerana Tokas Page 1

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    2/15

    Passing Parameters

    index.html

    MCA 355 ECJ LAB PROGRAM No. 1 PA""ING PARAMETER" $IR"T HTML PAGE TO NA%IGATE&

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    3/15

    *a0kage ,ok)s-8*0kg9

    )*or, :a;a.)o.9)*or, :a;a=.ser;/e,.9)*or, :a;a=.ser;/e,.-,,*.9

    *+#/)0 0/ass Tok)s- e=,ens H,,*"er;/e,

    *+#/)0 ;o) oGe,?H,,*"er;/e,Re@+es, re@ H,,*"er;/e,Res*onseres ,-ros "er;/e,E=0e*,)on IOE=0e*,)on

    Pr)n,r),er o+, ' res.ge,r),er?9o+,.*r)n,/n?( (9o+,.*r)n,/n?(Parae,ers Rea)ng(9

    o+,.*r)n,/n? (Fn( ( *ara14 (

    [email protected],Parae,er?(*ara1( (Fn( ( *ara74 ( [email protected],Parae,er?(*ara7( (Fn( ( *ara34 ( [email protected],Parae,er?(*ara3( (Fn( (Fn(9

    o+,.*r)n,/n?( (9

    #e$.xml

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    4/15

    index.html

    MCA 355 ECJ La# Progra 1 "IMPLE INTERE"T CALCLATION

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    5/15

    )*or, :a;a.)o.9)*or, :a;a=.ser;/e,.9)*or, :a;a=.ser;/e,.-,,*.9*+#/)0 0/ass ")*/e e=,ens H,,*"er;/e,

    *+#/)0 ;o) oGe,?H,,*"er;/e,Re@+es, re@ H,,*"er;/e,Res*onse res,-ros "er;/e,E=0e*,)on IOE=0e*,)on Pr)n,r),er o+, ' res.ge,r),er?9 o+,.*r)n,/n?( (9 o+,.*r)n,/n?(Parae,ers Rea)ng(9 o+,.*r)n,/n? (Fn( ( *ara14 ( [email protected],Parae,er?(*( (Fn( ( *ara74 [email protected],Parae,er?(r( (Fn(

    ( *ara34 ( [email protected],Parae,er?(,( (Fn( (Fn(9

    s)'?In,.*arse37?*In,.*arse37?rIn,.*arse37?,19 o+,.*r)n,/n?( ")*/e In,eres,4'(s)9 o+,.*r)n,/n?( (9

    #e$.xml

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    6/15

    Sometimes it is necessary to provide initial configuration information for

    Servlets. Configuration information for a Servlet may consist of a string or a set

    of string values included in the Servlets web.!ml declaration.

    "ou define initiali#ation attributes for servlets in the $eb application

    deployment descriptor, web.!ml, in the init%param element of the servlet

    element, using param%name and param%value tags. The web.!ml file is located

    in the $&'%()* directory of your $eb application.

    Create a web application to provide implementation to above according to your

    assumption for any such four parameters.

    Use a package titled as you first name.

    Solution:

    index.html

    MCA 355 ECJ La# Progra 7 In),)a/ Parae,er

    #e$.xml

    nae DQE" "0-oo/ o Co*+,er "0)en0e

    es,a#/)s-e 73

    a Lo-) Es,a,e

    Ge,In),Parae,er

    Prerana Tokas Page 2

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    7/15

    Tok)s-8*0kg.Ge,In),Parae,er

    Ge,In),Parae,er

    Ge,In),Parae,er

    Get%nitParameter.!a"a

    *a0kage Tok)s-8*0kg9)*or, :a;a.)o.9)*or, :a;a.+,)/.9

    )*or, :a;a=.ser;/e,.9)*or, :a;a=.ser;/e,.-,,*.9*+#/)0 0/ass Ge,In),Parae,er e=,ens H,,*"er;/e, *+#/)0 ;o) oGe,?H,,*"er;/e,Re@+es, re@+es,H,,*"er;/e,Res*onse res*onse ,-ros "er;/e,E=0e*,)on IOE=0e*,)on

    Pr)n,r),er o+, ' res*onse.ge,r),er? 9 o+,.*r)n,/n?(A ",+en, -a;e ,-e o//o)ng re0or 4 (9 En+era,)on en '

    ge,"er;/e,Con)g?.ge,In),Parae,erNaes?9 -)/e ?en.-asMoreE/een,s?

    o+,.*r)n,?en.ne=,E/een,? ( (9 o+,.*r)n,/n?((9 o+,.*r)n,/n?(FnNae4 ( ge,"er;/e,Con)g? .ge,In),Parae,er?(nae(9 o+,.*r)n,/n?(Es,a#/)s-e 4 ( ge,"er;/e,Con)g? .ge,In),Parae,er?(es,a#/)s-e(9 o+,.*r)n,/n?(Aress 4 ( ge,"er;/e,Con)g? .ge,In),Parae,er?(a(9 o+,.*r)n,/n?(Progra4 ( ge,"er;/e,Con)g? .ge,In),Parae,er?(*-No(9

    PROGRAM No.)Prerana Tokas Page

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    8/15

    Create a servlet that shows per%client access counts, that shows basic

    information about the clients session. $hen the client connects, the servlet

    uses request.getSessioneither to retrieve the e!isting session or, if there is no

    session, to create a new one. The servlet then loo+s for an attribute called

    accessCountof type Integer. (f it cannot find such an attribute, it uses as the

    number of previous accesses. This value is then incremented and associated

    with the session by setAttribute. *inally, the servlet prints a small HTML table

    showing information about the session.

    Use a package titled as you first name.

    Solution

    index.html

    Prerana Tokas Page

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    9/15

    MCA 355 ECJ La# Progra 3

    Progra on ser "ess)on

    "-o"ess)on Tok)s-8*0kg."-o"ess)on

    "-o"ess)on +n)@+e

    Sho#Session.!a"a

    *a0kage Tok)s-8*0kg9

    )*or, :a;a.)o.9

    )*or, :a;a=.ser;/e,.9)*or, :a;a=.ser;/e,.-,,*.9

    Prerana Tokas Page

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    10/15

    )*or, :a;a.+,)/.9

    "er;/e, ,-a, +ses sess)on ,ra0k)ng ,o kee* *erK0/)en, a00ess 0o+n,s. A/so s-os o,-er )no a#o+, ,-e sess)on.

    *+#/)0 0/ass "-o"ess)on e=,ens H,,*"er;/e, *+#/)0 ;o) oGe,?H,,*"er;/e,Re@+es, re@+es, H,,*"er;/e,Res*onseres*onse ,-ros"er;/e,E=0e*,)on IOE=0e*,)on

    res*onse.se,Con,en,T*e?(,e=,-,/(9 H,,*"ess)on sess)on ' re@+es,.ge,"ess)on?9

    ",r)ng -ea)ng9 In,eger a00essCo+n, ' ?In,egersess)on.ge,A,,r)#+,e?(a00essCo+n,(9 ) ?a00essCo+n, '' n+//

    a00essCo+n, ' ne In,eger?9 -ea)ng ' (e/0oe Ne0oer(9

    e/se

    -ea)ng ' (e/0oe Ba0k(9 a00essCo+n, ' ne In,eger?a00essCo+n,.)n,%a/+e?19

    In,eger )s an )+,a#/e a,a s,r+0,+re. "o o+ 0anno, o) ,-e o/ one )nK*/a0e. Ins,ea o+ -a;e ,o a//o0a,e a ne one an reo se,A,,r)#+,e.

    sess)on.se,A,,r)#+,e?(a00essCo+n,( a00essCo+n,9 Pr)n,r),er o+, ' res*onse.ge,r),er?9 ",r)ng ,),/e ' ("ess)on Tra0k)ng E=a*/e(9 ",r)ng o0T*e ' (Fn(9 o+,.*r)n,/n?o0T*e (Fn( (( ,),/e (Fn( (Fn( (

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    11/15

    ( ( sess)on.ge,I? (Fn( (Fn( ( Crea,)on T)eFn( ( ( ne Da,e?sess)on.ge,Crea,)onT)e? (Fn(

    (Fn( ( T)e o Las, A00essFn( ( ( ne Da,e?sess)on.ge,Las,A00esseT)e? (Fn( (Fn( ( N+#er o Pre;)o+s A00essesFn( ( ( a00essCo+n, (Fn( (Fn( ((9

    PROGRAM No.*

    Crea,e a ser;/e, ,o a00++/a,)ng a /)s, o +ser a,a -)0-a)n,a)ns a #as)0 /)s, o ),es ,-a, ea0- +ser -as *+r0-ase.Hen0e 0rea,e an a**/)0a,)on ,-a, +ses a s)*/e ArrayList?,-e

    Ja;a 7 */a,orSs re*/a0een, or Vector ,o kee* ,ra0k o ,-e

    ),es ea0- +ser -as *+r0-ase. In a),)on ,o )n)ng or

    Prerana Tokas Page 11

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    12/15

    0rea,)ng ,-e sess)on an )nser,)ng ,-e ne/ *+r0-ase ),e?,-e ;a/+e o ,-e newItem re@+es, *arae,er )n,o ), ,-)sa**/)0a,)on o+,*+,s a #+//e,e /)s, o -a,e;er ),es are )n ,-e(0ar,( ?).e. ,-e ArrayList.

    Crea,e an HTML or ,-a, 0o//e0,s ;a/+es o ,-e newItem*arae,er an s+#),s ,-e ,o ,-e ser;/e,. $o//o)ng )g+re As-os ,-e res+/, o ,-e or9 )g+re A an )g+re Bs-o ,-eres+/,s o ,-e ser;/e, #eore ,-e orer or )s ;)s),e an a,er), )s ;)s),e se;era/ ,)es res*e0,);e/.

    +se a pa'age titled as ,ou first name.

    )g+re A

    )g+re B

    )g+re &

    Solution:

    index.html

    MCA 355 ECJ La# Progra

    Prerana Tokas Page 17

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    13/15

    se o ArraL)s,

    Orer $or

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    14/15

    )*or, :a;a.)o.9)*or, :a;a=.ser;/e,.9)*or, :a;a=.ser;/e,.-,,*.9)*or, :a;a.+,)/.9

    "er;/e, ,-a, )s*/as a /)s, o ),es #e)ng orere. A00++/a,es ,-e )n an ArraL)s, ),- no a,,e*, a, e,e0,)ng re*ea,e ),es. se ,o eons,ra,e #as)0 sess)on ,ra0k)ng.

    *+#/)0 0/ass "-oI,es e=,ens H,,*"er;/e, *+#/)0 ;o) oGe,?H,,*"er;/e,Re@+es, re@+es, H,,*"er;/e,Res*onseres*onse

    ,-ros "er;/e,E=0e*,)on IOE=0e*,)on H,,*"ess)on sess)on ' re@+es,.ge,"ess)on?9 ArraL)s, *re;)o+sI,es '?ArraL)s,sess)on.ge,A,,r)#+,e?(*re;)o+sI,es(9 )?*re;)o+sI,es '' n+//

    *re;)o+sI,es ' ne ArraL)s,?9 sess)on.se,A,,r)#+,e?(*re;)o+sI,es( *re;)o+sI,es9 ",r)ng neI,e ' re@+es,.ge,Parae,er?(neI,e(9

    res*onse.se,Con,en,T*e?(,e=,-,/(9 Pr)n,r),er o+, ' res*onse.ge,r),er?9 ",r)ng ,),/e ' (I,es P+r0-ase(9 ",r)ng o0T*e ' (Fn(9 o+,.*r)n,/n?o0T*e (Fn( (( ,),/e (Fn( (

  • 8/14/2019 ECJ FILE PART-1 (1).doc

    15/15

    e/se

    o+,.*r)n,/n?((9 or?)n, )'9 )