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 = req.getParameter("state");
String city = req.getParameter("city");
String function = req.getParameter("function");
if(AAUtils.isAjaxRequest(req))
{
HttpSession session = req.getSession();
if(function.equals("city"))
{
AAUtils.addZonesToRefresh(req, "stateswcityList");
session.setAttribute("stateList", getStates(city));
}
else if(function.equals("state"))
{
AAUtils.addZonesToRefresh(req, "citiesList");
session.setAttribute("cityList", getCities(state));
}
}
String url = "/index.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, res);
|
private java.util.Collection | getCities(java.lang.String state)
ArrayList cityList = new ArrayList();
Connection con = DatabaseConnector.getConnection();
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())
{
cityList.add(resultSet.getString(1));
}
}
catch(Exception e)
{
System.out.println("exception caught getting cities for " + state);
}
finally
{
if(con != null)
{
try
{
con.close();
}
catch(SQLException e)
{
}
}
}
return cityList;
|
private java.util.Collection | getStates(java.lang.String city)
ArrayList stateList = new ArrayList();
Connection con = DatabaseConnector.getConnection();
try
{
Statement statement = con.createStatement();
String sqlString = "SELECT DISTINCT STATE FROM ZIPCODES where CITY='" + city + "' ORDER BY STATE;";
ResultSet resultSet = statement.executeQuery(sqlString);
while (resultSet.next())
{
stateList.add(resultSet.getString(1));
}
}
catch(Exception e)
{
System.out.println("exception caught getting states from zipcodes table");
}
finally
{
if(con != null)
{
try
{
con.close();
}
catch(SQLException e)
{
}
}
}
return stateList;
|