• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Check value is Exist in the database and transfer the page

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I am new to JSP. My work is i have a page with some text boxes and submit button. When the user enters data in the textboxes and submit, i need to check the value (like ID) in the first textbox is already in the database or not. If already available need to show error message and page not need to post back. If value is not available need to the next page.

How can i achieve this? If not database related we can simply write JavaScript to validate and return based on the result. But how in server side script?
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Podal,

Welcome to coderanch.
Could you please post what you have tried so far so that we can help you do it better or solve if you have any problem.

Thanks
 
Podal Au
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I wrote the code to pass the value and return that value is in database or not. But i have a confusion that how i call the method in my submit button
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use count function in sql.

Consider the id is the unique value in Database.

select count(id) where id=your id

if(count>1)
{
//already exist
}
else
{
//add
}
 
Look ma! I'm selling my stuff!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic