public class Servletode e%tends $ttpServlet ? protected void process8e>uest($ttpServle process8e>uest($ttpServlet8e>uest t8e>uest re>uest, $ttpServlet8esponse response) thro!s Servlet4%ception, ;uestgetParameter(t%t"oc)= c)= s>r insert into 4P' values(FdnoF, KFdnameFK, KFdlcFK)= lass&orName(orgapachederb2dbclientriver)= onnection cn
riverManagergetonnection(dbc:derb2:++localhost:16J+ompan2)= Statement st cncreateStatement()= ste%ecute.pdate(s>r)= H catch(4%ception e) ? outprint(egetMessage())= H outprintln(@uest($ttpServlet8e>uest t8e>uest re>uest, $ttpServlet8esponse response) thro!s Servlet4%ception, ;uestgetonte%tPath() F +h1*)= String ans (String) re>uestgetSession(&alse re>uestgetSession(&alse)getAttribute(un)= )getAttribute(un)= outprintln(ans)= outprintln(+bod2*)= outprintln(+html*)= H H H
(O) Simple Server-Side programming using 9SP O Aim: Write 9SP &ile that accepts a number &rom $'M" &orm and � ispla2 ispla2s s !hether !hether it� s even even or odd odd � ;t�s &ac &acto tori rial al � Multiplication table Solution: $'M" ode: html* head* title*+title* meta http-e>uivontent-'2pe contentte%t+html= charset.'/-0* +head* bod2* &orm action4ven/actMulsp method74'* hO*alculate /actorial , 4ven+uivontent-'2pe contentte%t+html= charset.'/-0* title*9SP Page+title* +head* bod2* String str= int n= strre>uestgetParameter(num)= n;ntegerparse;nt(str)=* hO*ispla2 /actorial +hO* tr2 ? int &act1,= &or(1=n=FF) ? &act&actL= H outprint(/actorial o& F nF is F&act)= H catch(4%ception e) ? H * @ int m= * hO*ispla2 4E4N+uest= ava%servlethttp$ttpServlet8esponse=
WebServlet(name7cd"cmServlet, urlPatterns?+7cd"cmServletH) public class 7cd"cmServlet e%tends $ttpServlet ? 49I private 7cd"cmIean ob= protected void do7et($ttpServlet8e>uest re>uest, $ttpServlet8esponse response) thro!s Servlet4%ception, ;uestg a;ntegerparse;nt(re>uestgetParameter(t1))= etParameter(t1))= int b;ntegerparse;nt(re>uestg b;ntegerparse;nt(re>uestgetParameter(tJ))= etParameter(tJ))= outprintln(7 o& t!o numbers is: Fobgcd(a, b))= outprintln(br*)= outprintln("M o& t!o numbers is: Foblcm(a, b))= H &inall2 ? outclose()= H H H 9SP ode: page content'2pete%t+html page4ncoding.'/-0* @lL=
import ava%!sWebService= import ava%!sWebMethod= import ava%!sWebParam= WebService(serviceName 'rade3WS) public class 'rade3WS ? WebMethod public String give8ate(WebParam(name item) String item) ? String rate1= onnection connull= tr2 ? lass&orName(orgapachederb2dbc4mbeddedriver)= conriverManagergetonnection(dbc:derb2:++localhost:16J+db1)= H catch(4%ception e) ? S2stemerrprintln(e)= H tr2 ? Statement stconcreateStatement()= 8esultSet rsste%ecuteUuer2(Select L &rom trade !here ;nde%K F item F K)= !hile(rsne%t()) ? ratersgetString(J)= H H catch(SU"4%ception e) ? S2stemerrprintln(e)= H return rate= H H
9SP ode 1: page content'2pete%t+html page4ncoding.'/-0* @uestgetParameter(selitem)= tr2 ? trade!s'rade3WS port ne! trade!s'rade3WS()= String resultportgive8ate(str)= outprintln(8ate is Fresult)= H catch(4%ception e)?H * +bod2* +html*
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.