protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
String name = request.getParameter("name").toString();
ArrayList a = new ArrayList();
int y =a.size();
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = null;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db, user, pass);
try{
Statement st = con.createStatement();
ResultSet res = st.executeQuery("SELECT employee FROM employ ");
while (res.next()) {
String s = res.getString("employee");
int len=name.length();
String x= s.substring(0,len);
if(x.equalsIgnoreCase(name))
{
System.out.println(s);
a.add(s);
}
}
if(a.size()<1)
{
response.sendRedirect("noemp.jsp");
}
else
response.sendRedirect("empresult.jsp");
con.close();
}
catch (SQLException s){
System.out.println("SQL code does not execute.");
}
}
catch (Exception e){
e.printStackTrace();
}
// TODO Auto-generated method stub
}
}
how do i access array list "a" in my jsp page?????????????