Browse Source

import of old work

master
Jim Infield 16 years ago
commit
da26e33bb2
  1. 12
      Connections/jimi.jsp
  2. BIN
      First.gif
  3. BIN
      Last.gif
  4. BIN
      Next.gif
  5. BIN
      Previous.gif
  6. BIN
      WEB-INF/classes/addressBeans.jar
  7. BIN
      WEB-INF/classes/com/bullseyecomputing/beans/AddressDataBean.class
  8. BIN
      WEB-INF/classes/com/bullseyecomputing/beans/AddressListBean.class
  9. BIN
      WEB-INF/classes/com/bullseyecomputing/servlets/ConnectionListener.class
  10. BIN
      WEB-INF/classes/com/bullseyecomputing/servlets/DetailQueryServlet.class
  11. BIN
      WEB-INF/classes/com/bullseyecomputing/servlets/FilterQueryServlet.class
  12. BIN
      WEB-INF/classes/com/bullseyecomputing/servlets/ListQueryServlet.class
  13. BIN
      WEB-INF/classes/com/bullseyecomputing/test/RequestTestServlet.class
  14. 117
      WEB-INF/code/AddressDataBean.java
  15. 77
      WEB-INF/code/AddressListBean.java
  16. 45
      WEB-INF/code/ConnectionListener.java
  17. 128
      WEB-INF/code/DetailQueryServlet.java
  18. 76
      WEB-INF/code/DetailUpdateServlet.java
  19. 162
      WEB-INF/code/FilterQueryServlet.java
  20. 191
      WEB-INF/code/ListQueryServlet.java
  21. 107
      WEB-INF/code/junk/AddressDataBean.java
  22. 152
      WEB-INF/code/junk/DataQueryBean.java
  23. 34
      WEB-INF/code/junk/DataQueryServlet.java
  24. 90
      WEB-INF/code/junk/ListDataBean.java
  25. 33
      WEB-INF/code/junk/LoginServlet.java
  26. 39
      WEB-INF/code/junk/RequestTestServlet.java
  27. 10
      WEB-INF/code/junk/ServerInfoServlet.java
  28. 129
      WEB-INF/web.xml
  29. 161
      addressData.jsp
  30. 67
      addressList.jsp
  31. 9
      checklogin.jsp
  32. 14
      endSession.jsp
  33. BIN
      images/750px.png
  34. BIN
      images/766px.png
  35. 13
      include/pageHeader.jsp
  36. 1
      index.jsp
  37. 25
      login.jsp
  38. 52
      oldAddressList.jsp
  39. 94
      style/common.css
  40. 185
      style/old.css
  41. 269
      test-1.jsp
  42. 139
      test-2.jsp
  43. 178
      test.html
  44. 52
      testpage.jsp

12
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";
%>

BIN
First.gif

After

Width: 18  |  Height: 13  |  Size: 128 B

BIN
Last.gif

After

Width: 18  |  Height: 13  |  Size: 93 B

BIN
Next.gif

After

Width: 14  |  Height: 13  |  Size: 67 B

BIN
Previous.gif

After

Width: 14  |  Height: 13  |  Size: 67 B

BIN
WEB-INF/classes/addressBeans.jar

BIN
WEB-INF/classes/com/bullseyecomputing/beans/AddressDataBean.class

BIN
WEB-INF/classes/com/bullseyecomputing/beans/AddressListBean.class

BIN
WEB-INF/classes/com/bullseyecomputing/servlets/ConnectionListener.class

BIN
WEB-INF/classes/com/bullseyecomputing/servlets/DetailQueryServlet.class

BIN
WEB-INF/classes/com/bullseyecomputing/servlets/FilterQueryServlet.class

BIN
WEB-INF/classes/com/bullseyecomputing/servlets/ListQueryServlet.class

BIN
WEB-INF/classes/com/bullseyecomputing/test/RequestTestServlet.class

117
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;
}
}

77
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;
}
}

45
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...
}
}
}

128
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);
}
}

76
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();

162
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);
}
}

191
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);
}
}

107
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;
}
}

152
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("") ? "&nbsp" : plus4);
dataList.add(data);
}
dbTransaction.close();
return dataList;
}
// getDataList
// Finalize
protected void finalize() {
try {
dbConnection.close();
}
catch(SQLException sqlException) {
sqlException.printStackTrace();
}
}
// Finalize
}
// class

34
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

90
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;
}
}

33
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();
}
}

39
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("<html>\n<head>\n");
out.print(" <title>Request Parameter Test</title>\n");
out.print(" <link rel=\"stylesheet\" href=\"style/common.css\"");
out.print(" type=\"text/css\">\n");
out.print("</head>\n<body>\n");
out.print(" <h3>Request Parameter Test</h3>\n");
out.print(" <table class=\"third\">\n ");
out.print(" <thead>\n <th>Name</th>\n");
out.print(" <th>Value</th>\n </thead>\n");
arglist = request.getParameterNames();
while(arglist.hasMoreElements()) {
name = arglist.nextElement().toString();
value = request.getParameter(name);
out.print(" <tr>\n <td>" + name + "</td>\n ");
out.print("<td>" + value + "</td>\n </tr>\n");
}
out.print(" </table>\n</body>\n</html>\n");
}
}

10
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 {

129
WEB-INF/web.xml

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name>
AddressBook Manager
</display-name>
<servlet>
<servlet-name>getList</servlet-name>
<servlet-class>com.bullseyecomputing.servlets.ListQueryServlet</servlet-class>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>org.postgresql.Driver</param-value>
</init-param>
<init-param>
<param-name>jdbcURL</param-name>
<param-value>jdbc:postgresql:jimi</param-value>
</init-param>
<init-param>
<param-name>jdbcUser</param-name>
<param-value>guest</param-value>
</init-param>
<init-param>
<param-name>jdbcPassword</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>table</param-name>
<param-value>address</param-value>
</init-param>
<init-param>
<param-name>selected</param-name>
<param-value>
id,name,street,city,state,zipcode,zipext
</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>getData</servlet-name>
<servlet-class>
com.bullseyecomputing.servlets.FilterQueryServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>getDetail</servlet-name>
<servlet-class>
com.bullseyecomputing.servlets.DetailQueryServlet
</servlet-class>
<init-param>
<param-name>jdbcDriver</param-name>
<param-value>org.postgresql.Driver</param-value>
</init-param>
<init-param>
<param-name>jdbcURL</param-name>
<param-value>jdbc:postgresql:jimi</param-value>
</init-param>
<init-param>
<param-name>jdbcUser</param-name>
<param-value>guest</param-value>
</init-param>
<init-param>
<param-name>jdbcPassword</param-name>
<param-value></param-value>
</init-param>
<init-param>
<param-name>table</param-name>
<param-value>address</param-value>
</init-param>
<init-param>
<param-name>selected</param-name>
<param-value>
id,name,street,city,state,zipcode,zipext,areacode,phone
</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>getTest</servlet-name>
<servlet-class>com.bullseyecomputing.test.RequestTestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>getList</servlet-name>
<url-pattern>/getList</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>getData</servlet-name>
<url-pattern>/getData</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>getDetail</servlet-name>
<url-pattern>/getDetail</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>getTest</servlet-name>
<url-pattern>/getTest</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>90</session-timeout>
</session-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Trucking App</web-resource-name>
<url-pattern>/index.jsp</url-pattern>
<url-pattern>/getList</url-pattern>
<url-pattern>/getData</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/login.jsp</form-error-page>
</form-login-config>
</login-config>
</web-app>

161
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" %>
<body bgcolor="#f7f7f7" onload="document.search.filter.focus();">
<table class="data">
<colgroup>
<col width=75pt>
<col width=275pt>
<col width=60pt>
<col width=*>
</colgroup>
<!-- Title/Search ----------->
<tr class="header">
<form method="get" action="getData" name="search">
<td colspan=3 class="title"><%=a.getName()%></td>
<td align="right"><b class="label">Search:</b>
<input type="text" name="filter" maxlength=30 style="width: 140pt"/></td>
</form>
</tr>
<!-- Address/Contact -->
<tr>
<th colspan=4 style="font-style: italic"><%=pageTitle%></th>
</tr>
<!-- Entry Form -->
<form name="entry" method="post">
<tr>
<td colspan=2>
<!-- Left Side ----------->
<table>
<colgroup>
<col width=75pt>
<col width=275pt>
</colgroup>
<!-- Name -->
<tr>
<td class="label">Name:</td>
<td>
<input type="text" name="name" value="<%=a.getName()%>"
maxlength=30 style="width: 210pt;">
</td>
</tr>
<!-- Addr1 -->
<tr>
<td class="label">Addr1:</td>
<td>
<input type="text" name="street" value="<%=a.getStreet()%>"
maxlength=30 style="width: 210pt;">
</td>
</tr>
<!-- Addr2 -->
<tr>
<td class="label">Addr2:</td>
<td>
<input type="text" name="street" value=""
maxlength=30 style="width: 210pt;">
</td>
</tr>
<!-- City/State -->
<tr>
<td class="label">City/St:</td>
<td>
<input type="text" name="city" value="<%=a.getCity()%>"
maxlength=16 style="width: 108pt;">
<input type="text" name="state" value="<%=a.getState()%>"
maxlength=2 style="width: 21pt;">
<input type="text" name="zipcode" value="<%=a.getZipcode()%>"
maxlength=6 style="width: 41pt;">
<input type="text" name="plus4" value="<%=a.getPlus4()%>"
maxlength=4 style="width: 31pt;">
</td>
</tr>
</table>
</td>
<!-- Right Side -->
<td colspan=2>
<table>
<colgroup>
<col width=60pt>
<col width=275pt>
</colgroup>
<tr>
<td class="label">Phone:</td>
<td>
<input type="text" name="pArea" value=""
maxlength=3 style="width: 28pt;">
<input type="text" name="pNumber" value=""
maxlength=8 style="width: 58pt;">
<input type="text" name="pDesc" value=""
maxlength=20 style="width: 108pt;">
</td>
</tr>
<tr>
<td class="label">Fax:</td>
<td>
<input type="text" name="fArea" value=""
maxlength=3 style="width: 28pt;">
<input type="text" name="fNumber" value=""
maxlength=8 style="width: 58pt;">
<input type="text" name="fDesc" value=""
maxlength=20 style="width: 108pt;">
</td>
</tr>
<tr>
<td class="label">Note:</td>
<td><input type="text" name="note" value="This a sample note"
maxlength=30 style="width: 200pt;">
</td>
</tr>
<tr>
<td class="label">Nick:</td>
<td><input type="text" name="nick" value=""
maxlength=12 style="width: 90pt;">
</td>
</tr>
</table>
</td>
</tr>
<!-- Save/Delete Buttons -->
<tr align="center">
<td colspan=4>
<input class="small" type="submit" value="save">
<input class="small" type="button" value="delete">
<input class="small" type="reset" value="reset">
</td>
</tr>
<!-- Status Line -->
<tr class="status">
<td colspan=4>
<span class="left">&nbsp;Status:</span>
<span class="right"></span>
</td>
</tr>
</form>
</table>
</body>
</html>

67
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" %>
<body bgcolor="#f7f7f7" onload="document.search.filter.focus();">
<table class="data" cellpadding=0 cellspacing=2>
<colgroup>
<col> <!-- Name -->
<col> <!-- Street -->
<col size=16em> <!-- City -->
<col size=2em> <!-- State -->
<col size=5em> <!-- Zipcode -->
<col size=10em> <!-- Phone -->
</colgroup>
<tr class="header">
<form method="get" action="getData" name="search">
<td colspan=2 class="title">Address List</td>
<td colspan=4 align="right"><b class="label">Search:</b>
<input type="text" name="filter" maxlength=30 style="width: 140pt"/></td>
</form>
</tr>
<tr>
<th><a href="/getList?orderby=name&">Name</a></th>
<th>Street</th>
<th><a href="/getList?orderby=city&">City</a></th>
<th><a href="/getList?orderby=state&">ST</a></th>
<th><a href="/getList?orderby=zipcode&">Zip</a></th>
<th>Phone</th>
</tr>
<%
List addresslist = (List) session.getAttribute("resultList");
Iterator address = addresslist.iterator();
int row = 0;
AddressListBean addr;
while(address.hasNext()) {
addr = (AddressListBean) address.next();
%> <tr class="<%=(row++ % 2 == 1) ? "dark" : "light"%>">
<td><a href="/getDetail?id=<%=addr.getIdNumber()%>&"><%=addr.getName()%></a></td>
<td><%=addr.getStreet()%></td>
<td><a href="/getList?filter=state:<%=addr.getState()%>:city:<%=addr.getCity()%>&"><%=addr.getCity()%></a></td>
<td><a href="/getList?filter=state:<%=addr.getState()%>&"><%=addr.getState()%></a></td>
<td><%=addr.getZipcode()%></td>
<td><%=addr.getPlus4()%></td>
</tr>
<%
}
// Release the resultList object
session.removeAttribute("resultList");
%> <tr class="status">
<td colspan=6>
<span class="left">&nbsp;Page x of y</span>
<span class="right">
<input class="status" type="button" value="prev">
<input class="status" type="button" value="next">
</span>
</td>
</tr>
</table>
</body>
</html>

9
checklogin.jsp

@ -0,0 +1,9 @@
<%
String user = (String) session.getAttribute("user");
if(user == null) {
%>
<jsp:include page="/login" flush="false"/>
<%
}
%>

14
endSession.jsp

@ -0,0 +1,14 @@
<% session.invalidate(); %>
<%! static String pageTitle = "Session Ended"; %>
<%@ include file = "include/pageHeader.jsp" %>
<body bgcolor="#f7f7f7">
<center>
<br><br>
<b class="title"><%= pageTitle %></b>
<br><br><br>
<form name="form" method=POST action="/index.jsp">
<input type="submit" value="New Session"/>
</form>
</center>
</body>
</html>

BIN
images/750px.png

After

Width: 750  |  Height: 20  |  Size: 359 B

BIN
images/766px.png

After

Width: 780  |  Height: 50  |  Size: 1.5 KiB

13
include/pageHeader.jsp

@ -0,0 +1,13 @@
<% out.clear(); // clear out those extra newlines
%><?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><%= pageTitle %></title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<meta name="author" content="jimi(bcs)">
<meta name="title" content="<%= pageTitle %>">
<link rel="stylesheet" href="style/common.css" type="text/css">
</head>

1
index.jsp

@ -0,0 +1 @@
<jsp:forward page="getList?orderby=name&limit=22&"/>

25
login.jsp

@ -0,0 +1,25 @@
<%! static String pageTitle = "Application Login"; %>
<%@ include file = "include/pageHeader.jsp" %>
<body bgcolor="#f7f7f7" onload="document.login.j_username.focus();">
<center>
<p style="margin-top: 3em">
<table class="login">
<th colspan=2>User Login</th>
<form method="post" action="j_security_check" name="login">
<tr>
<td class="label">Username:</td>
<td class="form"><input type="text" name="j_username" size="20"/></td>
</tr>
<tr>
<td class="label">Password:</td>
<td class="form"><input type="password" name="j_password" size="20"/></td>
</tr>
<tr>
<td colspan=2 align="center">
<input type="submit" value="Login" class="login"/></td>
</tr>
</form>
</table>
</center>
</body>
</html>

52
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" %>
<body <%=backgroundColor%>>
<div class="head">
<table <%=listWidth%> class="hidden">
<tr class="hidden">
<td><b class="title">Address List</b><td>
<td>
<form method="get" action="getData" style="float: right">
<b class="label">Search:</b>
<input type="text" name="filter" size=20 />
</form>
</td>
</tr>
</table>
</div>
<div class="tabular">
<table <%=listWidth%>>
<!-- table header -->
<th style="width: 33%"><a href="/getList?orderBy=name">Name</a></th>
<th style="width: 34%">Street</th>
<th style="width: 15%"><a href="/getList?orderBy=city">City</a></th>
<th style="width: 5%"><a href="/getList?orderBy=state">ST</a></th>
<th style="width: 7%"><a href="/getList?orderBy=zipcode">Zip</a></th>
<th style="width: 6%">+4</th>
<!-- table data -->
<db:addresslist><tr class="<%=shade%>">
<td><a href="/getDetail?id=<%=id%>"><%=name%></a></td>
<td><%=street%></td>
<td><a href="/getList?city=<%=city%>&state=<%=state%>"><%=city%></a></td>
<td><a href="/getList?state=<%=state%>"><%=state%></a></td>
<td><%=zip%></td>
<td><%=plus4%></td>
</tr>
</db:addresslist></table>
</div>
<!-- page footer -->
<div class="foot">
Session ID: <%= session.getId() %><br>
Session is new: <%= session.isNew() %><br>
Session variables:
<% java.util.Enumeration sess = session.getAttributeNames();
while(sess.hasMoreElements()) {
out.print(sess.nextElement() + " ");
}
%>
</div>
</body>
</html>

94
style/common.css

@ -0,0 +1,94 @@
<!-- common.css
body, table, input, textarea {
font-family: Verdana, Helvetica;
font-size: 9pt;
}
body {
border: none;
padding-left: 1%;
}
a {
color: #000000;
text-decoration: none;
}
table.login {
font-size: 9pt;
width: 200pt;
border: outset 1pt;
}
.login {
background-color: #dfdfdf;
}
table.data {
width: 98%;
background-color: #f7f7f7;
border: none;
}
tr {
vertical-align: baseline;
}
td, th {
padding: 1pt;
}
th {
font-weight: bold;
background-color: #b0c4de;
border: outset 1px;
}
td {
border-width: none;
border-style: none;
}
.right {
float: right;
}
.left {
float: left;
}
.title {
font-size: 16pt;
font-weight: bold;
font-style: italic;
}
.label {
font-size: 9pt;
font-weight: bold;
text-align: right;
}
.form {
font-size: 9pt;
}
.header {
background-color: #f7f7f7;
}
.light {
background-color: #efefef;
border-width: 1pt;
border-style: none;
}
.dark {
background-color: #e7e7e7;
border-width: 1pt;
border-style: none;
}
.status {
font-family: Lucida Console;
font-size: 7pt;
background-color: #dfdfdf;
border-width: 1pt;
border-style: none;
}
.boxed {
border-style: solid;
border-width: 1px;
border-color: black;
}
input.small {
font-family: Arial;
font-size: 7pt;
background-color: #e7e7e7;
border-width: 1px;
width: 27pt;
height: 13pt;
}
-->

185
style/old.css

@ -0,0 +1,185 @@
<!-- common.css
body {
font-family: Helvetica;
margin-left: 3%;
margin-right: 3%;
}
a {
color: Black;
text-decoration: none;
}
p {
font-family: Helvetica;
margin-top: none;
margin-bottom: none;
padding: none 3pt;
}
h1,h2,h3,h4,h5,h6 {
font-family: Helvetica;
}
.title {
font-size: 18pt;
font-style: italic;
font-weight: bold;
}
.boxed {
background-color: transparent;
border-color: black;
border-width: 1px;
border-style: solid;
}
h1 {
font-size: 11pt;
font-weight: bold;
background-color: #d3d3d3;
border: outset 1pt;
}
h3 {
font-size: 9pt;
font-weight: bold;
background-color: #b0c4de;
border: outset 1pt;
}
p.title {
background-color: #cccccc;
font-size: 12pt;
font-weight: bold;
border: outset 1pt;
}
p.heading {
background-color: #b0c4de;
font-size: 9pt;
font-weight: bold;
border: outset 1pt;
}
p.content {
font-family: Helvetica;
font-size: 9pt;
}
p.list {
margin-top: -1em;
margin-left: 3%;
}
form {
font-family: Helvetica;
font-size: 9pt;
}
table {
font-family: Helvetica;
font-size: 9pt;
background-color: #d3d3d3;
border-style: outset;
border-width: 1pt;
margin-left: 2%;
width: 96%;
min-width: 740px;
}
table.entry, table.data {
border-style: none;
background-color: #dedede;
}
table.hidden {
background-color: #f0f0f0;
border-width: none;
border-style: none;
margin-left: 3%;
width: 94%;
vertical-align: bottom;
}
table.third {
margin-left: 33%;
width: 34%;
background-color: inherit;
border-style: inset;
}
table.login {
margin-left: 35%;
width: 30%;
min-width: 200px;
border-width: 1pt;
border-style: outset;
}
thead,th {
font-weight: bold;
border-width: 1pt;
border-style: outset;
padding: inherit;
background-color: #b0c4de;
}
tr {
font-weight: normal;
border-width: inherit;
border-style: none;
padding: inherit;
}
td {
border-width: inherit;
border-style: inherit;
}
td.status {
font-family: Helvetica;
font-size: 7pt;
background-color: #dadada;
border-style: none;
border-width: 1px;
}
.label {
font-weight: bold;
padding-left: 9pt;
text-align: right;
}
.field {
font-weight: normal;
padding-right: 9pt;
padding-top: 2pt;
padding-bottom: 2pt;
font-size: 8pt;
text-align: left;
}
.inset {
border-style: inset;
border-width: 1pt;
}
.outset {
border-style: outset;
border-width: 1pt;
}
.center {
text-align: center;
}
.light {
background-color: #f0f0f0;
}
.dark {
background-color: #e5e5e5;
}
-->

269
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));
}
%>
<html>
<head>
<title>Test Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style/common.css" rel="stylesheet" type="text/css">
</head>
<body>
<table cellpadding="0" cellspacing="2" class="data">
<tr>
<th>name</th><th>street</th><th>city</th><th>state</th><th>zipcode</th>
</tr>
<% int row = 0; while ((AddressList_hasData)&&(Repeat1__numRows-- != 0)) { %>
<tr class="<%=(row++ % 2 == 1) ? "dark" : "light"%>">
<td><%=(((AddressList_data = AddressList.getObject("name"))==null || AddressList.wasNull())?"":AddressList_data)%></td>
<td><%=(((AddressList_data = AddressList.getObject("street"))==null || AddressList.wasNull())?"":AddressList_data)%></td>
<td><%=(((AddressList_data = AddressList.getObject("city"))==null || AddressList.wasNull())?"":AddressList_data)%></td>
<td><%=(((AddressList_data = AddressList.getObject("state"))==null || AddressList.wasNull())?"":AddressList_data)%></td>
<td><%=(((AddressList_data = AddressList.getObject("zipcode"))==null || AddressList.wasNull())?"":AddressList_data)%></td>
</tr>
<%
Repeat1__index++;
AddressList_hasData = AddressList.next();
}
%>
<tr valign="bottom" class="status">
<td colspan=5>
<span class="left">
<%=(AddressList_first)%> to <%=(AddressList_last)%> of <%=(AddressList_total)%>
</span>
<span class="right">
<% if (MM_offset !=0) { %>
<a href="<%=MM_movePrev%>"><img src="Previous.gif" border=0></a>
<% } /* end MM_offset != 0 */ %>
<% if (!MM_atTotal) { %>
<a href="<%=MM_moveNext%>"><img src="Next.gif" border=0></a>
<% } /* end !MM_atTotal */ %>
</span>
</td>
</tr>
</table>
</body>
</html>
<%
AddressList.close();
StatementAddressList.close();
ConnAddressList.close();
%>

139
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;
%>
<html>
<head>
<title>Test Document 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
<%
addressData.close();
StatementaddressData.close();
ConnaddressData.close();
%>

178
test.html

@ -0,0 +1,178 @@
<html>
<head>
<title>HTML 4.0 Test Page</title>
<style type="text/css">
<!--
body, table, input {
font-family: Arial, Helvetica;
font-size: 8pt;
}
body {
border: none;
padding-left: 1%;
}
table.data {
width: 98%;
background-color: #f7f7f7;
border: none;
}
tr {
vertical-align: baseline;
}
td, th {
padding: 1pt;
}
th {
background-color: #b0c4de;
border: outset 1px;
}
td {
border-width: inherit;
border-style: inherit;
}
.right {
float: right;
}
.left {
float: left;
}
.title {
font-size: 22pt;
font-weight: bold;
font-style: italic;
}
.label {
font-size: 9pt;
font-weight: bold;
text-align: right;
}
.header {
background-color: #f7f7f7;
}
.light {
background-color: #efefef;
border-width: 1pt;
border-style: none;
}
.dark {
background-color: #e7e7e7;
border-width: 1pt;
border-style: none;
}
.status {
font-family: Lucida Console;
font-size: 7pt;
background-color: #dfdfdf;
border-width: 1pt;
border-style: none;
}
input.small {
font-family: Arial;
font-size: 7pt;
background-color: #efefef;
border-width: 1px;
width: 27pt;
height: 13pt;
}
-->
</style>
</head>
<body bgcolor="#f7f7f7" onload="document.search.filter.focus();">
<table class="data" cellpadding=2 cellspacing=2>
<colgroup>
<col><!-- Name -->
<col><!-- Street -->
<col size=16em><!-- City -->
<col size=2em><!-- State -->
<col size=5em><!-- Zipcode -->
<col size=10em><!-- Phone -->
</colgroup>
<tr class="header">
<td colspan=2 class="title">Contact List</td>
<form name="search">
<td colspan=4 align=right><b class="label">Search:</b>
<input type="text" name="filter" style="width: 140pt"/></td>
</form>
</tr>
<!-- Table Headers ----->
<th>Name</th>
<th>Street</th>
<th>City</th>
<th>ST</th>
<th>Zip</th>
<th>Phone</th>
<!---------------------->
<tr class="light">
<!--.---+----1----+----2----+----3----+----4----+----5-->
<td>This 30 character Company Name</td>
<td>My 30 character Street Address</td>
<td>Rancho Cucamonga</td>
<td>CA</td>
<td>99999_</td>
<td>(800) 555-1212</td>
</tr><!---+----1----+----2----+----3----+----4----+----5-->
<tr class="dark">
<td>2</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="light">
<td>3</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="dark">
<td>4</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="light">
<td>5</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="dark">
<td>6</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="light">
<td>7</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="dark">
<td>8</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="light">
<td>9</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="dark">
<td>10</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="light">
<td>11</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="dark">
<td>12</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="light">
<td>13</td><td>&nbsp;</td><td>&nbsp;</td>
<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
</tr>
<tr class="status">
<td colspan=6>
<span class="left">&nbsp Page 1 of 2</span>
<span class="right">&lt prev &nbsp next &gt &nbsp</span>
</td>
</tr>
</table>
<form>
<input type="button" value="save" class="small">
<input type="button" value="reset" class="small">
<input type="button" value="delete" class="small">
<input type="text" width=30>
<input type="submit" value="submit" class="small">
</form>
</body>
</html>

52
testpage.jsp

@ -0,0 +1,52 @@
<%! static String pageTitle = "Snoopy"; %>
<%@ page info="test area" %>
<%@ page import="java.util.Enumeration" %>
<%@ include file="include/pageHeader.jsp" %>
<body style="background-color: #f0f0f0">
<div>
<h1>Header And Session Snooper</h1>
<h3>Header Contents:</h3>
<p class="content">
<%
Enumeration header = request.getHeaderNames();
while(header.hasMoreElements()) {
String name = header.nextElement().toString();
String value = request.getHeader(name);
out.println(" " + name + " = " + value + " <br>");
}
%>
<h3>Request Parameters:</h3>
<p class="content">
RemoteUser = <%= request.getRemoteUser() %> <br>
SessionID from cookie: <%= request.isRequestedSessionIdFromCookie() %> <br>
SessionID from URL: <%= request.isRequestedSessionIdFromURL() %> <br>
<%
Enumeration arglist = request.getParameterNames();
while(arglist.hasMoreElements()) {
String name = arglist.nextElement().toString();
String value = request.getParameter(name);
out.println(" " + name + " = " + value + " <br>");
}
%>
<h3>Session Contents:</h3>
<p class="content">
sessionId: <%= session.getId()%> <br>
maxInactiveInterval: <%= session.getMaxInactiveInterval() %> seconds <br>
sessionAttributes: <br>
<p class="list">
<% Enumeration enum = session.getAttributeNames();
while(enum.hasMoreElements()) {
String attr = enum.nextElement().toString();
String val = session.getAttribute(attr).toString();
out.println(" " + attr + " = " + val + " <br>");
}
%>
<hr>
<form method=GET action="/endSession.jsp" class="center">
<input type="submit" value="End Session"/>
</form>
</div>
</body>
</html>