Installing the JDBC Driver

Unpacking a WAR File Manually WAR files are act ually ZI P- form at archives t hat can be unpacked using j ar, WinZip, or any ot her t ool t hat underst ands ZI P files. However, when unpacking a WAR file m anually, youll need t o creat e it s t op- level direct ory first . The following sequence of st eps show s one w ay t o do t his, using t he j ar ut ilit y t o unpack a WAR file nam ed m cb.war t hat is assum ed t o be locat ed in Tom cat s webapps direct ory. For Unix, change locat ion t o t he webapps direct ory, t hen issue t he following com m ands: mkdir mcb cd mcb jar xf ..mcb.war For Windows, t he com m ands are only slight ly different : C:\ mkdir mcb C:\ cd mcb C:\ jar xf ..\mcb.war Unpacking t he WAR file in t he webapps direct ory creat es a new applicat ion cont ext , so youll need t o rest art Tom cat before it not ices t he new applicat ion.

16.4.5 Installing the JDBC Driver

The JSP pages in t he mcb applicat ion need a JDBC driver for connect ing t o t he cookbook dat abase. The following inst ruct ions describe how t o inst all t he MySQL Connect or J driver; t he inst allat ion procedure for ot her drivers should be sim ilar. To inst all MySQL Connect or J for use by Tom cat applicat ions, place a copy of it in Tom cat s direct ory t ree. Assum ing t hat t he driver is packaged as a JAR file as is t he case for MySQL Connect or J , t here are t hree likely places under t he Tom cat root direct ory where you can inst all it , depending on how visible you want t he driver t o be: • To m ake t he driver available only t o t he mcb applicat ion, place it in t he m cb WEB- I NF lib direct ory under Tom cat s webapps direct ory. • To m ake t he driver available t o all Tom cat applicat ions but not t o Tom cat it self, place it in t he lib direct ory under t he Tom cat root . • To m ake t he driver available bot h t o applicat ions and t o Tom cat , place it in t he com m on lib direct ory under t he Tom cat root . I recom m end inst alling a copy of t he driver in t he com m on lib direct ory. That gives it t he m ost global visibilit y it will be accessible bot h by Tom cat and by applicat ions , and youll need t o inst all it only once. I f you enable t he driver only for t he mcb applicat ion by placing a copy in m cb WEB- I NF lib, but t hen develop ot her applicat ions t hat use MySQL, youll need t o eit her copy t he driver int o t hose applicat ions or m ove it t o a m ore global locat ion. Making t he driver m ore globally accessible also is useful if you t hink it likely t hat at som e point youll elect t o use JDBC- based session m anagem ent or realm aut hent icat ion. Those act ivit ies are handled by Tom cat it self above t he applicat ion level, so Tom cat needs access t o t he driver t o carry t hem out . Heres an exam ple inst allat ion procedure for Unix, assum ing t hat t he MySQL Connect or J driver and Tom cat are locat ed at src Java m ysql- connect or- j ava- bin.j ar and usr local j akart a- t om cat . The com m and t o inst all t he driver would look like t his: cp srcJavamysql-connector-java-bin.jar usrlocaljakarta- tomcatcommonlib For Windows, if t he com ponent s are inst alled at D: \ m ysql- connect or-j ava-bin.j ar and D: \ j akart a- t om cat , t he com m and looks like t his: C:\ copy D:\mysql-connector-java-bin.jar D:\jakarta-tomcat\common\lib Aft er inst alling t he driver, rest art Tom cat and t hen request t he following mcb applicat ion page t o verify t hat Tom cat can find t he JDBC driver properly: ht t p: t om cat .snake.net : 8080 m cb j dbc_t est .j sp You m ay need t o edit j dbc_t est .j sp first t o change t he connect ion param et ers.

16.4.6 Installing the JSTL Distribution