From da26e33bb207a7accaf8ca2eb357614022e68150 Mon Sep 17 00:00:00 2001 From: Jim Infield Date: Thu, 1 Jan 2009 12:00:00 -0600 Subject: [PATCH] import of old work --- Connections/jimi.jsp | 12 + First.gif | Bin 0 -> 128 bytes Last.gif | Bin 0 -> 93 bytes Next.gif | Bin 0 -> 67 bytes Previous.gif | Bin 0 -> 67 bytes WEB-INF/classes/addressBeans.jar | Bin 0 -> 1984 bytes .../beans/AddressDataBean.class | Bin 0 -> 1572 bytes .../beans/AddressListBean.class | Bin 0 -> 1285 bytes .../servlets/ConnectionListener.class | Bin 0 -> 846 bytes .../servlets/DetailQueryServlet.class | Bin 0 -> 3606 bytes .../servlets/FilterQueryServlet.class | Bin 0 -> 4707 bytes .../servlets/ListQueryServlet.class | Bin 0 -> 4890 bytes .../test/RequestTestServlet.class | Bin 0 -> 1780 bytes WEB-INF/code/AddressDataBean.java | 117 ++++++++ WEB-INF/code/AddressListBean.java | 77 +++++ WEB-INF/code/ConnectionListener.java | 45 +++ WEB-INF/code/DetailQueryServlet.java | 128 +++++++++ WEB-INF/code/DetailUpdateServlet.java | 76 +++++ WEB-INF/code/FilterQueryServlet.java | 162 +++++++++++ WEB-INF/code/ListQueryServlet.java | 191 +++++++++++++ WEB-INF/code/junk/AddressDataBean.java | 107 +++++++ WEB-INF/code/junk/DataQueryBean.java | 152 ++++++++++ WEB-INF/code/junk/DataQueryServlet.java | 34 +++ WEB-INF/code/junk/ListDataBean.java | 90 ++++++ WEB-INF/code/junk/LoginServlet.java | 33 +++ WEB-INF/code/junk/RequestTestServlet.java | 39 +++ WEB-INF/code/junk/ServerInfoServlet.java | 10 + WEB-INF/web.xml | 129 +++++++++ addressData.jsp | 161 +++++++++++ addressList.jsp | 67 +++++ checklogin.jsp | 9 + endSession.jsp | 14 + images/750px.png | Bin 0 -> 359 bytes images/766px.png | Bin 0 -> 1572 bytes include/pageHeader.jsp | 13 + index.jsp | 1 + login.jsp | 25 ++ oldAddressList.jsp | 52 ++++ style/common.css | 94 ++++++ style/old.css | 185 ++++++++++++ test-1.jsp | 269 ++++++++++++++++++ test-2.jsp | 139 +++++++++ test.html | 178 ++++++++++++ testpage.jsp | 52 ++++ 44 files changed, 2661 insertions(+) create mode 100644 Connections/jimi.jsp create mode 100644 First.gif create mode 100644 Last.gif create mode 100644 Next.gif create mode 100644 Previous.gif create mode 100644 WEB-INF/classes/addressBeans.jar create mode 100644 WEB-INF/classes/com/bullseyecomputing/beans/AddressDataBean.class create mode 100644 WEB-INF/classes/com/bullseyecomputing/beans/AddressListBean.class create mode 100644 WEB-INF/classes/com/bullseyecomputing/servlets/ConnectionListener.class create mode 100644 WEB-INF/classes/com/bullseyecomputing/servlets/DetailQueryServlet.class create mode 100644 WEB-INF/classes/com/bullseyecomputing/servlets/FilterQueryServlet.class create mode 100644 WEB-INF/classes/com/bullseyecomputing/servlets/ListQueryServlet.class create mode 100644 WEB-INF/classes/com/bullseyecomputing/test/RequestTestServlet.class create mode 100644 WEB-INF/code/AddressDataBean.java create mode 100644 WEB-INF/code/AddressListBean.java create mode 100644 WEB-INF/code/ConnectionListener.java create mode 100644 WEB-INF/code/DetailQueryServlet.java create mode 100644 WEB-INF/code/DetailUpdateServlet.java create mode 100644 WEB-INF/code/FilterQueryServlet.java create mode 100644 WEB-INF/code/ListQueryServlet.java create mode 100644 WEB-INF/code/junk/AddressDataBean.java create mode 100644 WEB-INF/code/junk/DataQueryBean.java create mode 100644 WEB-INF/code/junk/DataQueryServlet.java create mode 100644 WEB-INF/code/junk/ListDataBean.java create mode 100644 WEB-INF/code/junk/LoginServlet.java create mode 100644 WEB-INF/code/junk/RequestTestServlet.java create mode 100644 WEB-INF/code/junk/ServerInfoServlet.java create mode 100644 WEB-INF/web.xml create mode 100644 addressData.jsp create mode 100644 addressList.jsp create mode 100644 checklogin.jsp create mode 100644 endSession.jsp create mode 100644 images/750px.png create mode 100644 images/766px.png create mode 100644 include/pageHeader.jsp create mode 100644 index.jsp create mode 100644 login.jsp create mode 100644 oldAddressList.jsp create mode 100644 style/common.css create mode 100644 style/old.css create mode 100644 test-1.jsp create mode 100644 test-2.jsp create mode 100644 test.html create mode 100644 testpage.jsp diff --git a/Connections/jimi.jsp b/Connections/jimi.jsp new file mode 100644 index 0000000..2a631e8 --- /dev/null +++ b/Connections/jimi.jsp @@ -0,0 +1,12 @@ +<% +// FileName="Connection_jdbc_conn.htm" +// Type="JDBC" "" +// DesigntimeType="JDBC" +// HTTP="true" +// Catalog="" +// Schema="" +String MM_jimi_DRIVER = "org.postgresql.Driver"; +String MM_jimi_USERNAME = "guest"; +String MM_jimi_PASSWORD = ""; +String MM_jimi_STRING = "jdbc:postgresql:jimi"; +%> diff --git a/First.gif b/First.gif new file mode 100644 index 0000000000000000000000000000000000000000..a2ff24ff421c84944d7f616be973488d19b3014c GIT binary patch literal 128 zcmZ?wbhEHb6k_0I*v!Ddke0T0@817J1I3>#j0_Bn3_3uq3?MTYSac0ecxtmQNSb?i sUW9t3s!R;l0EtCM*Z=?k literal 0 HcmV?d00001 diff --git a/Last.gif b/Last.gif new file mode 100644 index 0000000000000000000000000000000000000000..b1419f67bde8ba194cc17bf15e683a87f92d36a1 GIT binary patch literal 93 zcmZ?wbhEHb6k_0In8?7ul%CF*p3ab#_W%EX#h)y!A`Hw7It)Mnl4oGjo73N^bn+fs vciK9OOgsO){L0X46I9cd$#ORM?Dku0ef$v5Bg1zevmY?TiMY5jGFSru+3g+l literal 0 HcmV?d00001 diff --git a/Next.gif b/Next.gif new file mode 100644 index 0000000000000000000000000000000000000000..2b35f5bbd485329ed738a1b0f815dc6903694c19 GIT binary patch literal 67 zcmZ?wbhEHbbe@5RzpESwUr zC67r}|mAzQ$YgXzN zvPjRnKXrC$d+PL~iIpiAle_0}Xt6DR{PW1qS+v#nXsY+n;X^zdgPE^YPRFj)rW$Yq<9!(<_V0Wl!gqs#Y|AIjdTKv-q1qWaH-U zbu&^X*LMA@%s%|LX4~Ai@fHRD4ktyQTfWwI#<|4{ZMZ6SKRc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 HcmV?d00001 diff --git a/WEB-INF/classes/com/bullseyecomputing/beans/AddressListBean.class b/WEB-INF/classes/com/bullseyecomputing/beans/AddressListBean.class new file mode 100644 index 0000000000000000000000000000000000000000..254125b2165bacc7213ec0749512f16e6b7aa7a4 GIT binary patch literal 1285 zcmZvaUuzRV6vgjsve{%4O{}R}wQ5tX`O|j&Q$bJ*wa}u3Dzx;$w@osHEt^fqPK5fY z6coV+KY$-fJa@KjWI8YB-no1BcjjjE=kKrIl%oxL?vqcg5|yaU(qUO=*si1}KN%%Po;xHKohiV!n!&idxNjQ>%3aOe(sc`N`>Qs=Ms!(C> zeTgRh@c^AWiD&5+oUfxKQrm)Z&DJseyZULh8znLeItqI+{N+@tcNf`<&CB8ZdU^Q2 ztKMu~w&4;$9q4O%uxDKfGc2L+T*CCcXYa0FfxTH*)Ly+$QCoHEWBTcQJ0J6l1N%Q_ z+p_h#B>pf`)-RGv!olbOQj2znr;fq@oOn}4?ty%X72w1Q9U6Ol&_$DwmLQCEcOid1+_MVyvV1*+TrN#YwCK{udrpbMCSooj1`9pjY9)XGP~t^ct-9?P%9T zcYt1p|A7_ln&<%56+60MqPKv40e{1aE|}<-u&&zCo{4?~^fvqtt!U3g@4))VjxL($ WJ)rmDU$df%Ci*?BkMXZ@sQC~5E3vZx literal 0 HcmV?d00001 diff --git a/WEB-INF/classes/com/bullseyecomputing/servlets/ConnectionListener.class b/WEB-INF/classes/com/bullseyecomputing/servlets/ConnectionListener.class new file mode 100644 index 0000000000000000000000000000000000000000..8e1448f5238591e61e95b716e12398216c99266e GIT binary patch literal 846 zcmah{!EVz)5PfSWahf_Lv`v$yNlTzDNuXGqi;!qk#32+_0S?@3XH{IB-C(by@0=`znxvp*B2oXRZ@}44pw%K42(32}GctGBmn3GJ0z)r8f5#C&&G?Gc=^XGv!QC~P12C?FTM~`%`Hf(fkl(1~!u8n)xp($iT z7@Z7{&V4@B)3LFunS1CkJoe?p@sco%`6o{CG*RT_%4vLUcvp`xR8!T^CEh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AuYO1p_QNswa|!WB|lzxw#W45{L7JM$sN=K zX!3+v%KJ|yx-`9^V%gmpfOnJMmMu)!774`iMcb9Qj$WpF00{cgBZO!Zjp>0xw1>EB z=*w%d^a8|L8VK|fZT2VE5~Vi`BL3EsBpRi)bh={!k#u?DXSu74$AouBu>l1aDwXHmXN2VIZAM zl5trzom|V`mUMC*f8)BUx9IWnSf5Q?z?$QFVgVbnQIglA6>Myxhf^|}@Rh966aG>3 z=sa`=x+(;^+6U@LZmQrKvVw3nA78+=SxwiHsd-$dw-6a6W(za%khz|j1T&1TYxB6F zf~^tgY6aT_vN1gtPTokM&3bbMZ33eg&`#j#Y^&a?Ht_1(i}-7cV$<~xM% ztXAJySzf2OcO<(i*i{povlPyL6k${FKN8Q07w8+L+RI2&;5#TqZh?kdDP4AA3vNdS zSsLx4zulCQdq}z)qm;Kf;%rKm(=_ua{lE1ThVU#7(<5&LFX0G12an<{9HU3qUHAxh z<6k(5f5X6kP!KVUi}jcgTVRR|CdDq?EBa6rqnHvBmT+NO;*l{SMZ=X ZhtuLB9`aMPnND&LpCRk}$?gaS{s&gz;eY@D literal 0 HcmV?d00001 diff --git a/WEB-INF/classes/com/bullseyecomputing/servlets/FilterQueryServlet.class b/WEB-INF/classes/com/bullseyecomputing/servlets/FilterQueryServlet.class new file mode 100644 index 0000000000000000000000000000000000000000..7402166cf4ec9ee91822ec5fec9d8146e8f77b2b GIT binary patch literal 4707 zcmaJ@S$I>|5&o|&>0V1$_OZOm`;K>E)*!PRFiy;7FjSDx%JRhsWJ!^(!4OiKP?9zz zX$wiq(j`qxXlc_nCg8f{>ubNSee7Fb`_`Af_MuTlLOea~h6`uhaN=bqUtu`Q@O6f7FoYS#7$OYg zENt=YoCgy)Zy@Ty1zhwXhDif)CK3jc9=wW_je~ix^7xj4w|Ts5;5#0C7w_Z)U;dlnKRRydcvpiS zNyKey+SX7vd?9=(JRL||sY@}-4jj*n0~vn526s3XI~ulaD;3vJKAcER1j5O170>6B5i=lYhPEA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R1A}P?acZhgn`NOXyZj4HZ5cC~vMX05twS&rDsRj|*@`G(MEsYNy zx;rTnIx@kdkpLk{qwv!`>IHSHmPSOi_&pe+1n8sGBhtdGN3Q{TIM5;iK_!KTYqI@m z|1rw+<+*};G~ehM3WN}YP4{U!XS>84pTOxd16Qtf><#=5p$8+q!B^8~3Lw#sUVzks z?^tSO2!16}Ytrl>>gf%EaC|$&78(eosIBpdP1Mpul7ukpxzvZKZ;iKYhZK(wL*9l^ zTn`VUrfbd)D659hur&TCLVE28A`-pq=`{`m2SP21ol1g%{Sd}f)RFFHOrzE5Xu+Yd zXeC5^J@o6v+CXXeI-*Ucg~m2{1W^e~+jnD1o34$ZPC~NAsA-!sf_nNc(;G(6DB&qI zB|}DNHqWwl_1pCPtLSr)G zdtvxq7@=WIWiba7#T@91Y10oH!NFuhq)nd|jG}FNEEs75s8R2a z%J&~WwrjkVn(undpfe&k34}36$?FmX_2m#Wv@>)?a2ktPB%6#T{Rq~iQnQLCNAjfB zpVaL_&ZyH{?}N1yN3Eve(c5uMQYWrsnTrnpxZT@WBasWED9*$5iFMI}Z$6T=`$Vk7JgS8!k(BxLkD5ie zjHp-R4BUt%*o;oxi!MBZW!Q@4cmgZ%47%|G?Rp(&(TBx3^qsI;Os4PaX*gHJ=?ms) zoG0cYB^IDZykVMyMH2jrXapnMM= yqVoE%{4_Sp&tr@H3Lcf;#5O{8hx|Ss57pp_Py?RyYjh1E-$Td?tRtKyT<|~7<~5lB literal 0 HcmV?d00001 diff --git a/WEB-INF/classes/com/bullseyecomputing/test/RequestTestServlet.class b/WEB-INF/classes/com/bullseyecomputing/test/RequestTestServlet.class new file mode 100644 index 0000000000000000000000000000000000000000..5428b549591b478a334234df93e71adbc3dfc1d9 GIT binary patch literal 1780 zcma)7>vG#f7(MGGwrYzeb#8Sot!kj;u0psbj!PTTrjRBf2`MR8+1|t|vSg%nCwT{+ zfEQrkAJdt1($4SzJQQ$Na#GV$z(4lWo^QWz&mNtXfB)mjZ|K4-s##pZR1VXaF)*v+ zoB=zFYk1SZTL$J0ylvne1MeDm&%pZzKFDDKi#e3AltmfW_4LCGZe-DqDFZikTsH8L zj@J#W7`UYu-!`zC!JP~~7D$&|-&JLSu8GNAf$rs?CIx!eTwkuY8WkDtI2DgbPc67D zmB7}-+5_jIb7)60eCSDK*OhA8s~olyU`u}Al95{c&t*|F@FTgXcg?OGR%KJU1Ty#} zgEd0iK`X4vTdv-GxZQMzjoaJIX%;3f!^+^UiFIrUoKx~p6KZ%SHu0&z`I4TLv!%Lp zYUOMOTPC)3V#2aY%2l2$w>w*#PUtkGlA)zHDcMOjD{zfVJ=g!v3Z=JHjMR}Qqq>x; zXw^fx-$v|e&}anyTs4Y{0(navHRVzuy+MN6Qkpq?1WkEBi>}GJ! z#OK({;J%43@TG~b@U_5@*4g$P|G?f>q3a*qZ0+yMP@q3)9BL-XW36oB8+F@Yh0vE{T%+J~mkwD>;6ZP}# z6~EPxp`&jcSq;V~em)_P^Ld|EJlP;!fq~Nwu^Bch4`fxbxGyg5zyu5xBwl&GC_!0d zb}|&W`cEn(5_UL`b!n&BlzvTM=6_WrUS(Zx-HGl7p==+9dhm01A6GEWPp6^a*+e)_=mz>NAYjaS<~pU>+mt<8 literal 0 HcmV?d00001 diff --git a/WEB-INF/code/AddressDataBean.java b/WEB-INF/code/AddressDataBean.java new file mode 100644 index 0000000..7b6e80c --- /dev/null +++ b/WEB-INF/code/AddressDataBean.java @@ -0,0 +1,117 @@ +// AddressDataBean.java +// JavaBean for storing and manipulating an address entry. +package com.bullseyecomputing.beans; + +public class AddressDataBean { + private String idNumber; + private String name; + private String street; + private String suite; + private String city; + private String state; + private String zipcode; + private String plus4; + private Phone phone; + private Phone fax; + private String note; + +// idNumber accessor methods + public void setIdNumber(String id) { + idNumber = id; + } + + public String getIdNumber() { + return idNumber; + } + +// name accessor methods + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +// street accessor methods + public void setStreet(String street) { + this.street = street; + } + + public String getStreet() { + return street; + } + +// suite accessor methods + public void setSuite(String suite) { + this.suite = suite; + } + + public String getSuite() { + return suite; + } + +// city accessor methods + public void setCity(String city) { + this.city = city; + } + + public String getCity() { + return city; + } + +// state accessor methods + public void setState(String state) { + this.state = state; + } + + public String getState() { + return state; + } + +// zipcode accessor methods + public void setZipcode(String zip) { + zipcode = zip; + } + + public String getZipcode() { + return zipcode; + } + +// plus4 accessor methods + public void setPlus4(String plus4) { + this.plus4 = plus4; + } + + public String getPlus4() { + return plus4; + } + +// Inner class for phone data + class Phone { + + String type; + String areacode; + String number; + String comment; + } + +// areacode accessor methods + public void setAreacode(String areacode) { + this.areacode = areacode; + } + + public String getAreacode() { + return areacode; + } + +// phone accessor methods + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPhone() { + return phone; + } + +} diff --git a/WEB-INF/code/AddressListBean.java b/WEB-INF/code/AddressListBean.java new file mode 100644 index 0000000..f29d1a4 --- /dev/null +++ b/WEB-INF/code/AddressListBean.java @@ -0,0 +1,77 @@ +// AddressListBean.java +// JavaBean for storing and manipulating address list entries. +package com.bullseyecomputing.beans; + +public class AddressListBean { + private String idNumber; + private String name; + private String street; + private String city; + private String state; + private String zipcode; + private String plus4; + +// idNumber accessor methods + public void setIdNumber(String id) { + idNumber = id; + } + + public String getIdNumber() { + return idNumber; + } + +// name accessor methods + public void setName(String name) { + this.name = name; + } + + public String getName() { + return name; + } + +// street accessor methods + public void setStreet(String street) { + this.street = street; + } + + public String getStreet() { + return street; + } + +// city accessor methods + public void setCity(String city) { + this.city = city; + } + + public String getCity() { + return city; + } + +// state accessor methods + public void setState(String state) { + this.state = state; + } + + public String getState() { + return state; + } + +// zipcode accessor methods + public void setZipcode(String zip) { + zipcode = zip; + } + + public String getZipcode() { + return zipcode; + } + +// plus4 accessor methods + public void setPlus4(String plus4) { + this.plus4 = plus4; + } + + public String getPlus4() { + return plus4; + } + +} diff --git a/WEB-INF/code/ConnectionListener.java b/WEB-INF/code/ConnectionListener.java new file mode 100644 index 0000000..9eed318 --- /dev/null +++ b/WEB-INF/code/ConnectionListener.java @@ -0,0 +1,45 @@ +// ConnectionListener.java +// This object implements the HttpSessionBindingListener interface for the +// purpose of maintaining a persistent database connection throughout the +// scope of a session. When the session becomes unbound, any uncommitted +// transactions are rolled back and the connection is released. + +package com.bullseyecomputing.servlets; + +import java.sql.*; +import javax.servlet.http.*; + +public class ConnectionListener implements HttpSessionBindingListener { + private Connection connection = null; + + public ConnectionListener(Connection conn) { + connection = conn; + try { + connection.setAutoCommit(false); + } + catch(SQLException e) { + // error handler here... + } + } + + public Connection getConnection() { + return connection; + } + + public void valueBound(HttpSessionBindingEvent event) { + // called when the object is added to a session + } + + public void valueUnbound(HttpSessionBindingEvent event) { + // called when the session expires + try { + if(connection != null) { + connection.rollback(); + connection.close(); + } + } + catch(SQLException e) { + // error handler here... + } + } +} diff --git a/WEB-INF/code/DetailQueryServlet.java b/WEB-INF/code/DetailQueryServlet.java new file mode 100644 index 0000000..a366736 --- /dev/null +++ b/WEB-INF/code/DetailQueryServlet.java @@ -0,0 +1,128 @@ +// DetailQueryServlet.java +// This servlet receives an addressee identifier as a request argument, +// and makes the required query/(queries) to retrieve the addressee's +// detail info. This info is loaded into a DataBean that is then stored +// in the session environment. The servlet then redirects to the correct +// JSP for display. + +package com.bullseyecomputing.servlets; + +import java.io.*; +import java.util.*; +import java.sql.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +import com.bullseyecomputing.beans.AddressDataBean; + +public class DetailQueryServlet extends HttpServlet { + + ServletContext context; + + public void init(ServletConfig config) throws ServletException { + super.init(config); + + // Grab a handle to the local context + context = getServletContext(); + + // Get the name of the jdbc driver from an init param + String jdbcDriver = getInitParameter("jdbcDriver"); + // Now try to load the driver + try { + Class.forName(jdbcDriver); + } + catch(ClassNotFoundException e) { + context.log("jdbcDriver: ", e); + } + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + HttpSession session = request.getSession(false); + ConnectionListener dbListener; + Statement transaction; + ResultSet results; + RequestDispatcher dispatcher; + + // Bail if we're not part of a session + if(session == null) { + dispatcher = context.getRequestDispatcher("/index.jsp"); + dispatcher.forward(request, response); + } + + // Look for an existing db connection in the session environment + dbListener = (ConnectionListener) session.getAttribute("dbConnection"); + // Create one if it's not there + if(dbListener == null) { + // Load the params from init + String jdbcURL = getInitParameter("jdbcURL"); + String jdbcUser = getInitParameter("jdbcUser"); + String jdbcPassword = getInitParameter("jdbcPassword"); + // Attempt to make the connection + try { + Connection conn = DriverManager.getConnection(jdbcURL,jdbcUser,jdbcPassword); + dbListener = new ConnectionListener(conn); + // Push the new connection into the session environment + session.setAttribute("dbConnection", dbListener); + } + catch(SQLException e) { + context.log("dbConnection", e); + } + } + + // Grab a local handle to the session's db connection + Connection db = dbListener.getConnection(); + + // Build the query based on init and request parameters + String selected = getInitParameter("selected"); + String table = getInitParameter("table"); + String id = request.getParameter("id"); + + StringBuffer query = new StringBuffer(); + query.append("select ").append(selected); + query.append(" from ").append(table); + query.append(" where id = ").append(id); + // + context.log(query.toString()); + // + + // Execute the query + try { + transaction = db.createStatement(); + results = transaction.executeQuery(query.toString()); + + // move to the first (and only) record + results.next(); + + // Create a DataBean to store the results + AddressDataBean address = new AddressDataBean(); + + // Push the data into the DataBean + address.setIdNumber(Integer.toString(results.getInt(1))); + address.setName(results.getString(2)); + address.setStreet(results.getString(3)); + address.setCity(results.getString(4)); + address.setState(results.getString(5)); + address.setZipcode(results.getString(6)); + address.setPlus4(results.getString(7)); + address.setAreacode(results.getString(8)); + address.setPhone(results.getString(9)); + + // Push the AddressBean into the session environment + session.setAttribute("address.data", address); + + // Close the database transaction + results.close(); + transaction.close(); + } + catch(SQLException e) { + context.log("DetailQueryServlet: Error during SQL transaction", e); + } + + // Forward to the corresponding JSP + dispatcher = request.getRequestDispatcher("addressData.jsp"); + dispatcher.forward(request, response); + } +} diff --git a/WEB-INF/code/DetailUpdateServlet.java b/WEB-INF/code/DetailUpdateServlet.java new file mode 100644 index 0000000..b445c94 --- /dev/null +++ b/WEB-INF/code/DetailUpdateServlet.java @@ -0,0 +1,76 @@ +// DetailUpdateServlet.java +// This servlet receives the contents of the addressData form via HTTP/POST. +// That data is then compared to the data within the AddressDataBean stored +// in the session environment. The fields that have been changed are then +// tagged for update. A sql update statement is then formulated from the tagged +// data fields. + +package com.bullseyecomputing.servlets; + +import java.io.*; +import java.util.*; +import java.sql.*; + +import jacax.servlet.*; +import javax.servlet.http.*; + +import com.bullseyecomputing.beans.AddressDataBean; + +public class DetailUpdateServlet extends HttpServlet { + + ServletContext context; + + public void init(ServletConfig config) throws ServletException { + super.init(config); + + // Grab a handle to the local context + context = getServletContext(); + + // Get the jdbc driver name from an init param + String jdbcDriver = getInitParameter("jdbcDriver:); + + // Attempt to load the jdbc driver + try { + Class.forName(jdbcDriver); + } + catch(ClassNotFoundException e) { + context.log("jdbcDriver: ", e); + } + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + HttpSession session = request.getSession(false): + ConnectionListener dbListener; + Statement transaction; + RequestDispatcher dispatcher; + + // Bail if this is not an existing session + if(session == null) { + dispatcher = request.getRequestDispatcher("/index.jsp"); + dispatcher.forward(request, response); + } + + // get POST parameters + + ////////// + // Check the session environ for an existing db connection + /////////// + dbListener = (ConnectionListener) session.getAttribute("dbConnection"); + if(dbListener == null) { + String jdbcURL = getInitParameter("jdbcURL"); + String jdbcUser = getInitParameter("jdbcUser"); + String jdbcPassword = getInitParameter("jdbcPassword"); + try { + Connection conn = DriverManager.getConnection(jdbcURL,jdbcUser,jdbcPassword); + dbListener = new ConnectionListener(conn); + session.setAttribute("dbConnection:, dbListener); + } + catch(SQLException e) { + context.log("dbConnection: ", e); + } + } + + // Grab a local handle to the connection + Connection db = dbListener.getConnection(); diff --git a/WEB-INF/code/FilterQueryServlet.java b/WEB-INF/code/FilterQueryServlet.java new file mode 100644 index 0000000..dc9e1c2 --- /dev/null +++ b/WEB-INF/code/FilterQueryServlet.java @@ -0,0 +1,162 @@ +// FilterQueryServlet.java +// + +package com.bullseyecomputing.servlets; + +import java.io.*; +import java.util.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +import org.apache.regexp.*; + +public class FilterQueryServlet extends HttpServlet { + + ServletContext context; + private static RE allPattern, statePattern, cityPattern; + private static RE zipcodePattern, limitPattern; + + // Pre-compiled regular expression '^([Aa][Ll][Ll])|\*$' + private static char[] allPatternInstructions = + { + 0x007c, 0x0000, 0x0024, 0x005e, 0x0000, 0x0003, 0x0028, + 0x0001, 0x0003, 0x007c, 0x0000, 0x0018, 0x005b, 0x0002, + 0x0007, 0x0041, 0x0041, 0x0061, 0x0061, 0x005b, 0x0002, + 0x0007, 0x004c, 0x004c, 0x006c, 0x006c, 0x005b, 0x0002, + 0x0007, 0x004c, 0x004c, 0x006c, 0x006c, 0x0029, 0x0001, + 0x000d, 0x007c, 0x0000, 0x000a, 0x0041, 0x0001, 0x0004, + 0x002a, 0x0024, 0x0000, 0x0003, 0x0045, 0x0000, 0x0000, + }; + + + // Pre-compiled regular expression '^[A-Za-z]{2}$' + private static char[] statePatternInstructions = + { + 0x007c, 0x0000, 0x0017, 0x005e, 0x0000, 0x0003, 0x005b, + 0x0002, 0x0007, 0x0041, 0x005a, 0x0061, 0x007a, 0x005b, + 0x0002, 0x0007, 0x0041, 0x005a, 0x0061, 0x007a, 0x0024, + 0x0000, 0x0003, 0x0045, 0x0000, 0x0000, + }; + + // Pre-compiled regular expression '^[A-Za-z\+\.]{4,}$' + private static char[] cityPatternInstructions = + { + 0x007c, 0x0000, 0x004f, 0x005e, 0x0000, 0x0003, 0x005b, + 0x0004, 0x000b, 0x0041, 0x005a, 0x0061, 0x007a, 0x002b, + 0x002b, 0x002e, 0x002e, 0x005b, 0x0004, 0x000b, 0x0041, + 0x005a, 0x0061, 0x007a, 0x002b, 0x002b, 0x002e, 0x002e, + 0x005b, 0x0004, 0x000b, 0x0041, 0x005a, 0x0061, 0x007a, + 0x002b, 0x002b, 0x002e, 0x002e, 0x005b, 0x0004, 0x000b, + 0x0041, 0x005a, 0x0061, 0x007a, 0x002b, 0x002b, 0x002e, + 0x002e, 0x007c, 0x0000, 0x0014, 0x005b, 0x0004, 0x000b, + 0x0041, 0x005a, 0x0061, 0x007a, 0x002b, 0x002b, 0x002e, + 0x002e, 0x007c, 0x0000, 0x0003, 0x0047, 0x0000, 0xffef, + 0x007c, 0x0000, 0x0003, 0x004e, 0x0000, 0x0003, 0x0024, + 0x0000, 0x0003, 0x0045, 0x0000, 0x0000, + }; + + // Pre-compiled regular expression '^[0-9]{3,5}$' + private static char[] zipcodePatternInstructions = + { + 0x007c, 0x0000, 0x0034, 0x005e, 0x0000, 0x0003, 0x005b, + 0x0001, 0x0005, 0x0030, 0x0039, 0x005b, 0x0001, 0x0005, + 0x0030, 0x0039, 0x007c, 0x0000, 0x0008, 0x005b, 0x0001, + 0x0008, 0x0030, 0x0039, 0x007c, 0x0000, 0x0003, 0x004e, + 0x0000, 0x0003, 0x007c, 0x0000, 0x0008, 0x005b, 0x0001, + 0x0008, 0x0030, 0x0039, 0x007c, 0x0000, 0x0003, 0x004e, + 0x0000, 0x0003, 0x005b, 0x0001, 0x0005, 0x0030, 0x0039, + 0x0024, 0x0000, 0x0003, 0x0045, 0x0000, 0x0000, + }; + + // Pre-compiled regular expression '^limit=[0-9]+$' + private static char[] limitPatternInstructions = + { + 0x007c, 0x0000, 0x0023, 0x005e, 0x0000, 0x0003, 0x0041, + 0x0006, 0x0009, 0x006c, 0x0069, 0x006d, 0x0069, 0x0074, + 0x003d, 0x005b, 0x0001, 0x0005, 0x0030, 0x0039, 0x007c, + 0x0000, 0x0006, 0x0047, 0x0000, 0xfff8, 0x007c, 0x0000, + 0x0003, 0x004e, 0x0000, 0x0003, 0x0024, 0x0000, 0x0003, + 0x0045, 0x0000, 0x0000, + }; + + public void init(ServletConfig config) throws ServletException { + super.init(config); + + // Grab a handle to the local context + context = getServletContext(); + + + allPattern = new RE(new REProgram(allPatternInstructions)); + statePattern = new RE(new REProgram(statePatternInstructions)); + cityPattern = new RE(new REProgram(cityPatternInstructions)); + zipcodePattern = new RE(new REProgram(zipcodePatternInstructions)); + limitPattern = new RE(new REProgram(limitPatternInstructions), + RE.MATCH_CASEINDEPENDENT); + + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + RequestDispatcher dispatcher; + HttpSession session = request.getSession(false); + + // bail if we're not part of a session + if(session == null) { + dispatcher = request.getRequestDispatcher("/index.jsp"); + dispatcher.forward(request, response); + } + + // get HTTP args + String query = request.getParameter("filter"); + + String url = ""; + String all = ""; + String state = ""; + String city = ""; + String zipcode = ""; + String limit = ""; + + // tokenize "query" String + context.log(query); + StringTokenizer str = new StringTokenizer(query, ";:, "); + context.log(str.toString()); + while(str.hasMoreTokens()) { + // Grab the next as String + String token = str.nextToken(); + // Check for a match + if(allPattern.match(token)) { + session.removeAttribute("filter"); + all = "true"; + } + if(statePattern.match(token)) { + state = token; + break; + } + if(zipcodePattern.match(token)) { + zipcode = token; + break; + } + if(limitPattern.match(token)) { limit = token; } + if(cityPattern.match(token)) { city = token; } + } + + // Assemble our new filter String + if(all != "true") { + StringBuffer filter = new StringBuffer(); + if(state != "") { + filter.append("state:").append(state).append(":"); + } + if(city != "") { + filter.append("city:").append(city).append(":"); + } + if(zipcode != "") { + filter.append("zipcode:").append(zipcode).append(":"); + } + if(filter.length() != 0) { url += "filter=" + filter + "&"; } + } + if(limit != "") { url += limit + "&"; } + response.sendRedirect("/getList?" + url); + } +} diff --git a/WEB-INF/code/ListQueryServlet.java b/WEB-INF/code/ListQueryServlet.java new file mode 100644 index 0000000..e8f826d --- /dev/null +++ b/WEB-INF/code/ListQueryServlet.java @@ -0,0 +1,191 @@ +// ListQueryServlet.java +// Servlet that will use its request parameters to to generate a +// collection of DataBeans with an SQL query. The SQL connection +// is a persistent part of the HttpSession. + +package com.bullseyecomputing.servlets; + +import java.io.*; +import java.util.*; +import java.sql.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +import com.bullseyecomputing.beans.AddressListBean; + +public class ListQueryServlet extends HttpServlet { + + ServletContext context; + ResultSet results; + + public void init(ServletConfig config) throws ServletException { + super.init(config); + + // Grab a handle to our context + context = getServletContext(); + + // Get the jdbcDriver from an init param, and try to load it + String jdbcDriver = getInitParameter("jdbcDriver"); + try { + Class.forName(jdbcDriver); + } + catch(ClassNotFoundException e) { + context.log("ListQueryServlet: jdbcDriver failure"); + } + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + HttpSession session = request.getSession(false); + ConnectionListener dbSession; + Statement transaction; + RequestDispatcher dispatcher; + + // If we have no session, we're in the wrong place + if(session == null) { + dispatcher = request.getRequestDispatcher("/index.jsp"); + dispatcher.forward(request, response); + } + + // Look in the session environment for our database connection + dbSession = (ConnectionListener) session.getAttribute("dbConnection"); + // Create one if needed + if(dbSession == null) { + String jdbcURL = getInitParameter("jdbcURL"); + String jdbcUser = getInitParameter("jdbcUser"); + String jdbcPassword = getInitParameter("jdbcPassword"); + try { + Connection conn = DriverManager.getConnection(jdbcURL,jdbcUser,jdbcPassword); + dbSession = new ConnectionListener(conn); + session.setAttribute("dbConnection", dbSession); + } + catch(SQLException e) { + context.log("Error creating database connection"); + } + } + + // Get a local handle to the connection stored in the session + Connection db = dbSession.getConnection(); + + // Formulate our query based on init and request parameters + String selected = getInitParameter("selected"); + String table = getInitParameter("table"); + String newFilter = request.getParameter("filter"); + String newOrder = request.getParameter("orderby"); + String newLimit = request.getParameter("limit"); + + if(newFilter != null) { // add error checking for filter value + session.setAttribute("filter", newFilter); + } + if(newOrder != null) { // add error checking for orderby value + String oldOrder = (String) session.getAttribute("orderby"); + String direction = (String) session.getAttribute("direction"); + context.log("oldOrder = "+oldOrder+" "+direction); + + // Set initial orderby values + if(oldOrder == null) { oldOrder = ""; } + if(direction == null) { direction = "asc"; } + + // Toggle direction + if(oldOrder.equals(newOrder)) { + context.log("toggle direction"); + if(direction.equals("asc")) { + direction = "desc"; + } + else { + direction = "asc"; + } + } + else { + context.log("'"+oldOrder+"' != '"+newOrder+"'"); + } + + // Push values into session + session.setAttribute("orderby", newOrder); + session.setAttribute("direction", direction); + context.log("newOrder = "+newOrder+" "+direction); + } + if(newLimit != null) { // add error checking for limit value + session.setAttribute("limit", newLimit); + } + + // Get values from session + String filter = (String) session.getAttribute("filter"); + String orderby = (String) session.getAttribute("orderby"); + String direction = (String) session.getAttribute("direction"); + String limit = (String) session.getAttribute("limit"); + + StringBuffer query = new StringBuffer(); + query.append("select ").append(selected); + query.append(" from ").append(table); + + if(filter != null && filter != "") { + StringTokenizer str = new StringTokenizer(filter,":"); + query.append(" where ").append(str.nextToken()); + query.append(" ~* '").append(str.nextToken()).append("'"); + // Multiple filters? + while(str.hasMoreTokens()) { + query.append(" and ").append(str.nextToken()); + query.append(" ~* '").append(str.nextToken()).append("'"); + } + } + if(orderby != null) { + query.append(" order by ").append(orderby); + } + if(direction != null) { + query.append(" ").append(direction); + } + if(limit != null) { + query.append(" limit ").append(limit); + } + + // Execute our calculated SQL query + try { + transaction = db.createStatement(); + context.log(query.toString()); + results = transaction.executeQuery(query.toString()); + + // Traverse the ResultSet and create an ArrayList of DataBeans + ArrayList resultList = new ArrayList(); + String dbField = ""; + + while(results.next()) { + + // Create a new DataBean for each row of data + AddressListBean address = new AddressListBean(); + + // Push the result data into the DataBean + address.setIdNumber(Integer.toString(results.getInt(1))); + address.setName(results.getString(2)); + address.setStreet(results.getString(3)); + dbField = results.getString(4).trim(); + address.setCity(dbField.equals("") ? " " : dbField); + dbField = results.getString(5).trim(); + address.setState(dbField.equals("") ? " " : dbField); + dbField = results.getString(6).trim(); + address.setZipcode(dbField.equals("") ? " " : dbField); + dbField = results.getString(7).trim(); + address.setPlus4(dbField.equals("") ? " " : dbField); + + // Add the DataBean to the ArrayList + resultList.add(address); + } + + // Push the ArrayList into the session environment + session.setAttribute("resultList", resultList); + + // Close the query transaction + results.close(); + transaction.close(); + } + catch(SQLException e) { + context.log("Error processing SQL Query", e); + } + + // Forward on to the corresponding jsp + dispatcher = context.getRequestDispatcher("/addressList.jsp"); + dispatcher.forward(request, response); + } +} diff --git a/WEB-INF/code/junk/AddressDataBean.java b/WEB-INF/code/junk/AddressDataBean.java new file mode 100644 index 0000000..3d278d7 --- /dev/null +++ b/WEB-INF/code/junk/AddressDataBean.java @@ -0,0 +1,107 @@ +// AddressDataBean.java +// JavaBean that holds all the data for one address object. + +package com.bullseyecomputing.beans; + +public class AddressDataBean { + private int maxLength; // max string length for list variables + private String id; // a hash of the name + street fields + private String name; + private String listName; // a shortened version of name + private String street; + private String listStreet; + private String city; + private String state; + private String zip; + private String plus4; + private String listPhone; // phone needs to be a collection of phone objects + +// maxLength accessor methods + public void setMaxLength(int len) { + maxLength = len; + } + public int getMaxLength() { + return maxLength; + } + +// id accessor methods + public void setId(String id) { + this.id = id; + } + public String getId() { + return id; + } + +// name accessor methods + public void setName(String name) { + this.name = name; + } + public String getName() { + return name; + } + +// listName accessor methods + public void setListName(String name) { + listName = name; + } + public String getListName() { + return listName; + } + +// street accessor methods + public void setStreet(String street) { + this.street = street; + } + public String getStreet() { + return street; + } + +// listStreet accessor methods + public void setListStreet(String street) { + listStreet = street; + } + public String getListStreet() { + return listStreet; + } + +// city accessor methods + public void setCity(String city) { + this.city = city; + } + public String getCity() { + return city; + } + +// state accessor methods + public void setState(String state) { + this.state = state; + } + public String getState() { + return state; + } + +// zipcode accessor methods + public void setZip(String zip) { + this.zip = zip; + } + public String getZip() { + return zip; + } + +// zip plus4 accessor methods + public void setPlus4(String plus4) { + this.plus4 = plus4; + } + public String getPlus4() { + return plus4; + } + +// listPhone accessor methods + public void setListPhone(String areacode, String number) { + listPhone = "(" + areacode + ")" + number; + } + public String getListPhone() { + return listPhone; + } + +} diff --git a/WEB-INF/code/junk/DataQueryBean.java b/WEB-INF/code/junk/DataQueryBean.java new file mode 100644 index 0000000..f73f9c0 --- /dev/null +++ b/WEB-INF/code/junk/DataQueryBean.java @@ -0,0 +1,152 @@ +// DataQueryBean.java +// JavaBean that will generate an SQL query for the collection of data from the +// specified schema. The JDBC connection parameters and SQL strings are loaded +// from property files. + +package com.bullseyecomputing.beans; + +// import the essentials +import java.io.*; +import java.sql.*; +import java.util.*; + +public class DataQueryBean { + private ClassLoader loader; + + private Connection dbConnection; + private Statement dbTransaction; + private String jdbcProperties = "jdbc.properties"; + + private String schema; + private String sqlProperties; + private String sqlListSelect, sqlDetailSelect; + + private String filter, orderBy, limit; + +// Constructor + public DataQueryBean() throws Exception { + + Properties props = new Properties(); + + // Grab our ClassLoader + loader = this.getClass().getClassLoader(); + + // Use the ClassLoader to locate and load the property file. + try { + props.load(loader.getResourceAsStream(jdbcProperties)); + } + + // Handle the exception if the file is unavailable + catch(IOException ioException) { + ioException.printStackTrace(); + } + + // Get the JDBC parameters + String jdbcDriver = props.getProperty("jdbcDriver"); + String jdbcURL = props.getProperty("jdbcURL"); + + // Get the User parameters + String jdbcUser = props.getProperty("jdbcUser"); + String jdbcPassword = props.getProperty("jdbcPassword"); + + // Create a JDBC connection + Class.forName(jdbcDriver); + dbConnection = DriverManager.getConnection(jdbcURL, jdbcUser, jdbcPassword); + + } +// Constructor + +// Schema + public void setSchema(String schema) { + Properties props = new Properties(); + + this.schema = schema; + sqlProperties = schema + "Query.properties"; + + // Load the SQL Properties + try { + props.load(loader.getResourceAsStream(sqlProperties)); + } + + catch(IOException ioException) { + ioException.printStackTrace(); + } + + // Get the SQL strings + sqlListSelect = props.getProperty("sqlListSelect"); + sqlDetailSelect = props.getProperty("sqlDetailSelect"); + } +// Schema + +// Filter + public void setFilter(String filterString) { + filter = filterString; + sqlListSelect += " where " + filter; + } + public String getFilter() { + return filter; + } +// Filter + +// OrderBy + public void setOrderBy(String orderByString) { + orderBy = orderByString; + sqlListSelect += " order by " + orderBy; + } + public String getOrderBy() { + return orderBy; + } +// OrderBy + +// Limit + public void setLimit(String limit) { + this.limit = limit; + sqlListSelect += " limit " + limit; + } + public String getLimit() { + return limit; + } +// Limit + +// getDataList + public ArrayList getDataList() throws SQLException { + + ArrayList dataList = new ArrayList(); + + dbTransaction = dbConnection.createStatement(); + ResultSet results = dbTransaction.executeQuery(sqlListSelect); + + while(results.next()) { + ListDataBean data = new ListDataBean(); + // Set the Bean values + data.setId(Integer.toString(results.getInt(1))); + data.setName(results.getString(2)); + data.setStreet(results.getString(3)); + data.setCity(results.getString(4)); + data.setState(results.getString(5)); + data.setZip(results.getString(6)); + // handle empty values + String plus4 = results.getString(7).trim(); + data.setPlus4(plus4.equals("") ? " " : plus4); + + dataList.add(data); + } + dbTransaction.close(); + return dataList; + } +// getDataList + +// Finalize + protected void finalize() { + try { + dbConnection.close(); + } + + catch(SQLException sqlException) { + sqlException.printStackTrace(); + } + } +// Finalize + +} +// class diff --git a/WEB-INF/code/junk/DataQueryServlet.java b/WEB-INF/code/junk/DataQueryServlet.java new file mode 100644 index 0000000..f73f7ff --- /dev/null +++ b/WEB-INF/code/junk/DataQueryServlet.java @@ -0,0 +1,34 @@ +// DataQueryServlet.java +// SingleThreadModel servlet that will create and maintain database connections. +// The database connection parameters are read from a properties file. The servlet +// formulates queries based on the its request parameters and session properties. + +package com.bullseyecomputing.servlets; + +import java.io.*; +import java.util.*; +import java.sql.*; +import javax.servlet.*; +import javax.servlet.http.*; + +public class DataQueryServlet extends HttpServlet implements SingleThreadModel { + + // Initialization code + Connection conn = null; + + public void init(ServletConfig config) throws ServletException { + super.init(config) + loadConnectionParameters(); + conn = createConnection(); + conn.setAutoCommit(false); + } + + // HTTP GET handler + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Check for existing session + HttpSession session = request.getSession(false); + String user = session.getAttribute("j_username"); + + // Get query parameters from the request args diff --git a/WEB-INF/code/junk/ListDataBean.java b/WEB-INF/code/junk/ListDataBean.java new file mode 100644 index 0000000..9505bb9 --- /dev/null +++ b/WEB-INF/code/junk/ListDataBean.java @@ -0,0 +1,90 @@ +// ListDataBean.java +// JavaBean that holds the data for one address that will be +// part of a list of addresses generated by another bean. + +package com.bullseyecomputing.beans; + +public class ListDataBean { + private int maxLength; // maximum string length for name and street + private String id; // possibly a hash of the name + street fields + private String name; // possibly a shortened version of the name + private String street; + private String city; + private String state; + private String zip; + private String plus4; + private String phone; + +// maxLength accessor methods + public void setMaxLength(int len) { + maxLength = len; + } + public int getMaxLength() { + return maxLength; + } + +// id accessor methods + public void setId(String id) { + this.id = id; + } + public String getId() { + return id; + } + +// name accessor methods + public void setName(String name) { + this.name = name; + } + public String getName() { + return name; + } + +// street accessor methods + public void setStreet(String street) { + this.street = street; + } + public String getStreet() { + return street; + } + +// city accessor methods + public void setCity(String city) { + this.city = city; + } + public String getCity() { + return city; + } + +// state accessor methods + public void setState(String state) { + this.state = state; + } + public String getState() { + return state; + } + +// zipcode accessor methods + public void setZip(String zip) { + this.zip = zip; + } + public String getZip() { + return zip; + } + +// zip plus4 accessor methods + public void setPlus4(String plus4) { + this.plus4 = plus4; + } + public String getPlus4() { + return plus4; + } + +// phone accessor methods + public void setPhone(String phone) { + this.phone = phone; + } + public String getPhone() { + return phone; + } + +} diff --git a/WEB-INF/code/junk/LoginServlet.java b/WEB-INF/code/junk/LoginServlet.java new file mode 100644 index 0000000..2d5dc4c --- /dev/null +++ b/WEB-INF/code/junk/LoginServlet.java @@ -0,0 +1,33 @@ +// LoginServlet.java +// Session servlet responsible for storing user credentials and preferences +// into the session environment. + +package com.bullseyecomputing.servlets; + +import javax.servlet.*; +import javax.servlet.http.*; +import java.io.*; +import java.util.*; + +public class LoginServlet extends HttpServlet { + + // Init code goes here... + + // HTTP GET handler + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Check for existing session, create one if neccesary. + HttpSession session = request.getSession(true); + session.setAttribute("NewSession","false"); + + if(session.isNew()) { + session.setAttribute("NewSession","true"); + response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); + response.setHeader("WWW-Authenticate", "BASIC realm=\"Application User\""); + } + + // Get our username from the request + String user = request.getRemoteUser(); + } +} diff --git a/WEB-INF/code/junk/RequestTestServlet.java b/WEB-INF/code/junk/RequestTestServlet.java new file mode 100644 index 0000000..df4058a --- /dev/null +++ b/WEB-INF/code/junk/RequestTestServlet.java @@ -0,0 +1,39 @@ +// RequestTestServlet.java + +package com.bullseyecomputing.test; + +import java.io.*; +import java.util.*; + +import javax.servlet.*; +import javax.servlet.http.*; + +public class RequestTestServlet extends HttpServlet { + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + Enumeration arglist; + String name, value; + PrintWriter out = response.getWriter(); + + response.setContentType("text/html"); + out.print("\n\n"); + out.print(" Request Parameter Test\n"); + out.print(" \n"); + out.print("\n\n"); + out.print("

Request Parameter Test

\n"); + out.print(" \n "); + out.print(" \n \n"); + out.print(" \n \n"); + arglist = request.getParameterNames(); + while(arglist.hasMoreElements()) { + name = arglist.nextElement().toString(); + value = request.getParameter(name); + out.print(" \n \n "); + out.print("\n \n"); + } + out.print("
NameValue
" + name + "" + value + "
\n\n\n"); + } +} diff --git a/WEB-INF/code/junk/ServerInfoServlet.java b/WEB-INF/code/junk/ServerInfoServlet.java new file mode 100644 index 0000000..3914b70 --- /dev/null +++ b/WEB-INF/code/junk/ServerInfoServlet.java @@ -0,0 +1,10 @@ +// ServerInfoServlet.java +// Servlet that returns imformation about the server it is running under. + +package com.bullseyecomputing.servlets; + +import java.io.*; +import java.util.*; +import javax.servlet.*; + +public class ServerInfoServlet extends GenericServlet { diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml new file mode 100644 index 0000000..f9931aa --- /dev/null +++ b/WEB-INF/web.xml @@ -0,0 +1,129 @@ + + + + + + + AddressBook Manager + + + + getList + com.bullseyecomputing.servlets.ListQueryServlet + + jdbcDriver + org.postgresql.Driver + + + jdbcURL + jdbc:postgresql:jimi + + + jdbcUser + guest + + + jdbcPassword + + + + table + address + + + selected + + id,name,street,city,state,zipcode,zipext + + + + + + getData + + com.bullseyecomputing.servlets.FilterQueryServlet + + + + + getDetail + + com.bullseyecomputing.servlets.DetailQueryServlet + + + jdbcDriver + org.postgresql.Driver + + + jdbcURL + jdbc:postgresql:jimi + + + jdbcUser + guest + + + jdbcPassword + + + + table + address + + + selected + + id,name,street,city,state,zipcode,zipext,areacode,phone + + + + + + getTest + com.bullseyecomputing.test.RequestTestServlet + + + + getList + /getList + + + getData + /getData + + + getDetail + /getDetail + + + getTest + /getTest + + + + 90 + + + + + Trucking App + /index.jsp + /getList + /getData + + + user + + + + + FORM + + /login.jsp + /login.jsp + + + + diff --git a/addressData.jsp b/addressData.jsp new file mode 100644 index 0000000..da6a308 --- /dev/null +++ b/addressData.jsp @@ -0,0 +1,161 @@ +<%-- JSP page setup --%> +<%! static String pageTitle = "Address Detail"; %> +<%@ page + info = "Data-Entry form for the AddressBook webapp" + language = "java" + session = "true" + import = "com.bullseyecomputing.beans.AddressDataBean" +%> +<% AddressDataBean a = (AddressDataBean) session.getAttribute("address.data"); %> +<%@ include file = "include/pageHeader.jsp" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
<%=a.getName()%>Search: +
<%=pageTitle%>
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name: + +
Addr1: + +
Addr2: + +
City/St: + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Phone: + + + +
Fax: + + + +
Note: +
Nick: +
+ +
+ + + +
+  Status: + +
+ + diff --git a/addressList.jsp b/addressList.jsp new file mode 100644 index 0000000..749cefb --- /dev/null +++ b/addressList.jsp @@ -0,0 +1,67 @@ +<%-- JSP page setup --%> +<%! static String pageTitle = "Address List"; %> +<%@ page + info = "Generate a filtering, sortable table of addresses" + language = "java" + session = "true" + import="com.bullseyecomputing.beans.AddressListBean, java.util.*" +%> +<%@ include file = "include/pageHeader.jsp" %> + + + + + + + + + + + + + + + + + + + + + + + + +<% + List addresslist = (List) session.getAttribute("resultList"); + Iterator address = addresslist.iterator(); + int row = 0; + AddressListBean addr; + + while(address.hasNext()) { + addr = (AddressListBean) address.next(); + +%> "> + + + + + + + +<% + } + // Release the resultList object + session.removeAttribute("resultList"); +%> + + +
Address ListSearch: +
NameStreetCitySTZipPhone
<%=addr.getName()%><%=addr.getStreet()%><%=addr.getCity()%><%=addr.getState()%><%=addr.getZipcode()%><%=addr.getPlus4()%>
+  Page x of y + + + + +
+ + diff --git a/checklogin.jsp b/checklogin.jsp new file mode 100644 index 0000000..05d0403 --- /dev/null +++ b/checklogin.jsp @@ -0,0 +1,9 @@ +<% + String user = (String) session.getAttribute("user"); + + if(user == null) { +%> + +<% + } +%> diff --git a/endSession.jsp b/endSession.jsp new file mode 100644 index 0000000..9f5ebe6 --- /dev/null +++ b/endSession.jsp @@ -0,0 +1,14 @@ +<% session.invalidate(); %> +<%! static String pageTitle = "Session Ended"; %> +<%@ include file = "include/pageHeader.jsp" %> + +
+

+ <%= pageTitle %> +


+
+ +
+
+ + diff --git a/images/750px.png b/images/750px.png new file mode 100644 index 0000000000000000000000000000000000000000..f51f7386e0722172c97429fc83497c303f187928 GIT binary patch literal 359 zcmeAS@N?(olHy`uVBq!ia0y~yV0s5+i*T?3$xGck<^U;{bVpxD28NCO+hy&=XG= z$B>FSZ|`p8YcddNyD0B@eBb|OBcZ0|PN{<@SaNOB-;^BJFW(_MX-%aB69dDRG~Y?L zuLc8k?&mCLV0h6`z|PRX#{ps<$lGx}>ij%r28JJrXJ2nRbJ?O#ya%Y||Jo^^etvoL z)py739n1_4#{1f^=+(7v$s(7#SRt`)Uq6 kkx>D<^|+-6&|ODmWz7_iOjs?u1?Xx9Pgg&ebxsLQ0Jn{Sv;Y7A literal 0 HcmV?d00001 diff --git a/images/766px.png b/images/766px.png new file mode 100644 index 0000000000000000000000000000000000000000..c1332f6d0836fbfde0682fee124721d9b3b38b39 GIT binary patch literal 1572 zcmXX`eK?bA7=NrUA1UNWlB|~FvQt z_krtC`BV30(L)RuJpk~7Ufp-8rTxxz=5IfHHx0t0t4JyafD}`G1Qxos35%&x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#d2Tlmy2kR49B2YO3T*&D$ox4A zaH79P_f=c^`?h7??;&c3!xbqlI9QUtfB*i$@~IPc5C_mr^&^?M^1`ow!VLh(UW!K< HA>_ + + + + + <%= pageTitle %> + + + + + diff --git a/index.jsp b/index.jsp new file mode 100644 index 0000000..c08da86 --- /dev/null +++ b/index.jsp @@ -0,0 +1 @@ + diff --git a/login.jsp b/login.jsp new file mode 100644 index 0000000..37c8e66 --- /dev/null +++ b/login.jsp @@ -0,0 +1,25 @@ +<%! static String pageTitle = "Application Login"; %> +<%@ include file = "include/pageHeader.jsp" %> + +
+

+ + + + + + + + + + + + + + + + +

+ + diff --git a/oldAddressList.jsp b/oldAddressList.jsp new file mode 100644 index 0000000..464ae56 --- /dev/null +++ b/oldAddressList.jsp @@ -0,0 +1,52 @@ +<%@ page info = "addressList.jsp - generate a table of addresses" %> +<%! static String pageTitle = "Address List"; %> +<%@ taglib uri = "include/db-taglib.tld" prefix = "db" %> +<%@ include file = "include/sessionHeader.jsp" %> +<%@ include file = "include/pageHeader.jsp" %> +> +
+ class="hidden"> + + + +
+
+
+ > + + + + + + + + + + + + + + + + +
NameStreetCitySTZip+4
<%=name%><%=street%><%=city%><%=state%><%=zip%><%=plus4%>
+
+ +
+ Session ID: <%= session.getId() %>
+ Session is new: <%= session.isNew() %>
+ Session variables: + <% java.util.Enumeration sess = session.getAttributeNames(); + while(sess.hasMoreElements()) { + out.print(sess.nextElement() + " "); + } + %> +
+ + diff --git a/style/common.css b/style/common.css new file mode 100644 index 0000000..7c06b63 --- /dev/null +++ b/style/common.css @@ -0,0 +1,94 @@ + diff --git a/style/old.css b/style/old.css new file mode 100644 index 0000000..deb1cd5 --- /dev/null +++ b/style/old.css @@ -0,0 +1,185 @@ + diff --git a/test-1.jsp b/test-1.jsp new file mode 100644 index 0000000..a9d36b3 --- /dev/null +++ b/test-1.jsp @@ -0,0 +1,269 @@ +<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> +<%@ include file="Connections/jimi.jsp" %> +<% +Driver DriverAddressList = (Driver)Class.forName(MM_jimi_DRIVER).newInstance(); +Connection ConnAddressList = DriverManager.getConnection(MM_jimi_STRING,MM_jimi_USERNAME,MM_jimi_PASSWORD); +PreparedStatement StatementAddressList = ConnAddressList.prepareStatement("SELECT nick,name,street,city,state,zipcode FROM address"); +ResultSet AddressList = StatementAddressList.executeQuery(); +boolean AddressList_isEmpty = !AddressList.next(); +boolean AddressList_hasData = !AddressList_isEmpty; +Object AddressList_data; +int AddressList_numRows = 0; +%> +<% +int Repeat1__numRows = 35; +int Repeat1__index = 0; +AddressList_numRows += Repeat1__numRows; +%> +<% +// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables + +int AddressList_first = 1; +int AddressList_last = 1; +int AddressList_total = -1; + +if (AddressList_isEmpty) { + AddressList_total = AddressList_first = AddressList_last = 0; +} + +//set the number of rows displayed on this page +if (AddressList_numRows == 0) { + AddressList_numRows = 1; +} +%> +<% +// *** Recordset Stats: if we don't know the record count, manually count them + +if (AddressList_total == -1) { + + // count the total records by iterating through the recordset + for (AddressList_total = 1; AddressList.next(); AddressList_total++); + + // reset the cursor to the beginning + AddressList.close(); + AddressList = StatementAddressList.executeQuery(); + AddressList_hasData = AddressList.next(); + + // set the number of rows displayed on this page + if (AddressList_numRows < 0 || AddressList_numRows > AddressList_total) { + AddressList_numRows = AddressList_total; + } + + // set the first and last displayed record + AddressList_first = Math.min(AddressList_first, AddressList_total); + AddressList_last = Math.min(AddressList_first + AddressList_numRows - 1, AddressList_total); +} +%> +<% String MM_paramName = ""; %> +<% +// *** Move To Record and Go To Record: declare variables + +ResultSet MM_rs = AddressList; +int MM_rsCount = AddressList_total; +int MM_size = AddressList_numRows; +String MM_uniqueCol = ""; + MM_paramName = ""; +int MM_offset = 0; +boolean MM_atTotal = false; +boolean MM_paramIsDefined = (MM_paramName.length() != 0 && request.getParameter(MM_paramName) != null); +%> +<% +// *** Move To Record: handle 'index' or 'offset' parameter + +if (!MM_paramIsDefined && MM_rsCount != 0) { + + //use index parameter if defined, otherwise use offset parameter + String r = request.getParameter("index"); + if (r==null) r = request.getParameter("offset"); + if (r!=null) MM_offset = Integer.parseInt(r); + + // if we have a record count, check if we are past the end of the recordset + if (MM_rsCount != -1) { + if (MM_offset >= MM_rsCount || MM_offset == -1) { // past end or move last + if (MM_rsCount % MM_size != 0) // last page not a full repeat region + MM_offset = MM_rsCount - MM_rsCount % MM_size; + else + MM_offset = MM_rsCount - MM_size; + } + } + + //move the cursor to the selected record + int i; + for (i=0; AddressList_hasData && (i < MM_offset || MM_offset == -1); i++) { + AddressList_hasData = MM_rs.next(); + } + if (!AddressList_hasData) MM_offset = i; // set MM_offset to the last possible record +} +%> +<% +// *** Move To Record: if we dont know the record count, check the display range + +if (MM_rsCount == -1) { + + // walk to the end of the display range for this page + int i; + for (i=MM_offset; AddressList_hasData && (MM_size < 0 || i < MM_offset + MM_size); i++) { + AddressList_hasData = MM_rs.next(); + } + + // if we walked off the end of the recordset, set MM_rsCount and MM_size + if (!AddressList_hasData) { + MM_rsCount = i; + if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount; + } + + // if we walked off the end, set the offset based on page size + if (!AddressList_hasData && !MM_paramIsDefined) { + if (MM_offset > MM_rsCount - MM_size || MM_offset == -1) { //check if past end or last + if (MM_rsCount % MM_size != 0) //last page has less records than MM_size + MM_offset = MM_rsCount - MM_rsCount % MM_size; + else + MM_offset = MM_rsCount - MM_size; + } + } + + // reset the cursor to the beginning + AddressList.close(); + AddressList = StatementAddressList.executeQuery(); + AddressList_hasData = AddressList.next(); + MM_rs = AddressList; + + // move the cursor to the selected record + for (i=0; AddressList_hasData && i < MM_offset; i++) { + AddressList_hasData = MM_rs.next(); + } +} +%> +<% +// *** Move To Record: update recordset stats + +// set the first and last displayed record +AddressList_first = MM_offset + 1; +AddressList_last = MM_offset + MM_size; +if (MM_rsCount != -1) { + AddressList_first = Math.min(AddressList_first, MM_rsCount); + AddressList_last = Math.min(AddressList_last, MM_rsCount); +} + +// set the boolean used by hide region to check if we are on the last record +MM_atTotal = (MM_rsCount != -1 && MM_offset + MM_size >= MM_rsCount); +%> +<% +// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters + +String MM_keepBoth,MM_keepURL="",MM_keepForm="",MM_keepNone=""; +String[] MM_removeList = { "index", MM_paramName }; + +// create the MM_keepURL string +if (request.getQueryString() != null) { + MM_keepURL = '&' + request.getQueryString(); + for (int i=0; i < MM_removeList.length && MM_removeList[i].length() != 0; i++) { + int start = MM_keepURL.indexOf(MM_removeList[i]) - 1; + if (start >= 0 && MM_keepURL.charAt(start) == '&' && + MM_keepURL.charAt(start + MM_removeList[i].length() + 1) == '=') { + int stop = MM_keepURL.indexOf('&', start + 1); + if (stop == -1) stop = MM_keepURL.length(); + MM_keepURL = MM_keepURL.substring(0,start) + MM_keepURL.substring(stop); + } + } +} + +// add the Form variables to the MM_keepForm string +if (request.getParameterNames().hasMoreElements()) { + java.util.Enumeration items = request.getParameterNames(); + while (items.hasMoreElements()) { + String nextItem = (String)items.nextElement(); + boolean found = false; + for (int i=0; !found && i < MM_removeList.length; i++) { + if (MM_removeList[i].equals(nextItem)) found = true; + } + if (!found && MM_keepURL.indexOf('&' + nextItem + '=') == -1) { + MM_keepForm = MM_keepForm + '&' + nextItem + '=' + java.net.URLEncoder.encode(request.getParameter(nextItem)); + } + } +} + +// create the Form + URL string and remove the intial '&' from each of the strings +MM_keepBoth = MM_keepURL + MM_keepForm; +if (MM_keepBoth.length() > 0) MM_keepBoth = MM_keepBoth.substring(1); +if (MM_keepURL.length() > 0) MM_keepURL = MM_keepURL.substring(1); +if (MM_keepForm.length() > 0) MM_keepForm = MM_keepForm.substring(1); +%> +<% +// *** Move To Record: set the strings for the first, last, next, and previous links + +String MM_moveFirst,MM_moveLast,MM_moveNext,MM_movePrev; +{ + String MM_keepMove = MM_keepBoth; // keep both Form and URL parameters for moves + String MM_moveParam = "index="; + + // if the page has a repeated region, remove 'offset' from the maintained parameters + if (MM_size > 1) { + MM_moveParam = "offset="; + int start = MM_keepMove.indexOf(MM_moveParam); + if (start != -1 && (start == 0 || MM_keepMove.charAt(start-1) == '&')) { + int stop = MM_keepMove.indexOf('&', start); + if (start == 0 && stop != -1) stop++; + if (stop == -1) stop = MM_keepMove.length(); + if (start > 0) start--; + MM_keepMove = MM_keepMove.substring(0,start) + MM_keepMove.substring(stop); + } + } + + // set the strings for the move to links + StringBuffer urlStr = new StringBuffer(request.getRequestURI()).append('?').append(MM_keepMove); + if (MM_keepMove.length() > 0) urlStr.append('&'); + urlStr.append(MM_moveParam); + MM_moveFirst = urlStr + "0"; + MM_moveLast = urlStr + "-1"; + MM_moveNext = urlStr + Integer.toString(MM_offset+MM_size); + MM_movePrev = urlStr + Integer.toString(Math.max(MM_offset-MM_size,0)); +} +%> + + +Test Document + + + + + + + + + <% int row = 0; while ((AddressList_hasData)&&(Repeat1__numRows-- != 0)) { %> + "> + + + + + + + <% + Repeat1__index++; + AddressList_hasData = AddressList.next(); +} +%> + + + +
namestreetcitystatezipcode
<%=(((AddressList_data = AddressList.getObject("name"))==null || AddressList.wasNull())?"":AddressList_data)%><%=(((AddressList_data = AddressList.getObject("street"))==null || AddressList.wasNull())?"":AddressList_data)%><%=(((AddressList_data = AddressList.getObject("city"))==null || AddressList.wasNull())?"":AddressList_data)%><%=(((AddressList_data = AddressList.getObject("state"))==null || AddressList.wasNull())?"":AddressList_data)%><%=(((AddressList_data = AddressList.getObject("zipcode"))==null || AddressList.wasNull())?"":AddressList_data)%>
+ + <%=(AddressList_first)%> to <%=(AddressList_last)%> of <%=(AddressList_total)%> + + + <% if (MM_offset !=0) { %> + + <% } /* end MM_offset != 0 */ %> + <% if (!MM_atTotal) { %> + + <% } /* end !MM_atTotal */ %> + +
+ + +<% +AddressList.close(); +StatementAddressList.close(); +ConnAddressList.close(); +%> diff --git a/test-2.jsp b/test-2.jsp new file mode 100644 index 0000000..a5ddb53 --- /dev/null +++ b/test-2.jsp @@ -0,0 +1,139 @@ +<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> +<%@ include file="Connections/jimi.jsp" %> +<% +// *** Edit Operations: declare variables + +// set the form action variable +String MM_editAction = request.getRequestURI(); +if (request.getQueryString() != null && request.getQueryString().length() > 0) { + MM_editAction += "?" + request.getQueryString(); +} + +// connection information +String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null; + +// redirect information +String MM_editRedirectUrl = null; + +// query string to execute +StringBuffer MM_editQuery = null; + +// boolean to abort record edit +boolean MM_abortEdit = false; + +// table information +String MM_editTable = null, MM_editColumn = null, MM_recordId = null; + +// form field information +String[] MM_fields = null, MM_columns = null; +%> +<% +// *** Insert Record: set variables + +if (request.getParameter("MM_insert") != null && request.getParameter("MM_insert").toString().equals("form1")) { + + MM_editDriver = MM_jimi_DRIVER; + MM_editConnection = MM_jimi_STRING; + MM_editUserName = MM_jimi_USERNAME; + MM_editPassword = MM_jimi_PASSWORD; + MM_editTable = "address"; + MM_editRedirectUrl = ""; + String MM_fieldsStr = "id|value|nick|value|name|value|street|value|city|value|state|value|zipcode|value|zipext|value|phone|value|areacode|value"; + String MM_columnsStr = "id|none,none,NULL|nick|',none,''|name|',none,''|street|',none,''|city|',none,''|state|none,none,NULL|zipcode|none,none,NULL|zipext|none,none,NULL|phone|',none,''|areacode|',none,''"; + + // create the MM_fields and MM_columns arrays + java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_fieldsStr,"|"); + MM_fields = new String[tokens.countTokens()]; + for (int i=0; tokens.hasMoreTokens(); i++) MM_fields[i] = tokens.nextToken(); + + tokens = new java.util.StringTokenizer(MM_columnsStr,"|"); + MM_columns = new String[tokens.countTokens()]; + for (int i=0; tokens.hasMoreTokens(); i++) MM_columns[i] = tokens.nextToken(); + + // set the form values + for (int i=0; i+1 < MM_fields.length; i+=2) { + MM_fields[i+1] = ((request.getParameter(MM_fields[i])!=null)?(String)request.getParameter(MM_fields[i]):""); + } + + // append the query string to the redirect URL + if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) { + MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString(); + } +} +%> +<% +// *** Insert Record: construct a sql insert statement and execute it + +if (request.getParameter("MM_insert") != null) { + + // create the insert sql statement + StringBuffer MM_tableValues = new StringBuffer(), MM_dbValues = new StringBuffer(); + for (int i=0; i+1 < MM_fields.length; i+=2) { + String formVal = MM_fields[i+1]; + String elem; + java.util.StringTokenizer tokens = new java.util.StringTokenizer(MM_columns[i+1],","); + String delim = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:""; + String altVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:""; + String emptyVal = ((elem = (String)tokens.nextToken()) != null && elem.compareTo("none")!=0)?elem:""; + if (formVal.length() == 0) { + formVal = emptyVal; + } else { + if (altVal.length() != 0) { + formVal = altVal; + } else if (delim.compareTo("'") == 0) { // escape quotes + StringBuffer escQuotes = new StringBuffer(formVal); + for (int j=0; j < escQuotes.length(); j++) + if (escQuotes.charAt(j) == '\'') escQuotes.insert(j++,'\''); + formVal = "'" + escQuotes + "'"; + } else { + formVal = delim + formVal + delim; + } + } + MM_tableValues.append((i!=0)?",":"").append(MM_columns[i]); + MM_dbValues.append((i!=0)?",":"").append(formVal); + } + MM_editQuery = new StringBuffer("insert into " + MM_editTable); + MM_editQuery.append(" (").append(MM_tableValues.toString()).append(") values ("); + MM_editQuery.append(MM_dbValues.toString()).append(")"); + + if (!MM_abortEdit) { + // finish the sql and execute it + Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance(); + Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword); + PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString()); + MM_editStatement.executeUpdate(); + MM_connection.close(); + + // redirect with URL parameters + if (MM_editRedirectUrl.length() != 0) { + response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl)); + return; + } + } +} +%> +<% +Driver DriveraddressData = (Driver)Class.forName(MM_jimi_DRIVER).newInstance(); +Connection ConnaddressData = DriverManager.getConnection(MM_jimi_STRING,MM_jimi_USERNAME,MM_jimi_PASSWORD); +PreparedStatement StatementaddressData = ConnaddressData.prepareStatement("SELECT * FROM address"); +ResultSet addressData = StatementaddressData.executeQuery(); +boolean addressData_isEmpty = !addressData.next(); +boolean addressData_hasData = !addressData_isEmpty; +Object addressData_data; +int addressData_numRows = 0; +%> + + +Test Document 2 + + + + + + + +<% +addressData.close(); +StatementaddressData.close(); +ConnaddressData.close(); +%> diff --git a/test.html b/test.html new file mode 100644 index 0000000..49b30f2 --- /dev/null +++ b/test.html @@ -0,0 +1,178 @@ + + + HTML 4.0 Test Page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Contact List
Search: +
NameStreetCitySTZipPhone
This 30 character Company NameMy 30 character Street AddressRancho CucamongaCA99999_(800) 555-1212
2     
3     
4     
5     
6     
7     
8     
9     
10     
11     
12     
13     
+   Page 1 of 2 + < prev   next >   +
+
+ + + + + +
+ + diff --git a/testpage.jsp b/testpage.jsp new file mode 100644 index 0000000..f4695ed --- /dev/null +++ b/testpage.jsp @@ -0,0 +1,52 @@ +<%! static String pageTitle = "Snoopy"; %> +<%@ page info="test area" %> +<%@ page import="java.util.Enumeration" %> +<%@ include file="include/pageHeader.jsp" %> + +
+

Header And Session Snooper

+ +

Header Contents:

+

+<% + Enumeration header = request.getHeaderNames(); + while(header.hasMoreElements()) { + String name = header.nextElement().toString(); + String value = request.getHeader(name); + out.println(" " + name + " = " + value + "
"); + } +%> +

Request Parameters:

+

+ RemoteUser = <%= request.getRemoteUser() %>
+ SessionID from cookie: <%= request.isRequestedSessionIdFromCookie() %>
+ SessionID from URL: <%= request.isRequestedSessionIdFromURL() %>
+<% + Enumeration arglist = request.getParameterNames(); + while(arglist.hasMoreElements()) { + String name = arglist.nextElement().toString(); + String value = request.getParameter(name); + out.println(" " + name + " = " + value + "
"); + } +%> + +

Session Contents:

+

+ sessionId: <%= session.getId()%>
+ maxInactiveInterval: <%= session.getMaxInactiveInterval() %> seconds
+ sessionAttributes:
+

+<% Enumeration enum = session.getAttributeNames(); + while(enum.hasMoreElements()) { + String attr = enum.nextElement().toString(); + String val = session.getAttribute(attr).toString(); + out.println(" " + attr + " = " + val + "
"); + } +%> +


+
+ +
+
+ +