You are on page 1of 4

Q1. Explain HTML form. Ans: HTML is a markup language. HTML stands for Hyper Text Markup Language.

HTML is a very simple language used to describe t e logical structure of a document. !!H "for Hyper# is t e opposite of liner. !!T "for Text# is $ at $e s all use. !!M "for Mark# up is $ at $e s all do. !!L "for Language# is plain %nglis . HTML tags define document description t at is instructions embedded $it in a less&t an '() and a greater&t an '*) sign. To begin formatting# you specify a format type $it in t e ( and t e *. Most tags in HTML are ended $it a similar tag $it a slas in it to specify an end to t e formatting. +t is +mportant to note t at t e formatting codes $it in an HTML tag are case&insensitive. A $eb page t at $e create by using HTML is called an HTML document. An tml document as t$o parts# $ ic are: HEAD "T e H%A, tag defines an HTML document eader. T e eader contains information about t e document rat er t an information to be displayed in t e document. T e $eb bro$ser displays none of t e information in t e eader# except for text contained by t e title tag. -e specify t e title of t e -eb page in t e H%A, element. Example:( ead*(title*My .age(!title*(base ref/ ttp:!!$$$.niit.com*(! ead* BODY " 0ody is t e main contain of document. -e specify t e contents of t e -eb page in t e 01,2 element. T e structure of t e HTML document is as follo$s: (HTML*(H%A,*(T+TL%*(!T+TL%*(!H%A,*(01,2*(!01 ,2*(!HTML* Q2. Explain in brief the b il!in" blo#$ of %eb. An&: T ere are t$o most important building blocks of $eb: 3) HTML and 4) HTT'. HTML: & HTML stands for Hyper Text Markup Language. HTML is a very simple language used to describe t e logical structure of a document. Actually# HTML is often called programming language it is really not. .rogramming languages are Turing&complete# or computable. T at is# programming languages can be used to compute somet ing suc as t e s5uare root of pi or some ot er suc task. Typically programming languages use conditional branc es and loops and operate on data contained in abstract data structures. HTML is muc easier t an all of t at. HTML is simply a 6markup language7 used to define a logical structure rat er t an compute anyt ing. HTT': & HTT. is a re5uest&response type protocol. +t is a language spoken bet$een $eb bro$ser 'client soft$are) and a $eb server 'server soft$are) so t at can communicate $it eac ot er and exc ange files. 8o$ let us understand o$ client!server system $orks using HTT.. A client!server system $orks somet ing like t is: A big piece of computer 'called a server) sits in some office some$ ere $it a bunc of files t at people mig t $ant access to. T is computer runs a soft$are package t at listens all day long to re5uests over t e $ires. Q(. Explain an) t%o formattin" ta"& %ith &)ntax. Ans: T ere are t ree formatting tags. 1.B* +line brea$,: T e 09 tag inserts a line break. T e 09 tag does not add extra space before t e ne$ line. +f text is $rapping around an element suc as an image# you can use t e :L%A9 attribute of t e 09 tag to force t e text to continue its flo$ at t e next clear line. T e 09 tag does not re5uire a closing tag. -)ntax : .B* /LEA*01ALL121LE3T121*45HT1 6 2. /E7TE* +/entere! #ontent,: T e :%8T%9 tag centers content. All content bet$een t e (:%8T%9* and (!:%8T%9* tags is centered. ;ome tags take an optional AL+<8 attribute t at specifies t e alignment of an element. -e can put a :%8T%9 tag any$ ere# suc as in t e middle of a paragrap . T e value of an AL+<8 attribute overrides t e (:%8T%9* tag. -)ntax : ./E7TE*6....8/E7TE*6 (.H* +hori9ontal r le,: T e H9 tag dra$s a ori=ontal line across t e document frame or $indo$. 2ou can use a ori=ontal line to visually divide information or sections. T e H9 tag does not ave a closing tag. (.*T is text appears above a t ick# unsaved# centered ori=ontal rule. (H9 81;HA,% AL+<8/>:%8T%9> -+,TH/>?@A> ;+B%/>C>* (.*T is text appears belo$ t e ori=ontal rule. Q.:, ;rite a HTML pro"ram to in&ert a &ele#tion li&t in a form. An&: ( tml* (body* (form* (b*;cience ;ubDect(!b* (select* (option*. ysics (option* : emestry (option* Mat (!select* (!form* (!body* (! tml*

Q<. ;hat i& =ML> Explain in brief. An&: %xtensible markup language is a text&based markup language t at enables to store data in a structured format by using meaningful tags. EML is a cross&platform# !$ F s!$ independent markup language. EML allo$s computers to store data in a format t at can be interpreted by any ot er computer system. EML can be used to transfer structured data bet$een various systems. Eml is used as a common data interc anges format in a number of applications. EML is extremely simple. EML represents information as text using tags to add structure. A tag begins $it a name sand$ic ed bet$een less&t an '() and greater&t an '*) c aracters. Advantages of EML: a) it provides a $ay of creating domain& specific vocabulary. b) +t enables smart searc es. c) +t provides user&selected vie$ of data. d) it allo$s granular updates. EMl ,ocument& (Gxml version/3.@> encoding/HTI&C>G *(My,ocument*(!My,ocument* e.g.:(Gxmlversion/3.@G* (aut ors*(aut or*(firstname*raD(!firstname*(lastname*(kum ar(!lastname*(!aut or*(!aut ers* Q?.Ho% to #reate a @men A &in" BaCa -#ript. Ans: creating a menu using Java;cript. -e $ill create a simple menu# $ ic as a number of clickable options. T ere $ill be a single image $ ic c anges $ en options are selected. -e $ill also create a function $ ic takes care of c anging t e menu image. 2ou $ill be using t e images dog.gif F cat.gif as example. 1. .lace t e follo$ing code in t e body of your HTML document: (center*( 3*My Iavourite .ets(! 3*(img src/>dog.gif> name/>pet> eig t/3CA $idt /CA* (br* (font si=e/?*(p*(a ref/>Davascript:c ange.et'Kdog.gifK)L>*.,og.(!a* (p*(A ref/>Davascript:c ange.et'Kcat.gifK)L>*.:at.(!a* (!font*(!center*. 2. +nsert t e code for t e function c ange.et into t e ead portion of your page: (script language/ Java;cript* function c ange.et'file)M document.pet.src/fileL N (!script* (. Oie$ your page $it t e bro$ser. +f t e menu doesn7t $ork# be sure to c eck all semicolons# apostrop es# and 5uotation marks. - en a menu option is clicked# t e corresponding Java;cript code is executed. QD. ;hat i& /54> 5iCe example of /54 appli#ation& an! explain an)one of them. An&: :<+ or :ommon <ate$ay +nterface is a specification $ ic allo$s $eb users to run programs from t eir computer. :<+ is t e part of t e -eb server t at can communicate $it ot er programs running on t e server. T e -eb server can call up a program# $ ile passing user&specific data to t e program. T e program t en processes t at data and t e server passes t e program7s response back to t e -eb bro$ser. ;ome of t e possible applications of :<+ are: 3) Iorms: & 1ne of t e most prominent uses of :<+ is in processing forms are subsets of HTML t at allo$ t e user to supply information forms. T e forms interface makes -eb bro$sing an interactive process for t e user and t e provider.4) <ate$ays: & :<+ provides a solution to t e problem in t e form of a gate$ay. -e can use a language suc as or a perl or a ,0+ extension to .erl to form ;PL 5ueries to read t e information contained $it in t e database. 1nce $e ave t e information# $e can format and send it to t e client. +n t is case# t e :<+ program servers as a gate$ay to t e 1racle database. Q) Oirtual ,ocuments: & Oirtual# or dynamic# document creation is at t e eart of :<+. T ey are created on t e fly in response to a user7s information re5uest. -e can create virtual HTML# plain text# image# and even audio documents.b) +n brief explain t$o types of .%A9L variables. QE. Explain briefl) abo t #a&#a!in" &t)le &heet& +/--,. An&: :;; stands for :ascading style s eets. :;; is t e part of ,HTML t at controls t e look and placement of t e elements on a page. -it :;; $e can basically set any style property of any element on a HTML page. 1ne of t e biggest advantages $it :;; instead of t e regular $ay of c anging t e look of elements is t at $e split content from design. +f $e $ant to c ange like t e font si=e of our main text $e Dust c ange it in t e :;; file and all pages are updated. +n :;; program al$ays place t e style tag inside t e ead of document. T e syntax for :;; code is: (style type/text!css* %lementMproperty3:valueLproperty:value4N (!style* Let us see couple of examples: -e al$ays place t e style tag inside t e ead of t e document. ;o a document could look like t is. All H? eading on t at page $ould t en look like t is: ( tml*( ead* (style type/>text!css>* H?Mbackground&color:blueL color:$ iteL font&si=e:4@pxN (!style*(body*( ?*:ascading style s eets(! ?* (!body*(! tml*

QF. ;hat i& BaCa &#ript> ;hat i& the &e of BaCa &#ript an! %hat are it& !i&a!Canta"e&> An&: Java;cript is a scripting language 'like a simple programming language). Java;cript is a language t at can be used for client&side scripting. Java;cript is only used inside of HTML documents. -it Java;cript# $e can make text scroll across t e screen like ticker tape. Java;cript does not ave any grap ics capabilities# except for t e ability to format and display HTML. Ior security reasons# client& side Java;cript does not allo$ t e reading or $riting of files. 1bviously# you $ouldn7t $ant to allo$ an untrusted program from any random $eb site to run on your computer and rearrange your files. The &e& of BaCa-#ript are: i, :ontrol ,ocument Appearance and :ontent ii, :ontrol t e 0ro$ser iii, +nteract $it ,ocument :ontrol iC, +nteract $it Hser C, 9ead and -rite :lient ;tate $it :ookies Ci, +nteract $it Applets Cii) Java;cript is only used inside of HTML documents. Di&a!Canta"e&: i, Java;cript do not ave any grap ics capabilities. ii) Ior security reasons# client&side Java;cript does not allo$ t e reading or $riting of files. iii) Java;cript does not support any kind of net$orking. iv) Java;cript doesn7t ave any multit reading capabilities. Q1G. Explain in brief the b il!in" element& of %eb. An&: T ere are t$o most important building elements of $eb: 3) HTML and 4) HTT' HTML: & HTML stands for Hyper Text Markup Language. HTML is a very simple language used to describe t e logical structure of a document. Actually# HTML is often called programming language it is really not. .rogramming languages are Turing&complete# or computable. T at is# programming languages can be used to compute somet ing suc as t e s5uare root of pi or some ot er suc task. Typically programming languages use conditional branc es and loops and operate on data contained in abstract data structures. HTML is muc easier t an all of t at. HTML is simply a 6markup language7 used to define a logical structure rat er t an compute anyt ing. HTT': & HTT. is a re5uest&response type protocol. +t is a language spoken bet$een $eb bro$ser 'client soft$are) and a $eb server 'server soft$are) so t at can communicate $it eac ot er and exc ange files. 8o$ let us understand o$ client!server system $orks using HTT.. A client!server system $orks somet ing like t is: A big piece of computer 'called a server) sits in some office some$ ere $it a bunc of files t at people mig t $ant access to. T is computer runs a soft$are package t at listens all day long to re5uests over t e $ires. 11. ;rite an HTML pro"ram to !emon&trate applet embe!!in". An&:-applet is embedded in HTML pages using t e (A..L%T*tag. An example of an HTML page containing an applet $ ic scroll t e specify text across t e screen at a specified speed. ( tml* ( ead* (title*,emo applet(!title* (! ead* (body* (applet code/scrollingRbanner.class: codebase/Dclasses $idt /4S@ eig t/S@@ align/middle space/3@ vspace/4@* (param name/message OALH%/Hse 8etscape navigator t e $orld $ide $eb.* (param name/speed value/S* (!applet* (!body* (! tml* Q.1<, Explain ho% HTT' i& &e! in #lient - &erCer &)&tem. An&: HTT. means Hyper Text transfer .rotocol. Http is used t e maintain t e connectivity bet$een client and server. it is stateless protocol and it can not preserve data across t$o session. ;o $e use t e tracking session. Http is a re5uest&response protocol t at specify t at a client $ill open a connection to a server and t en send a re5uest using a specific format. T e server t en receives and parses t e re5uest of t e client to send back t e re5uested resources using HTT.. Ior sending t e response to t e server. $e ave to accessed t e server ard$are .so $e use t e HTT. in client&server system.. Q1D. ;rite HTML &#ript to !i&pla) @Hello %orl!H %el#ome to the %orl! of HTMLAH the title a& @%orl! of HTMLA. Ans: (HTML*(H%A,*(T+TL%*$orld of HTML(!T+TL%*(;cript language/Java ;cript* Hello $orld# $elcome to t e $orld of HTML(!;:9+.T*(!H%A,*(01,2*(!01,2* (!HTML*

Q12.4n brief explain t%o t)pe& of 'EA*L Cariable&. An&. T ere are follo$ing t$o types of pearl variables. -#alar&:- A scalar variable stores a single 'scalar) value. .erl scalar names are prefixed $it a dollar sign 'T)# so for example# Tx# Ty# T=# Tusername# and Turl are all examples of scalar variable names. Here7s o$ variables are set: Tfoo / 3L Tname / IredL Tpi / Q.3S3?U4L +n t is example Tfoo# Tname# and Tpi are scalars. 2ou do not ave to declare a variable before using it# but its considered good programming style to do so. T ere are several different $ays to declare variables# but t e most common $ay is $it t e my function: my Tfoo / 3L my 'Tname) / IredL my 'Tpi) / Q.3S3?U4L my simultaneously declares t e variables and limits t eir scope 't e area of code t at can see t ese variables) to t e enclosing code block. 2ou can declare a variable $it out giving it a value: my TfooL 2ou can also declare several variables $it t e same my statement: my 'Tfoo# Tbar# Tblee)L Arra):- An array stores an ordered list of values. - ile a scalar variable can only store one value# an array can store many. .erl array names are prefixed $it an V&sign. Here is an example: my Vcolors / 'red#green#blue)L %ac individual item 'or element) of an array may be referred to by its index number. Array indices start $it @# so to access t e first element of t e array Vcolors# you use TcolorsW@X. 8otice t at $ en you7re referring to a single element of an array# you prefix t e name $it T instead of V. T e T&sign again indicates t at it7s a single 'scalar) valueL t e V&sign means you7re talking about t e entire array. +f you $ant to loop t roug an array# printing out all of t e values# you could print eac element one at a time: my Vcolors / 'red#green#blue)L print TcolorsW@XYnL Z prints red print TcolorsW3XYnL Z prints green print TcolorsW4XYnL Z prints blue A muc easier $ay to do t is is to use a foreach loop: my Vcolors / 'red#green#blue)L foreac my Ti 'Vcolors) M print TiYnLN Q1:. ;hat i& the !ifferen#e bet%een %eb &erCer an! appli#ation &erCer> An&: ;eb &erCer: -eb server is t e soft$are responsible for accepting bro$ser re5uests# retrieving its content F returning its content. 0y default# -eb bro$sers use port C@ for t eir re5uests. -eb servers are often called ttpd# using a H8+E convention in $ ic daemons are named $it t e name of t e service follo$ed by t e letter d. -eb servers first retrieve t e re5uest using 0erkeley sockets. Most $eb servers on +nternet today run on H8+E mac ines. Appli#ation &erCer: An application server commonly includes a $eb server so per aps $e can see an application server as an extension of a $eb server. +n application server you can deploy a Dava components ranging from simple Dava application to server side business components. Hsually $ en $e $ant to deploy %J0s $e $ill go for App servers like $eb&logic or $eb&sp ere. +n application server# eDb&Dar.xml or application.xml file is used as deployment descriptor.

Q1?. ;hat i& HTML> Briefl) explain an) t%o HTML ta"&. ;hat i& the &e of HTML> Ans: HTML is a markup language. HTML stands for Hyper Text Markup Language. HTML is a very simple language used to describe t e logical structure of a document. !!H "for Hyper# is t e opposite of liner. !!T "for Text# is $ at $e s all use. !!M "for Mark# up is $ at $e s all do. !!L "for Language# is plain %nglis . HTML tags define document description t at is instructions embedded $it in a less&t an '()and a greater&t an '*) sign. To begin formatting# you specify a format type $it in t e ( and t e *. Most tags in HTML are ended $it a similar tag $it a slas in it to specify an end to t e formatting. +t is important to note t at t e formatting codes $it in an HTML tag are case&insensitive. HTML tags are follo$ing: Html tags are used to mark&up HTML element& Html tags are surrounded by t e t%o #hara#ter& .an!6 T e surrounding c aracters are called an"le bra#$et& Html tags normally #ome in pair& like (b* and (!b* Html tags are not #a&e &en&itiCe. HTML allo%& & to :: .ublis documents to t e +nternet in a platform independent format :reate links to related $orks from your document +nclude grap ics and multimedia data $it your document Link to non&-orld -ide -eb information resources on t e +nternet Q1E. ;hat i& B-'> Ho% it i& !ifferent from /54 pro"rammin"> An&: J;. stands for Java ;erver .ages. +t is a tec nology for developing $eb pages t at include dynamic content. A J;. page can c ange its content based on any number of variable items# including t e identity of t e user# t e user7s bro$ser type# information provided by t e user# and selections made by t e user. A J;. page contains standard markup language elements# suc as HTML tags# Dust like a regular $eb page. J;. also contains special J;. elements t at allo$ t e server to insert dynamic content in t e page. J;. elements can be used for a variety of purposes# suc as retrieving information from a database or registering user preferences. J;. defines a number of standard elements t at are useful for any $eb application# suc as accessing Java0eans components# passing control bet$een pages and s aring information bet$een re5uests# pages# and users. .rogrammers can also extend t e J;. syntax by implementing application&specific elements t at perform tasks suc as accessing databases and %nterprise Java0eans# sending email# and generating HTML to present application&specific data. Q1F.Explain B-' error han!lin". Ans: Like all development met ods# J;.s need a dynamic mec anism for andling errors. T e J;. arc itecture provides an error& andling solution t roug t e use of J;.s t at are $ritten exclusively to andle J;. errors. T e errors t at occur most fre5uently are runtime errors t at can arise eit er in t e body of t e J;. page or in some ot er obDect t at is called from t e body of t e J;. page. 9e5uest&time errors t at result in an exception being t ro$n can be caug t and andled in t e body of t e calling J;.# $ ic signals t e end of t e error. %xceptions t at are not andled in t e calling J;. result in t e for$arding of t e client re5uest# including t e uncaug t exception# to an error page specified by t e offending J;.. Here $e see o$ an error page $orks# let7s create a simple J;. t at t ro$s an uncaug t exception. T e J;. s o$n ere uses t e error page created in t e previous section. (AV page error.age/errorpage.Dsp A*(Aif ' true ) M t ro$ ne$ %xception'An uncaug t %xception)LNA* +n t is listing t at t e first line of code sets error.age e5ual to errorpage.Dsp# $ ic is t e name of t e error page. To make a J;. a$are of an error page#$e simply need to add t e error.age attribute to t e page directive and set its value e5ual to t e location of our J;. error page. Q2G. Explain &erClet life #)#le.

T e lifecycle of a ;ervlet consists of t e follo$ing fundamental stages: l 4n&tantiation - T e $eb server creates an instance of a servlet. T is based on a re5uest or a container startup 4nitiali9ation & T e $eb server creates t e instance7s init') met od. - en $eb server loads a $eb application# it also loads t e initiali=ation parameters associated $it t e application. The aboCe t%o &tate& o## r onl) on#e ! rin" the lifetime of a &erClet in&tan#e. l -erCi#e - T is is t e t ird state in t e servlet lifecycle. +n t is state t e servlets service') met od is called $ ic generates response. T e generation of response involves t e follo$ing steps: 3. ;etting t e content type of t e response. T e receiving application 'bro$ser) uses t is information to kno$ o$ to treat t e response data. Ior example# to generate an HTML output# t e content&type is set to text! tml. 4. T e second step is to get .rinter-riter obDect from reponse. .rint-riter is a class from Dava.io package t at extends t e Dava.io.$riter abstract class. +n t e case of servlets t e $eb server constructs t e .rinter-riter obDect from t e Dava.io.1utput;tream obDect associated $it t e underlying connection from t e client. De&tro) - T is is t e final stage in a servlet lifecycle. +n t is taget e destroy') met od is calledbefore s utting do$n t e ;ervlet. Q21.Explain the or!ere! li&t& an! nor!ere! li&t&. An&: O*DE*ED L4-T-: T e 1L tag displays an ordered# or numbered# list. T e default numbering style is determined by t e bro$ser# but you can use t e tag7s T2.% attributes to c ange t e numbering se5uence and numbering style. Hse t e L+ tag to designate t e individual list items. ;yntax: <OL START="value" TYPE="A"|"a"|"I"|"i"|"1" CLASS="styleClass" ID="namedPlaceO Style" LA!"="ISO" STYLE="style"# (!1L*. I7O*DE*ED L4-T: T e HL tag displays a bulleted list. 2ou can use t e tag7s T2.% attribute to c ange t e bullet style. Hse t e L+ tag to designate t e individual list items in t e list. ;yntax: <$L TYPE="CIRCLE"|"DISC"|"S%$ARE" CLASS="styleClass" ID="namedPlaceO Style" LA!"="ISO" STYLE="style" * (!HL*. L4-T 4TEM : T e L+ tag indicates an itemi=ed element# $ ic is usually preceded by a bullet# a number# or a letter. T e L+ tag is used inside list elements suc as 1L 'ordered list) and HL 'unordered list).A single itemi=ed element can contain ot er tags suc as t e . tag.T e L+ tag does not re5uire a closing tag.;yntax : <LI TYPE="DISC"|"CIRCLE"|"S%$ARE"|"A"|"a"|"I"|" i"|"1" &AL$E="num'e " CLASS="styleClass" ID="namedPlaceO Style" LA!"="ISO" STYLE="style"# <(LI# Q22. ;rite a BaCa -erClet pro"ram &in" HTML to &ho% all the parameter name& that %ere &ent an! p t& them in table. An&:-HTMLJ '*O5*AM ( tml* ( ead* (title*Login .age(!title* (! ead* (body* (center*(form name/>LoginIorm> met od/>get> action/>Log>* ( 3*;tudent Login Iorm(! 3* (table border/>[> bgcolor/>yello$>* (tr*(td*(font color/>red>*Hser 8ame:(!font*(!td*(td*(input type/>text> name/>t3> si=e/>3@>*(!td*(!tr* (tr*(td*.ass$ord:(!td*(td*(input type/>pass$ord> name/>t4> si=e/>34>*(!td*(!tr* (tr*(td bgcolor/>green>*(input type/>submit> value/>Log+n>*(!td*(!tr* (!table* (!form*(!center* (!body* (! tml* -E*KLETJ'*O5*AM:import Dava.io.\L import Dava.net.\L

import Davax.servlet.\L import Davax.servlet. ttp.\L public class Log extends Http;ervlet M protected void process9e5uest'Http;ervlet9e5uest re5uest# Http;ervlet9esponse response) t ro$s ;ervlet%xception# +1%xception M response.set:ontentType'>text! tmlLc arset/HTI&C>)L .rint-riter out / response.get-riter')L ;tring name/re5uest.get.arameter'>t3>)L ;tring pass$ord/re5uest.get.arameter'>t4>)L out.println'>( tml*>)L out.println'>( ead*>)L out.println'>(title*-elcome(!title*>)L out.println'>(! ead*>)L out.println'>(body*>)L out.println'>(mar5uee bgcolor/silver*-elcome to my servlet page(!mar5uee*>)L out.println'>Hser 8ame:>]name)L out.println'>(br*>)L out.println'>.ass$ord is:>]pass$ord)L out.println'>(!body*>)L out.println'>(! tml*>)L out.close')L NN Q2(.;hat i& extra path information> Explain %ith an example. Q2:. ;hat i& --L> ;h) !o )o reL ire --L> An&: ;;L stands for ;ecure ;ockets Layer. ;;L is a protocol. +t is developed by 8etscape# as become t e universal standard on t e -eb for aut enticating -eb sites to -eb bro$ser users# and for encrypting communications bet$een bro$ser users and -eb servers. -e re5uired ;;L is to provide security for -eb traffic. ;ecurity includes confidentiality# message integrity# and aut entication. ;;L is built into all maDor bro$sers and -eb servers# simply installing a digital certificate# or ;erver +,# enables ;;L capabilities. T ere are follo$ing re5uirement of ssl. A thenti#ation an! en#r)ption:- ;;L protects confidential information t roug t e use of cryptograp y. ;ensitive data is encrypted across public net$orks to ac ieve a level of confidentiality -erCer 4D:- +nstalled on your -eb server# a ;erver +, is a digital credential t at enables visitors using -eb bro$sers to verify your site7s aut enticity and to communicate $it it securely via ;;L encryption. A customer contacts your site and accesses a secured H9L: a page secured by a ;erver +, 'indicated by a H9L t at begins $it ttps: instead of Dust ttp: or by a message from t e bro$ser). Q2<. ;hat are the !ifferent %a)& of tra#$in" &er&> An&:-Iollo$ing are t e several $ays of tracking users# including t e follo$ing: Hi!!en text^Hsing idden controls in a -eb page is t e easiest $ay of associating some information $it t e user t at7s not directly accessible to im. Ho$ever# t e idden text can be seen if t e user looks at t e HTML for t e -eb page directly. /oo$ie&^T is is probably t e most common $ay of tracking users on t e +nternet. 2ou can store information in a user7s computer using cookies# and retrieve it $ en you need it. 2ou can also specify o$ long t e cookie s ould exist before being deleted by t e bro$ser. -e&&ion&^;essions are somet ing t e server offers us to support user tracking# and t ey7re great# alt oug t ey can take up a lot of resources on t e server. ;essions let you preserve data bet$een accesses to a -eb page by t e same user. Appli#ation&^Applications are muc like sessions# as you7ll see# but t ey7re more general^you can s are data bet$een all t e J;. pages in a site using applications. +n ot er $ords# unlike sessions# applications can be used to track multiple users at t e same time. 2?. Explain 5ET an! 'O-T metho!. Ans: - en a client sends a re5uest to t e server# t e client can also additional information $it t e H9L to describe $ at exactly is re5uired as output from t e server by using t e <%T met od. T e additional se5uence of c aracters t at are appended to H9L is called a 5uery string. Ho$ever# t e lengt of t e 5uery string is limited to 4S@ c aracters. Moreover# t e 5uery string is visible on t e bro$ser and can t erefore be a security risk. To overcome t ese disadvantages# t e .1;T met od can be used. T e .1;T met od sends t e data as packets t roug a separate socket connection. T e complete transaction is invisible because to t e client. T e disadvantage of .1;T met od is t at it is slo$er compared to t e <%T met od because data is sent to t e server as separate packets. Q2D, /reate a &imple HTML pa"e to !emon&trate the &a"e of an#hor ta"&. ( tml* (body*

( 3 align/>center>*All in 1ne(! 3* (p align/>left>*+n (a ref/>Zsec3>*section 3(!a*-e can searc . +n (a ref/>Zsec4>*section 4(!a*-e can s op.(!p* (a name/>sec3>*;ection 3:(!a* (p*(a ref/> ttp:!!google.co.in>target/>Rblank>* ;earc on google(!a*FnbspL(!p* (p*(a ref/> ttp:!!ya oo.com>target/>Rblank>*;earc on ya oo(!a*(!p* (p*FnbspL(!p* (p*(a name/>sec4>*;ection 4:(!a*(!p* (p*(a ref/> ttp:!!ebay.com>*; op on ebayFnbspL(!a*(!p* (p*(a ref/> ttp:!!$allpaper.com>*,o$nload $alpaper(!a*FnbspL(!p* (p*(a ref/> ttp:!!t&s irt.com>*1rder :ustom t&s irt 8e$s(!a*(!p* (!body* (! tml* Q2E. Explain the metho!& to a##e&& no!e& in a !o# ment tree. An&:& T e document obDect serves as t e root of t is node tree. +t too implements t e 8ode interface. +t $ill ave c ild nodes but no parent node or sibling nodes# as it is t e starting node. +n addition to being a 8ode# it also implements t e ,ocument interface. T is interface provides met ods for accessing and creating ot er nodes in t e document tree. ;ome met ods are: get%lement0y+d')# get%lements0yTag8ame')# create%lement')# createAttribute')# createText8ode').8ote t at unlike ot er nodes# t ere is only one document obDect in a page. All of t e above met ods 'except get%lements0yTag8ame')) can only be used against t e document obDect# i.e.# using t e syntax document.met od8ame'). T e document obDect can also ave several ot er properties related to older ,1M level support. Ior example# $e7ll find t at many bro$sers still ave document.images and document.links arrays or document.bg:olor and document.fg:olor properties relating to t e 0<:1L19 and T%ET attributes of t e 01,2 tag. T ese properties are intended to provide some back$ard compatibility so t at pages designed for older bro$sers $ill still $ork properly $it ne$er versions. T ey can still be used in scripts but t ey may not be supported in future versions. Q2F. ;hat are /54 enCironment Cariable&> Explain an) 3iCe. An& :- - en a :<+ program is called# t e information t at is made available to it can be roug ly broken into t ree groups :& +nformation about t e client# server# and user Irom data t at t e user supplied Additional pat name information Most information about t e client# server# or user is placed in :<+ environment variables. T e environment variables are :& 1. 5ATE;AYJ47TE*3A/E: & it defines t e revision of t e :<+ t at t e server uses. 2. -E*KE*J7AME: &it defines t e server7s ostname or +. address. (. *EQIE-TJMETHO,: & it defines t e met od $it $ ic t e information re5uest $as issued. :. 'ATHJ473O: & it defines extra pat information passed to a :<+ program. <. -/*4'TJ7AME: & it defines t e virtual pat of t e script being executed. Q(G.;ith the help of an example explain Q er) -trin". Ans:&+ ave to seen H9Ls like t e follo$ing: ttp:!!my.system!cgi&bin!name.plGfortune Hp to t e 5uestion mark'G)#t e H9L s ould look familiar. +t is merely a :<+ script being called# by t e name name.pl. - at7s ne$ ere is t e part after t e G. T e information after t e G c aracter is kno$n as a 5uery string. - en t e server is passed a H9L $it a 5uery string# it calls t e :<+ program identified in t e first part of t e H9L 'before t e G) and t en stores t e part after t e G in t e environment variable PH%92R;T9+8<. T e follo$ing is a :<+ program called name.pl t at uses PH%92R;T9+8< to print t e information passed. Z_!usr!local!bin!perl print :ontent&type: text!plain# YnYnL T5ueryRstring / T%8OM6PH%92R;T9+8<7NL if 'T5ueryRstring e5 fortune) M print 65uery string is fortune6L N elsif 'T5ueryRstring e5 finger) M print 65uery string is finger6L N else M print 6invalid 5uery string6L N exit '@)L 2ou can execute t is script as eit er: ttp:!!some.mac ine!cgi&bin!name.plGfortune ttp:!!some.mac ine!cgi&bin!name.plGfinger or ttp:!!some.mac ine!cgi&bin!name.pl and you $ill get different output. Q.(1, Explain ho% &erClet mappin" are !one in %eb.xml. An&: ;ervlet Mapping done in -eb.xml $it t e elp of t e(servlet&mapping*tags.

(servlet&mapping* (servlet&name*:ontroller(servletRname* (url&pattern*\.do (!url&pattern* (!servlet&mapping* .servlet&mapping6 (servlet&name*grap (servletRname* (url&pattern*!grap (!url&pattern* (!servlet&mapping* According to first mapping# all re5uests of t e form ttp:!!local ost:C@@C!Mcontextpat N.do $ill be mapped to t e controller servlet $ ereas according to second mapping all re5uest of t e form ttp:!!C@@C!Mcontextpat N!grap $ill be mapped to t e grap servlet. Q(2.;rite a B-' pro"ram %hi#h !i&pla)& !ifferent me&&a"e to the &er ba&e! on the time of !a). Ans: (AV taglib prefix/c uri/ ttp:!!Dava.sun.com!Dstl!core A* ( tml* (body bgcolor/$ ite* (Dsp:use0ean id/clock class/Dava.util.,ate !* (c:c oose*(c:$ en test/TMclock. ours ( 34N* ( 3*<ood morning_(! 3*(!c:$ en*(c:$ en test/T Mclock. ours ( 3CN*( 3*<ood day_(! 3* (!c:$ en*(c:ot er$ise*( 3*<ood evening_(! 3* (!c:ot er$ise* (!c:c oose*-elcome to our site# open 4S ours a day.(!body* (! tml*. Q.((, Explain impli#it obMe#t& o tH reL e&tH re&pon&e in a B-' pa"e. An&: t ere are imlicit obDects t at are used in Dsp page. 1.O t:- t is implicit obDect represents a Dsp$riter t at provide a stream back to t e re5uest client. T e most common met od of t is obDects is out.println')# $ ic is used to print t e text message on t e screen. 2.reL e&t:-t is implicit obDect t at is represents t e Davax.servlet.Http;ervlet9e5uest interface. t is obDect is associated $it every HTT. re5uest. T is is very usefull to access re5uest parameters.$e can calling t is obDect to use of get.arameter')met od $it t e parameter name. it takes only string values. (.re&pon&e:- t is implicit obDect represents t e Davax.servlet.Http;ervlet9e5uest obDect. T e response obDect is used to pass data to t e re5uesting client.t is obDect is most usefull to $riting HTML output back to t e cient bro$ser. Q(:.Explain the t%o approa#he& that a %eb appli#ation #an be !eplo)e! 4n Tom#at. Ans: Tomcat $ill operate under any Java ,evelopment `it 'J,`) environment t at provides a J,` 3.4 or later platform . A %eb appli#ation #an be !eplo)e! in Tom#at b) the follo%in" approa#he&: a, :opy unpacked directory ierarc y into a subdirectory in directory T:ATAL+8ARH1M%!$ebapps!. Tomcat $ill assign a context pat to application based on t e subdirectory name c oose. -e $ill use t is tec ni5ue in t e build.xml file t at $e construct# because it is t e 5uickest and easiest approac during development. 0e sure to restart Tomcat after installing or updating t e application. b, Hse t e Tomcat ? Manager $eb application to deploy and undeploy $eb applications. Tomcat ? includes a $eb application# deployed by default on context pat !manager t at allo$s to deploy and undeploy applications on a running Tomcat server $it out restarting it. ;ee t e administrator documentation for more information on using t e Manager -eb application. #, Hse Manager Ant Tasks +n 1ur 0uild ;cript. Tomcat ? includes a set of custom task definitions for t e Ant build tool t at allo$ automating t e execution of commands to t e Manager $eb application. T ese tasks are used in t e Tomcat deployer. !, Hse t e Tomcat ,eployer. Tomcat ? includes a packaged tool bundling t e Ant tasks# and can be used to automatically precompiled J;.s $ ic are part of t e $eb application before deployment to t e server. (<, 5iCe the hi"h leCel #omm ni#ation bet%een %eb bro%&er +#lient, an! %eb &erCer. An&:- T e bro$ser breaks t e H9L into t ree parts: ':onsider ttp:!!$$$.my$ebsite.com! firstpage. tm as an example H9L) 3. T e protocol ' ttp) 4. T e server name '$$$.my$ebsite.com) Q. T e file name '$eb&server. tm) 'a).T e bro$ser communicated $it a name server to translate t e server name $$$.my$ebsite.com into an +. Address# $ ic it uses to connect to t e server mac ine. 'b)T e bro$ser t en formed a connection to t e server at t at +. address on port C@. (c)Iollo$ing t e HTT. protocol# t e bro$ser sent a <%T re5uest to t e server# asking for t e file ttp:!!$$$.my$ebsite.com!firstpage. tm. '8ote t at cookies may be sent from bro$ser to server $it t e <%T re5uest.) (d)T e server t en sent t e HTML text for t e -eb page to t e bro$ser. ':ookies may also be sent from server to bro$ser in t e eader for t e page.)

(e)T e bro$ser read t e HTML tags and formatted t e page onto your reen. Q(?. Briefl) explain the three t)pe& of B-' element& that %e &e. Ans: T ere are t ree types of J;. elements $e can use: directive# action# and scripting. Dire#tiCe element&: ;pecify information about t e page itself t at remains t e same bet$een re5uests. e.g. : (AV page ... A* &&&&,efines page&dependent attributes# suc as session tracking# error page# and buffering re5uirements. -tan!ar! a#tion element&: Action elements typically perform some action based on information t at is re5uired at t e exact time. +t can also dynamically generate HTML# suc as a table filled $it information. +t retrieved information retrieved from an external system. e.g.: (Dsp:use0ean*&&&&Makes a Java0eans component available in a page. -#riptin" element&: Allo$ us to add small pieces of Dava code in a J;. page. +f statement to generate different HTML depending on a certain condition. -e s ould use scripting elements $it extreme care. e.g.: (A ...A* &&&&;criptlet# used to embed scripting code. Q(D. ;hat i& B-'> ;hat i& the &e of B-'> ;hat are the a!Canta"e& of B-'> An&. J;. is stands for Java server .age. J;. is a tec nology for developing $eb page t at include dynamic content. J;. page contains special J;. elements t at allo$ t e server to insert dynamic content in t e page. J;. elements can be used for a variety of purposes# suc as retrieving information from a database or registering user preferences. J;. is used for c ange its content based on any number of variable items# including t e identity of t e user# t e user7s bro$ser type# information provided by t e user# and selections made by t e user. The a!Canta"e& of B-' : 3) J;. supports bot scripting& and element&based dynamic content and allo$s programmers to develop custom tag libraries to satisfy application&specific needs. 4) J;. pages are compiled for efficient server processing. Q) J;. pages can be used in combination $it servlets t at andle t e business logic# t e model supported by Java servlet template engines. Q(E. ;hat are the a!Canta"e& an! !i&a!Canta"e& of EBB&> An&: Advantage of %J0: a) Many vendor application servers conform to t e J4%% specification allo$ing one to select a best&of&breed solution. b) To andle fluctuations in resource demand server&side resources can easily be scaled by adding or removing servers. c) Application servers provide access to complex services# namely transaction and security management# resource pooling# J8,+# component lifecycle management# etc. ,isadvantage of %J0: a) %J0 as a large and complicated specification. b) %J0s take longer to develop. Also# t ey can be more difficult to debug. c) 8o sooner ave $e deployed our %J0 application t an $e see a ne$ specification coming do$n t e pipe $it ne$er features# rendering our application obsolete. T is situation# o$ever# is unavoidable $it cutting&edge tec nologies. Q(F. ;rite &hort note& on: +a,--L +b,=ML +#,EBB An&:- +a,-LL- ;;L stands for ;ecure ;ockets Layer. ;;L is a protocol. +t is developed by 8etscape# as become t e universal standard on t e -eb for aut enticating -eb sites to -eb bro$ser users# and for encrypting communications bet$een bro$ser users and -eb servers. -e re5uired ;;L is to provide security for -eb traffic. ;ecurity includes confidentiality# message integrity# and aut entication. ;;L is built into all maDor bro$sers and -eb servers# simply installing a digital certificate# or ;erver +,# enables ;;L capabilities. +b,=ML- %xtensible markup language is a text&based markup language t at enables to store data in a structured format by using meaningful tags. EML is a cross&platform# !$ F s!$ independent markup language. EML allo$s computers to store data in a format t at can be interpreted by any ot er computer system. EML can be used to transfer structured data bet$een various systems. Eml is used as a common data interc anges format in a number of applications. EML is extremely simple. EML represents information as text using tags to add structure. A tag begins $it a name sand$ic ed bet$een less&t an '() and greater&t an '*) c aracters. +#,EBB- An %J0 is a server&side component t at executes specific business logic. %J0s run on a server and are invoked by local or remote clients. %J0 is a frame$ork for $riting distributed programs. %J0 involves a standardi=ed agreement t at enables a component to run $it in any application server. T e agreement is accomplis ed by implementing a set of Java interfaces from t e %J0 A.+. %J0s are not <H+ components.

You might also like