You are on page 1of 9

HJello World Servlet

HttpServlet-

doGetHttpServletRequest/Response

Exception JWSDP Tomcat server exception handlin ! Stac" trace appended to lo s/#$sdp%lo &'&txt HT() document returned to client ma* +or ma* not, contain partial stac" trace Servlet output to S*stem&out&print+,- printStac"Trace+,- etc& is appended to lo s/launcher&server&lo

Println-

Servlet.loseD*namic .ontent

Potential pro/lems! 0ssumin one instance o1 servlet on one server- /ut (an* We/ sites are distri/uted over multiple servers Even a sin le server can +not de1ault, create multiple instances o1 a sin le servlet Even i1 the assumption is correct- this servlet does not handle concurrent accesses properl* We2ll deal $ith this later in the chapter

Servlet )i1e.*cle Servlet 0P3 li1e c*cle methods init+,! called $hen servlet is instantiated4 must return /e1ore an* other methods $ill /e called service+,! method called directl* /* server $hen an HTTP request is received4 de1ault service+, method calls doGet+, +or related methods covered later,

destro*+,! called $hen server shuts do$n

Parameter Data The request o/#ect +$hich implements HttpServletRequest, provides in1ormation 1rom the HTTP request to the servlet 5ne t*pe o1 in1ormation is parameter data- $hich is in1ormation 1rom the quer* strin portion o1 the HTTP request

-Parameter data is the We/ analo o1 ar uments in a method call!

6uer* strin s*ntax and semantics (ultiple parameters separated /* 7 5rder o1 parameters does not matter 0ll parameter values are strin s

Parameter names and values can /e an* 8-/it characters 9R) encodin is used to represent non-alphanumeric characters!

9R) decodin applied /* server to retrieve intended name or value 9R) encodin al orithm

GET/P5ST

You might also like