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

Search in DATABASE with jsf  RSS feed

 
asmaa kellal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

hello
I want a sample code for search data in DB oracle I can show all my data in a jsp page with the request
(select * from mytable) but what I need is View by entering a keyword with the request (select * from mytable where id ="+v+")

the question is how we can get "v" (enter value)
and show only the corresponding elements

could you help me please
thank you
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asmaa,
Here is an example of how to accomplish it using a servlet.
First, the HTML form:

Next a snippet of the servlet code:

Good Luck,
Avi.
 
asmaa kellal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Avi for this code which was useful

but i still need your help

here code
search.jsp



what i need is display the text zone empty for name and city before research but when I introduce the keyword and click search their content appears in the text zone
how I can change my code to realize this
can you help me please
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asmaa,
You have combined into one JSP page both the form for entering the search criteria and the displaying of the search results.
I suggest you split these and put them in separate pages, i.e. one page for entering the search criteria and one page for displaying the search results.

Good Luck,
Avi.
 
asmaa kellal
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

but my purpose is to search and display the result in the same page

and why I must separate them...
Is this wrong what I did
give more explication please Avi
I need your help
thanks

 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Asmaa,
Your question leads me to believe that you don't really understand how JSP works.
If you haven't already done so, I suggest investing in reading a good book on the subject.
Entering search criteria and displaying the search results is so ubiquitous I would suggest that nearly any book on JSP will contain an example of doing such.
I don't think that it is appropriate for me to put in a post on a JavaRanch forum what essentially would be the contents of a book on JSP.

Good Luck,
Avi.
P.S. By the way, I'm surprised this thread has not been moved to a more appropriate forum, as I don't see JSF mentioned anywhere in it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!