Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

processing sql queries from JSP  RSS feed

 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bindesh Vij
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm....

It seems like you are starting ur life with JSP. I think you should download a Servlets and Jsp book available and study it..
One of the links i know (and that too recently.. is serverside.com


bye...
 
Gert Cuppens
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!