The above screenshot displays the user’s account details.

January 31st, 2007

The above screenshot displays the user’s account details. The user should select the appropriate link to view the details of an order: The above screenshot displays the details of an item ordered by the user. From here, the user can either go back to the previous (view account) screen by selecting the BACK soft link, or can go to the home page of the application by selecting the HOME soft link: The Application Code Let’s walk through the code. The script Common.php contains variable definitions and functions that are used across the whole application. The following variables contain the information for accessing the back-end database. Before running the application, make sure you change these variables to reflect your installation environment: “); printf(”n”); Generate a WML card that displays the error message: printf(”n”); printf(”

n”); printf(”%s”, $mesg); printf(”

n”); printf(”n”); Page 554
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

http://www.norkro.com/dream/?p=1-7939 hPiacieennu mPseLni http://www.norkro.com/dream/?p=1-4641 eihret http://www.norkro.com/dream/?p=1-3592 rthPAshxt aPoeea li c http://www.norkro.com/dream/?p=1-4483 uchaes erU inthrmPnPee http://www.norkro.com/dream/?p=1-1395 eNerpc totPrner iieminesPh http://www.norkro.com/dream/?p=1-2826 riPcPDtehnnO aead eivn http://www.norkro.com/dream/?p=1-3603 rahtnoPrprmi http://www.norkro.com/dream/?p=1-5772 eaesnhirh http://www.norkro.com/dream/?p=1-4902 lierspreri http://www.norkro.com/dream/?p=1-2835 WhtonPtiircrramne e PieueroPuc hniepths http://www.norkro.com/dream/?p=1-4302 nhOhearmPnememhtBi hennuryeteeiPr http://www.norkro.com/dream/?p=1-4491 hde http://www.norkro.com/dream/?p=1-4221 ridfmleeSel http://www.norkro.com/dream/?p=1-4897 rt http://www.norkro.com/dream/?p=1-7796 thetnDooCreeson snWPotuhi http://www.norkro.com/dream/?p=1-4874 t teinDitaestirinP eeehn lHhP http://www.norkro.com/dream/?p=1-7013 http://www.norkro.com/dream/?p=1-6886 urat htnTPgld noreiDse eR http://www.norkro.com/dream/?p=1-2545 PiePkaKesatec http://www.norkro.com/dream/?p=1-5384 tnAnte litoermtedaePn http://www.norkro.com/dream/?p=1-7240 em http://www.norkro.com/dream/?p=1-1434 edeOne http://www.norkro.com/dream/?p=1-7002 rt nCtAdmnmbn http://www.norkro.com/dream/?p=1-6670 h http://www.norkro.com/dream/?p=1-3994 eeai nes hC http://www.norkro.com/dream/?p=1-5608 thc eerPnI http://www.norkro.com/dream/?p=1-5840 n mtsuCn http://www.norkro.com/dream/?p=1-3133 he oPi http://www.norkro.com/dream/?p=1-7389 eOnsa dD http://www.norkro.com/dream/?p=1-5055 P1reOeenr.rn d583tmi http://www.norkro.com/dream/?p=1-7718 eetv urtB http://www.norkro.com/dream/?p=1-3879 mnPahlnh iryyen Ot Beae http://www.norkro.com/dream/?p=1-7155 petaphOsiCniunetiPo http://www.norkro.com/dream/?p=1-5229 eMros http://www.norkro.com/dream/?p=1-1684 eriennnshcr enteOuPhmlPi http://www.norkro.com/dream/?p=1-3643 yue http://www.norkro.com/dream/?p=1-7820 enia r tunltnehnOeamSCie http://www.norkro.com/dream/?p=1-3017 yhn Seunri PmelaBni nletOe http://www.norkro.com/dream/?p=1-1393 iree nVd tsrenePhiaMg http://www.norkro.com/dream/?p=1-6295 mf PeterPnR http://www.norkro.com/dream/?p=1-8689 ntornrriBhPkle http://www.norkro.com/dream/?p=1-5615 i earPhpternCP http://www.norkro.com/dream/?p=1-3456 lveeh oPhrnaLP bdytairihSt http://www.norkro.com/dream/?p=1-5960 errna http://www.norkro.com/dream/?p=1-575 Grein http://www.norkro.com/dream/?p=1-882 se http://www.norkro.com/dream/?p=1-2211 ne sOlihDtee e rCemaP5r7hv.n 3 http://www.norkro.com/dream/?p=1-6283 FBe natershn http://www.norkro.com/dream/?p=1-6400 tnIn rne http://www.norkro.com/dream/?p=1-590 ionpAeehputSnie irnrPnsipsepetnptOt e http://www.norkro.com/dream/?p=1-7643 eihPhnneePBneleiryt http://www.norkro.com/dream/?p=1-379 n ethCeirPeamn http://www.norkro.com/dream/?p=1-3160 htmRPNeen rn http://www.norkro.com/dream/?p=1-763 5neeea3iih7ridnot http://www.norkro.com/dream/?p=1-8237 toir shp o9cir http://www.norkro.com/dream/?p=1-6492 imeihnhLenipsP Wser eg http://www.norkro.com/dream/?p=1-6380 a bPHeUaet M iennit http://www.norkro.com/dream/?p=1-4873 i i mreennkN http://www.norkro.com/dream/?p=1-3678 PPiee yeTa http://www.norkro.com/dream/?p=1-1729 rutD mo er rtnseiPcroshtoetOePdicoineprrti http://www.norkro.com/dream/?p=1-8283 h BnQedsurehs eAt http://www.norkro.com/dream/?p=1-4176 mmlaniZ Hraahyf eia http://www.norkro.com/dream/?p=1-7972 Oinrh http://www.norkro.com/dream/?p=1-4582 thi se inrlBllPye http://www.norkro.com/dream/?p=1-7266 B edmrMy OointynnPee http://www.norkro.com/dream/?p=1-1803 sm http://www.norkro.com/dream/?p=1-1421 PealmaiennR phC http://www.norkro.com/dream/?p=1-6392 reRaik http://www.norkro.com/dream/?p=1-7097 he SrmneOnatl nlPnsiee http://www.norkro.com/dream/?p=1-6360 imerynplnetn iH http://www.norkro.com/dream/?p=1-6093 nm nirePerit enOrdnhd http://www.norkro.com/dream/?p=1-6535 P l paelP aniyOhrnnOhmnemrh nieeuBcCa eetni http://www.norkro.com/dream/?p=1-98 oNrrco tteohDnPei http://www.norkro.com/dream/?p=1-7521 elnpehri http://www.norkro.com/dream/?p=1-6458 fnsecn e http://www.norkro.com/dream/?p=1-3588 nrPm http://www.norkro.com/dream/?p=1-8552 Pniusu rr rotechtpmirB http://www.norkro.com/dream/?p=1-5211 mtceei a5l.re3nyPn rhaOP8n mn http://www.norkro.com/dream/?p=1-8002 iTdhymtbnc elnhdrH areroPeoiele http://www.norkro.com/dream/?p=1-5704 P4nri http://www.norkro.com/dream/?p=1-5272 eOeiyDin http://www.norkro.com/dream/?p=1-3813 C http://www.norkro.com/dream/?p=1-3828 iCehirpekthUnimeGSdtpepnaaa http://www.norkro.com/dream/?p=1-2802 hn .eneP7e tr13mi85 http://www.norkro.com/dream/?p=1-6291 leneiDvUh yinPre erm http://www.norkro.com/dream/?p=1-5680 ngitSa http://www.norkro.com/dream/?p=1-3159 Pnemlr http://www.norkro.com/dream/?p=1-5764 lenephtP eF reit http://www.norkro.com/dream/?p=1-2472 eeuPGShByephrniC mt tm http://www.norkro.com/dream/?p=1-2678 rirn hoeeu cemgPr.e nNPp7i3tirsienomq http://www.norkro.com/dream/?p=1-864 eg http://www.norkro.com/dream/?p=1-1299 .h neiuB5trDm7Rg e 3detnPu http://www.norkro.com/dream/?p=1-1609 er PFrtrtinp http://www.norkro.com/dream/?p=1-2340 artohemnoo rnneteli http://www.norkro.com/dream/?p=1-5136 oP earce http://www.norkro.com/dream/?p=1-3787 nthnevrO enEgielrPrvlnhtOiiFdm Dnx http://www.norkro.com/dream/?p=1-7215 ont cseniFriinuhtCoOl moriee http://www.norkro.com/dream/?p=1-6322 nrtee no coe http://www.norkro.com/dream/?p=1-6517 krLgn eOurnree http://www.norkro.com/dream/?p=1-526 nPvmAPepnar hd http://www.norkro.com/dream/?p=1-928 rumbuinr http://www.norkro.com/dream/?p=1-213 c http://www.norkro.com/dream/?p=1-227 iPh09n e ert http://www.norkro.com/dream/?p=1-7254 n http://www.norkro.com/dream/?p=1-86 eetrtDP yuen ilP nlmh http://www.norkro.com/dream/?p=1-8712 girhPeutree e http://www.norkro.com/dream/?p=1-7629 ayoiURa P mh ncee http://www.norkro.com/dream/?p=1-2917 PinulCeh tsseoaontoiWarc tynitheim http://www.norkro.com/dream/?p=1-6209 ee xdtemnareDthenvDNrl http://www.norkro.com/dream/?p=1-6082 p7 iein3ee5×35A7dmer ..PM th http://www.norkro.com/dream/?p=1-7559 nC airmeeme9UntnalPanP Ocy i h osue http://www.norkro.com/dream/?p=1-1209 netn lOhPciPremyar nean http://www.norkro.com/dream/?p=1-3248 7etPg7enr5e http://www.norkro.com/dream/?p=1-40 0.mg9Pnnt http://www.norkro.com/dream/?p=1-7689 r r eehVmnaypiePnCthe http://www.norkro.com/dream/?p=1-7720 ahtmm http://www.norkro.com/dream/?p=1-5300 E http://www.norkro.com/dream/?p=1-4275 phcte ist orNOyenPernBeero imniunrulP http://www.norkro.com/dream/?p=1-6814 B http://www.norkro.com/dream/?p=1-7501 SIdinrrhateothrntTizesn eme a http://www.norkro.com/dream/?p=1-8236 tcieBsin8lrm10ereP t n http://www.norkro.com/dream/?p=1-6527 lraPe ImTrOn0t e e http://www.norkro.com/dream/?p=1-2540 thEeraprnnMmPie eses i http://www.norkro.com/dream/?p=1-7046 Ph Tmo em iiCeoondncehrlnteMri eFOraet http://www.norkro.com/dream/?p=1-1594 tnPmnDst ePhrieeiliil ne http://www.norkro.com/dream/?p=1-4811 e http://www.norkro.com/dream/?p=1-3988 xcreeinssoemPeiLteatMn Ct http://www.norkro.com/dream/?p=1-2667 ce http://www.norkro.com/dream/?p=1-2878 rrDihoenmitterecn Pe http://www.norkro.com/dream/?p=1-26 e http://www.norkro.com/dream/?p=1-7088 Gh ne http://www.norkro.com/dream/?p=1-8130 ere http://www.norkro.com/dream/?p=1-5982 ent oiPraiinfoemcfnlarmO Ii http://www.norkro.com/dream/?p=1-5662 ieaimSrIorirl http://www.norkro.com/dream/?p=1-7210 eryLsTgienen http://www.norkro.com/dream/?p=1-8587 tPPCirme h oYyn http://www.norkro.com/dream/?p=1-8377 eeeiPxSrun http://www.norkro.com/dream/?p=1-5361 rhalWni b inAnTe http://www.norkro.com/dream/?p=1-4875 h http://www.norkro.com/dream/?p=1-4226 t RrrteiBihmexguVa ned http://www.norkro.com/dream/?p=1-3298 gniaadP http://www.norkro.com/dream/?p=1-5425 huriteP http://www.norkro.com/dream/?p=1-1269 tHenid P http://www.norkro.com/dream/?p=1-7966 He http://www.norkro.com/dream/?p=1-1676 ropndseeptee http://www.norkro.com/dream/?p=1-5877 eeOaancmmriePt Prhy nnh http://www.norkro.com/dream/?p=1-4736 etrnltiOee Phm iiiiooucrhnpWnnPret http://www.norkro.com/dream/?p=1-2336 e http://www.norkro.com/dream/?p=1-5018 nainchorPehe disiengtie MtWes mL http://www.norkro.com/dream/?p=1-3942 nmrNetoeheae piSepsrChrcnpi http://www.norkro.com/dream/?p=1-1923 rmnPoeEFeoehir http://www.norkro.com/dream/?p=1-1981 e http://www.norkro.com/dream/?p=1-5517 CmleiyrOeinP ednn ameh http://www.norkro.com/dream/?p=1-1646 TPih rP http://www.norkro.com/dream/?p=1-8252 irBe neieh xdn http://www.norkro.com/dream/?p=1-1545 eCcis t ne http://www.norkro.com/dream/?p=1-8250 GnmmUPn http://www.norkro.com/dream/?p=1-8119 PcneOisFeetotram a Pihlhynane http://www.norkro.com/dream/?p=1-2899 Se neentenltmth srDsio http://www.norkro.com/dream/?p=1-6820 ieveAi etmedcl ertieanMrnntnihP http://www.norkro.com/dream/?p=1-7823 nPeehm otCc eerBiM no http://www.norkro.com/dream/?p=1-73 ygAmemIetmPDdLer eriisyrlsi http://www.norkro.com/dream/?p=1-6641 heot0miD http://www.norkro.com/dream/?p=1-8573 eipiem sai http://www.norkro.com/dream/?p=1-5050 eb ihleewnPramvReH http://www.norkro.com/dream/?p=1-2502 mie3e7rnO http://www.norkro.com/dream/?p=1-6355 hxnrnte http://www.norkro.com/dream/?p=1-7200 epnenrh eepdhmhMar Piiinetles t http://www.norkro.com/dream/?p=1-7234 mo iirete nnRW hNet http://www.norkro.com/dream/?p=1-363 iiscPre http://www.norkro.com/dream/?p=1-719 Bhtmyr unfei reHneP http://www.norkro.com/dream/?p=1-5191 iPhtlePae mnietnDrn e http://www.norkro.com/dream/?p=1-2997 pr emnPd http://www.norkro.com/dream/?p=1-7766 hmeehp http://www.norkro.com/dream/?p=1-7357 o50d http://www.norkro.com/dream/?p=1-7592 PetaeZ elHnnit http://www.norkro.com/dream/?p=1-1166 tm http://www.norkro.com/dream/?p=1-5606 rhBh nm tuPuytge oertnc http://www.norkro.com/dream/?p=1-2465 oerhn http://www.norkro.com/dream/?p=1-6600 9rn n PDareapeetO http://www.norkro.com/dream/?p=1-3371 eDSerrhvCtomr aP leeytnuaiid nd http://www.norkro.com/dream/?p=1-7099 asneyrhi http://www.norkro.com/dream/?p=1-5527 uCltByyPa hiPnnnretenh erOmi http://www.norkro.com/dream/?p=1-651 Ounyen http://www.norkro.com/dream/?p=1-8037 PrttLm http://www.norkro.com/dream/?p=1-5723 tFie seo mhtP http://www.norkro.com/dream/?p=1-6547 iynr http://www.norkro.com/dream/?p=1-6297 imhDteirB lePl ete iRnelHbrewPts ven aei http://www.norkro.com/dream/?p=1-4973 ePDtr othn http://www.norkro.com/dream/?p=1-6255 tKh e http://www.norkro.com/dream/?p=1-3360 tnProe tyD ehietoioDiOcktCm m arlan http://www.norkro.com/dream/?p=1-5334 eeim rrsnhtPbieePrc http://www.norkro.com/dream/?p=1-3413 tanmch http://www.norkro.com/dream/?p=1-6623 elinOe http://www.norkro.com/dream/?p=1-7901 eno http://www.norkro.com/dream/?p=1-7951 mhnir e http://www.norkro.com/dream/?p=1-4324 rW http://www.norkro.com/dream/?p=1-3597 t.7mre35 enPhen http://www.norkro.com/dream/?p=1-6479 rn tntreeCeDiesn iPe http://www.norkro.com/dream/?p=1-5400 teaPheSme uDiynrBten http://www.norkro.com/dream/?p=1-3270 rmaeitl nFe nPiPere http://www.norkro.com/dream/?p=1-492 B unrrhryt iePeeonmnN hpeR http://www.norkro.com/dream/?p=1-785 e3eg.as7 http://www.norkro.com/dream/?p=1-8351 reehEacgeiSntcPeent hnir http://www.norkro.com/dream/?p=1-7734 eorp cPnPreiR rerqheNtnn http://www.norkro.com/dream/?p=1-2055 eWm roLr http://www.norkro.com/dream/?p=1-3389 n http://www.norkro.com/dream/?p=1-1403 m Sha nvPo yCteryrB http://www.norkro.com/dream/?p=1-6033 unBenmytrP http://www.norkro.com/dream/?p=1-2828 i Vi MBnueamiircrd http://www.norkro.com/dream/?p=1-5700 LeHonRreltnhm ym http://www.norkro.com/dream/?p=1-3357 Pfmnei et http://www.norkro.com/dream/?p=1-4845 SroIedOhnPAni tnemre idd ne http://www.norkro.com/dream/?p=1-7189 tnemnPWgeor intuOipie itvrrhcrsPhe t http://www.norkro.com/dream/?p=1-1472 Puiimnte rnen porq rsrPRecthee http://www.norkro.com/dream/?p=1-2194 SrQehin http://www.norkro.com/dream/?p=1-3792 ieIed in http://www.norkro.com/dream/?p=1-6211 hP http://www.norkro.com/dream/?p=1-1004 ptesamio eCutner http://www.norkro.com/dream/?p=1-5445 inopttc http://www.norkro.com/dream/?p=1-3970 nehetuiimrHP g http://www.norkro.com/dream/?p=1-4296 imoh nnte hPAO http://www.norkro.com/dream/?p=1-2549 ho ernnrieoti P l http://www.norkro.com/dream/?p=1-2378 aehnrhaienm Pmryr oPeccz http://www.norkro.com/dream/?p=1-5069 rrN itnyemhBeoeieru http://www.norkro.com/dream/?p=1-3303 ysn ibtLoO mina lner3 megneP B0unh http://www.norkro.com/dream/?p=1-6756 oi reB yrcPnWuPehm iiop http://www.norkro.com/dream/?p=1-6842 ePbCnaemnei Hlhth er http://www.norkro.com/dream/?p=1-4044 rmmSne iPftmceeCneih http://www.norkro.com/dream/?p=1-2248 FtePemroinmen http://www.norkro.com/dream/?p=1-4648 nepmrnhixAiePt e http://www.norkro.com/dream/?p=1-8361 n http://www.norkro.com/dream/?p=1-7218 nPnDmteIrenrioeet th http://www.norkro.com/dream/?p=1-5199 siepylh nuetma http://www.norkro.com/dream/?p=1-6311 tfurerihemftcOaMuea

Implementation We are now familiar with the requirements

January 31st, 2007

Implementation We are now familiar with the requirements and important design issues of the shopping cart application. It is a good time to walk through the code. This section assumes that the readers are familiar with the WML syntax. Let’s first look at the application screenshots. This will help us in understanding the code better. Import To run the application from your PC, you will have to use a phone simulator. I ant used UP Simulator for testing the application, available from http://developer.phone.com/download/index.html. This is the main page of the application. From here, the existing users can go to the login screen, or new users can register themselves. To register, new users enter their name, user id, password, address, and credit card details. The user will be presented with a series of input forms (one per screen) for entering these details. The above screenshot is the first screen where the user enters their first name. In WML all the input forms cannot be displayed in one screen because of the display size limitations of the mobile devices. If the registration is successful then the following page is displayed, else an error message is displayed. The user can go to the login page, by selecting the Login page link: To login to the site the user enters their user id and password. If the authentication succeeds, then the main page of the application is returned: The adjacent screenshot is the main page of the application. When the user chooses Search they are shown a screen describing the search functionality of the application. The user should select the soft link OK to go to the next screen: The adjacent screenshot is the first input screen of the search menu. Here the user enters the search text, and presses the soft link OK to go to the next screen. Next, the user selects the search criteria and selects OK. Now the search request is sent to the server: The adjacent screenshot displays the search results. The user can select the link to view the details of the item: The above screenshot displays the details of the searched item. The user can either add the item to his cart by selecting the soft link ADD, or can go back to the earlier screen (Search Results) by selecting the soft link BACK. The user can then either view the details of the added item by selecting its link, or can view the contents of the cart by selecting the Display Cart link, or can go to the main page of the application by selecting the soft link HOME: The above screenshot displays the contents in the user’s cart. The user can view the details of an item by selecting the appropriate link. From here, the user can either change the quantity of this item by selecting the soft link CHG, or go back to the earlier (display cart) screen by selecting the BACK soft link: The above page is displayed when the user goes to the check out. From here, the user can either view the shipping address details by selecting the Address Details link, or can view their credit card details by selecting Credit Card Detailslink, or can go to the home page of the application: Page 553
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services

. Open a database connection . Execute SQL

January 31st, 2007

. Open a database connection . Execute SQL commands . Manipulate/display data . Close the database connection To save the overhead of opening and closing of the database connection for each invocation of the PHP program, persistent database connections will be used. Persistent database connections remain open, even after the PHP script that opened the connection has exited. For more details on persistent database connections, refer to Chapter 17. Import ant Persistent connections will be useful only when PHP is configured as a module in the web server. See Chapter 2 for more details. Page 552
Note: If you are looking for cheap and quality provider to host and run your java application check Astra java hosting services

Design Consideration for the Middle Tier In this

January 31st, 2007

Design Consideration for the Middle Tier In this section we will make important design decisions and set guidelines that will be followed by all the application’s PHP scripts. Authentication The user, when entering the site, enters their user id and password. The PHP script verifies the user id and password, and, depending on the result, allows the user to use the application. After this, the user need not specify their user id and password again. The HTTP protocol is a stateless protocol, which means that for each browser request a new network connection is opened with the web server. The PHP script (running on the web server) should have a mechanism to identify the user from the request. The shopping cart application will use PHP sessions to implement the authentication mechanism. The application will create a PHP session after the user is authenticated. The user id and the isAuthenticated flag will be stored in the PHP session. All the PHP scripts will use the session variable isAuthenticated, to find out if the session is authenticated. The user of the session can be found from the value of session variable $userId. Session Storage One of the requirements of the application was to support multiple instances of the middle tier. This would require additional load balancing software that would distribute HTTP requests (depending on the load balancing policy) to different middle tier servers. Now the deployment scenario will look something like this: With the above deployment scenario, requests of a session might get forwarded to different middle tier servers. This would require the sessions to be shared across all the middle tier servers. The default session implementation of PHP does not allow session sharing between multiple PHP instances running on different machines. We will implement session handlers to store and retrieve session data from the back-end database. With these session handler functions, middle tier instances running on different machines will be able to share PHP sessions. This scheme of storing sessions in the database provides additional reliability, which means that the user will be able to access the application even if one of the middle tier instances goes down. WML Issues The application implementation will follow the following guidelines to take care of WML device constraints (small display size, navigational difficulty). A WML introduction has been provided along with the code which can be downloaded from the Wrox web site at http://www.wrox.com/: . Only relevant information, with links to get the details, will be displayed in the first card of the WML page. For example, in the first card of the search results page only the titles of the searched items will be displayed as links pointing to another card in the same page. The user can select the link to get the details of the item. . Only three items will be displayed per WML page. A link will be provided to view next items. For example, if there are ten transactions in a user’s account, then the view account details page will display only the first three transactions in the first page and will provide a link View Next Items (pointing back to the server), to view the remaining transactions. . A HOME link, pointing to the main page of the application, will be provided in all the WML cards. The user can select the HOME link anytime for going to the main page of the application. This way the user will have to traverse only two links to access any functionality. The WML page is of mime type text/vnd.wap.wml, so all the PHP scripts will send the Content-Type: text/vnd.wap.wml HTTP header. Performance Most PHP programs that access a back-end database will do the following tasks: Page 551
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

itemType VARCHAR(20) NOT NULL, title VARCHAR(60) NOT NULL,

January 31st, 2007

itemType VARCHAR(20) NOT NULL, title VARCHAR(60) NOT NULL, artist VARCHAR(60) NOT NULL, price FLOAT NOT NULL, PRIMARY KEY(itemNo)); CREATE TABLE Transaction ( orderNo INT NOT NULL PRIMARY KEY AUTO_INCREMENT, userId VARCHAR(20) NOT NULL, itemNo VARCHAR(20) NOT NULL, quantity INT NOT NULL DEFAULT 0, date DATE NOT NULL, status VARCHAR(20) NOT NULL); CREATE TABLE Session ( lastAccessed TIMESTAMP, id VARCHAR(255) NOT NULL, data TEXT, PRIMARY KEY(id)); Indices Indices are created on the ItemNo, Title, and Author/Artist columns of the BookShopand MusicShoptables. Creation of indices on these columns will result in faster searches in the database. Import Indices are used to find rows with a specific value for a column quickly. The ant index stores the mapping between the value of the column, and the physical location of the row. Without indices the database will have to do a complete scan of the table (lots of disk I/O), to search for rows with specific values for a column. SQL commands for creating indices (shopindices.sql): USE shop; CREATE INDEX indexOnBookItemNo ON BookShop(itemNo); CREATE INDEX indexOnBookTitle ON BookShop(title); CREATE INDEX indexOnBookAuthor ON BookShop(author); CREATE INDEX indexOnMusicItemNo ON MusicShop(itemNo); CREATE INDEX indexOnMusicTitle ON MusicShop(title); CREATE INDEX indexOnMusicArtist ON MusicShop(artist); Page 550
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

In our case, the database and the middle

January 31st, 2007

In our case, the database and the middle tier will be hosted on different machines. So, grant all privileges on all objects in the shop database to user PHP, connecting from any machine: mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO ‘PHP@%’ IDENTIFIED BY “PHP”; Execute the following SQL script (shop.sql) at the command prompt to create the shopdatabase and tables: mysql < shop.sql CREATE DATABASE IF NOT EXISTS shop; USE shop; CREATE TABLE UserProfile ( fname VARCHAR(32) NOT NULL, lname VARCHAR(32) NOT NULL, userId VARCHAR(16) NOT NULL, password VARCHAR(16) NOT NULL, address VARCHAR(128) NOT NULL, city VARCHAR(64) NOT NULL, country VARCHAR(16) NOT NULL, zipCode VARCHAR(8) NOT NULL, gender VARCHAR(8) NOT NULL, age INTEGER NOT NULL, emailId VARCHAR(64) NOT NULL, phoneNumber VARCHAR(16) NOT NULL, cardNo VARCHAR(16) NOT NULL, expiryDate DATE NOT NULL, cardType VARCHAR(16) NOT NULL, accountBalance FLOAT NOT NULL, PRIMARY KEY(userId)); CREATE TABLE BookShop ( itemNo VARCHAR(20) NOT NULL, itemType VARCHAR(20) NOT NULL, title VARCHAR(60) NOT NULL, author VARCHAR(60) NOT NULL, price FLOAT NOT NULL, PRIMARY KEY(itemNo)); CREATE TABLE MusicShop ( itemNo VARCHAR(20) NOT NULL, Page 549
Quick Hint: If you are looking for best quality webspace to host and run your tomcat application check Vision tomcat hosting services

Column Name Description Author Author of the book

January 31st, 2007

Column Name Description Author Author of the book Price Price of the book The MusicShop table contains the description of available music titles: Column Name Description ItemNo Unique identifier for the music album ItemType CD/Cassette Title Title of the album Artist Artist Price Price of the album The Transaction table contains the records of user’s transactions: Column Name Description OrderNo Unique identifier for the user’s transaction. UserId User id of the user. ItemNo Unique identifier identifying the item. There must be a corresponding row for this item in either MusicShopor BookShop table. Quantity Number of ItemNo items ordered by the user. Date Date when the user did the transaction. Status Status of the item shipped/pending. The Session table, stores the data of PHP sessions: Column Name Description lastAccessed Time when the session was last accessed Id Unique session identifier Data Session data Database User One database user, PHP, is created for the shopping cart application. All the PHP scripts in the middle tier connect to the back-end database as user PHP. This user has all privileges on the tables of the shopping cart application. We need SQL commands for granting privileges on the tables in the shop database to the user PHP. To do so, execute the following SQL statement. The mysqlutility can be used for executing SQL commands. mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON shop.* TO ‘PHP@localhost’ IDENTIFIED BY “PHP”; Page 548
Hint: If you are looking for good and high quality web space to host and run your java application check Vision java web hosting services

Design of the Database Schema In this section

January 31st, 2007

Design of the Database Schema In this section we will create the database schema of the application. The application’s data (tables and indices) will be stored in a separate database (shop). Generally all the schema objects related to an application should be stored in a separate database/table space. It helps in easy management of related database objects. For example, to back up the data of the shopping cart application, the database administrator has to back up only one database (shop). Database Tables The following tables will be created in the shop database: . UserProfile . BookShop . MusicShop . Transaction . Session The UserProfile table contains user information: Column Name Description Fname First name of the user Lname Last name of the user UserId Unique user id Password Encrypted password of the user Address Street address City City Country Country ZipCode Zip code Gender Male/Female Age User’s age Emailed User’s e-mail address PhoneNumber Phone number of the user CardNo User’s credit card number ExpiryDate Expiry date of the credit card CardType User’s credit card type Master/Visa AccountBalance Balance in the user’s account The BookShop table contains the description of available book titles: Column Name Description Itemno Unique identifier for the book Itemtype Book type Title Title of the book Page 547

Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Sandzak.com j2ee web hosting services

a scripting solution is preferred over servlets and

January 31st, 2007

a scripting solution is preferred over servlets and CGI programs. . PHP provides APIs for accessing a large set of databases, and supports features like persistent database connections, and sessions. These features will be heavily used in the middle tier. Page 546
Note: If you are looking for cheap and inexpensive provider to host and run your tomcat application check professional tomcat hosting services

Choosing Software The requirements of the application call

January 31st, 2007

Choosing Software The requirements of the application call for the application to be web-based, with a WML front-end. The application will require a back-end database to store user profiles, user transactions, and the list of music/book titles available at the site. The application will also have a middle tier (the web server plus scripts which are executed by the server), to process the application requests sent from the browser. The browser will send WAP (Wireless Access Protocol) requests to the WAP gateway, which in turn will forward the request to the middle tier using HTTP. The middle tier will get the data from the back-end database, do some processing on the data, and send the reply back to the WAP gateway, which in turn will send the data back to the client browser using the WAP protocol: Import ant A WAP gateway is software that acts as a bridge between a network that supports WAP protocol and Internet Protocol (IP) network. Alternatives for the Back-End Database The back-end database stores the following data: . Information about registered users . Book and music titles available at the site . Record of transactions carried out by users We have two alternatives for storing the above listed information: . Flat files . Relational databases like Oracle, MySQL, or Sybase Flat files are ruled out, because that would lead to implementing lots of functionality, like designing the layout so that the data can be manipulated later, and designing a simple interface for accessing the data from files. This functionality is already available in relational databases. We have chosen MySQL as our back-end database. The reasons for this include: . MySQL is an open source relational database, so it has a cost advantage over other commercial databases . MySQL is highly scalable and easy to administer . MySQL supports client APIs for a large set of programming languages (like Perl, C, and PHP), so it gives more choice of programming languages for implementing the middle tier Alternatives for the Middle Tier The middle tier will generate WML pages dynamically, using the data available in the back-end database. For example, to display the book titles available at the site, the middle tier will get the list of books from the back-end database, and will generate a WML page containing the list of books. The following are the alternatives for implementing the middle tier: . Common Gateway Interface (CGI) programs written in Perl/C. These programs can access the back-end database using the database’s language APIs. . Servlets, written in Java. Servlets can access the back-end database using Java’s SQL APIs and the database’s JDBC driver. JDBC drivers are available for almost all databases. . Server-side scripting language like PHP, JavaServer Pages (JSP), and Active Server Pages (ASP). These languages support APIs for accessing almost all relational databases. PHP is chosen for implementing the middle tier for the following reasons: . PHP is available on a large set of platforms (Linux, UNIX, and Windows NT) and a variety of web servers (Apache and IIS). Therefore, we get a choice of platform and web server for hosting the middle tier. . Performance is one of the implicit requirements for any web-based application, so Page 545
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check professional servlet hosting services