I have a select list of 300+ names. The way I want to do it is to have that list built and cached on startup so that the html that is displaying that list will be done on startup not each time the page is rendered.
so what I am trying to do is use application variables to store the list of names
Not sure whats wrong with this code.
public class SomeList extends HttpServlet{
private
String listOfSome;
public void init(){
}
public void service(HttpServletRequest req,HttpServletResponse resp){
private void getSome() throws DataLayerException
{
Connection Connection = null;
Connection = ConnectionFactory.getConnection();
synchronized(Connection)
{
try
{
listOfSome = "";
Statement Statement = Connection.createStatement();
ResultSet rs = Statement.executeQuery("SELECT row1, row2, row3, row4, row5 FROM table WHERE row6=aa order by row3");
String row5="";
while (rs.next())
{
if(rs.getString(4) != null){city = rs.getString(4);}
listOfDealer += "<option value=" + rs.getString(1) + ">"+ rs.getString(2) +","+ rs.getString(3) +","+ row5 +","+ rs.getString(5) + "</option>";
}
if (rs !=null) rs.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
public String getListOfSome() throws DataLayerException {
getSome();
this.getServletConfig().getServletContext().setAttribute("listOfSome",listOfSome);
//return listOfSome;
}
}