Methods Summary |
---|
public void | doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
doPost(req, res);
|
public void | doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
String state = (String) req.getParameter("state");
if (state != null)
{
res.setContentType("text/xml");
res.setHeader("Cache-Control", "no-cache");
res.getWriter().write(getCities(state));
}
|
private java.lang.String | getCities(java.lang.String state)
Connection con = DatabaseConnector.getConnection();
StringBuffer sb = new StringBuffer("<select name=\"citySelected\">");
try
{
Statement statement = con.createStatement();
String sqlString = "SELECT DISTINCT CITY FROM ZIPCODES WHERE STATE='"
+ state + "' ORDER BY CITY;";
ResultSet resultSet = statement.executeQuery(sqlString);
while (resultSet.next())
{
sb.append("<option>" + resultSet.getString(1) + "</option>\n");
}
}
catch (Exception e)
{
System.out.println("exception caught getting cities for " + state);
}
finally
{
sb
.append("</select> <ajax:event ajaxRef=\"CitySelectForm/citySelectionChange\"/>");
if (con != null)
{
try
{
con.close();
}
catch (SQLException e)
{
}
}
}
return sb.toString();
|
private java.lang.String | getStates(java.lang.String city)
Connection con = DatabaseConnector.getConnection();
StringBuffer sb = new StringBuffer("<select>");
try
{
Statement statement = con.createStatement();
String sqlString = "SELECT DISTINCT STATE FROM ZIPCODES where CITY='"
+ city + "';";
ResultSet resultSet = statement.executeQuery(sqlString);
while (resultSet.next())
{
sb.append("<option>" + resultSet.getString(1) + "</option>\n");
}
}
catch (Exception e)
{
System.out.println("exception caught getting states from zipcodes table");
}
finally
{
sb.append("</select>");
if (con != null)
{
try
{
con.close();
}
catch (SQLException e)
{
}
}
}
return sb.toString();
|