I have a JSP which i want to search for products from the database, so hope this is in the right place but it uses JSP aswell as JDBC so i'm assuming it is.
Firstly, when the JSP loads it automatically brings up results even before i have entered anything in the search field.
Could someone please tell me how to stop this? I do have normal checks like
if (queryText != null) ...
etc. but it still seems to do it.
And secondly, it seems to keep on bringing up the same results from the database, but i am selecting from 2 tables - product and price. But the weird thing is that
it shows the same product id basically, but then on the next result it shows it with a different price.
Thirdly, i am only wanting to display products where the current date is less than 'sellto' date column, and have a method to get the date and enter in my sql statement but it still brings up older dates. Here is the code snippet for this
sql += " AND product.sellto > '" + curDate + "'" ;
sql += "AND price.productid = product.id ";
sql += "LIMIT 5;";
This is my method for getting the current date
public String getDate() {
curDate = "";
Calendar cal = new GregorianCalendar();
int day = cal.get(Calendar.DATE);
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
curDate += year + "-" + month + "-" + day;
return curDate;
}
Please if anyone can advise me on what to do, or where i'm going wrong, it'll be much appreciated.
Thanks!