You are on page 1of 2

1.difference between request.getParameter() and request.getAttribute()? Always do a request.getParameter() to extract request parameters (i.e.

data sent by posting a html form ). The request.getParameter() always returns tring !alue and the data come from client. The basic difference between getAttribute() and getParameter() is that the first method extracts a (seriali"ed) #a!a ob$ect and the other pro!ides a tring !alue. %.&ow to config a # P file in web.xml? 'eclare the following tags in web.xml against your $sp (ser!let) (ser!let*name)my$sp(+ser!let*name) ($sp*file)+my$sp.$sp(+$sp*file) (init*param) (param*name)hello(+param*name) (param*!alue)test(+param*!alue) (+init*param) (+ser!let) (ser!let*mapping) (ser!let*name)my$sp(+ser!let*name) (url*pattern)+my$sp(+url*pattern) (+ser!let*mapping) ,.difference between page and page-ontext in # P pages? The page ob$ect represents the generated ser!let instance itself. i.e.. it is same as the /this/ 0eyword used in a #a!a file. 1efers to $a!a.lang.2b$ect The page-ontext ob$ect represents the en!ironment for the page. containing useful information li0e page attributes. access to the request. response and session ob$ects. as well as the #sp3riter referenced by out. $a!ax.ser!let. $sp.Page-ontext 4.difference between $sp5forward and response.send1edirect? The ($sp5forward ..) is actually a call to &ttp er!let1equest.forward( tring url) which passes the request ob$ect within the ser!er to either a ser!let or a # P page. The new ser!let or # P page continues to process the same request and the browser is not aware of the fact that more than one ser!let or page is in!ol!ed. The response.send1edirect() creates a new request ob$ect which doesn6t carry any of old requests. The first request handler # P page tells the browser to ma0e a new request to the target ser!let or # P page. The 718 shown in the browser therefore changes to the 718 of the new page when you redirect.

9.&ow to disable browser caching for a specific # P? :t is possible to 0eep the browser from caching a # P page response. The following hints added to the response header seem to pre!ent most modern browsers from pulling pages out of cache when the same 718 is /hit/5 (; response.set&eader( /Pragma/. /no*cache/ )< response.set&eader( /-ache*-ontrol/. /no*cache/ )< response.set'ate&eader( /=xpires/. > )< ;) The same effect can be achie!ed by using meta tags in the &T?8 header5 (meta http*equi!@/Pragma/ content@/no*cache/) (meta http*equi!@/-ache*-ontrol/ content@/no*cache/) (meta http*equi!@/=xpires/ content@/ at. >1 'ec %>>1 >>5>>5>> A?T/) The -ache*-ontrol header was added in &TTP 1.1. while the other two were also present in &TTP 1.>.

You might also like