Hai Guys, I am having JSP page with 4 textbox's (say empid, name, job,dept) and a search button.The user may enter data in all fields or may be some fields.and when he press submit button the JSP page has to fetch data from database based on the data provided by the user in the fields. EX: if the user enetred only job and press submit then the JSP has to display all the records with the job specified. and if he give only job and dept values then it has to display records only in that dept and job. pzl help me how to do this. thanks and regards, Mahesh
You're just going to read the HTTP parameters associated with those textfields to see what data the user supplied and build a SQL query based on this... preferably with the SQL query being encapsulated in a JavaBean/EJB/etc.
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
There's another very good book, namely "core servlets and Java Server Pages" from Marty Hall. You can buy the second edition or download the first edition fro free in pdf format at www.coreservlets.com.
And I agree with Nathan : you should avoid putting SQL statements in JSP's. So, try to find out how the Model-View-Controller design pattern works. I recommend the "Apache Tomcat Bible" from Eaves, Jones & Godfrey. It explains how to download and install the J2SDK, Tomcat, MySQL, Ant, Eclipse and it provides an example web application built following the MVC guidelines. A very good book if you're starting to find your way in the JSP-servlets world.