File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Check value is Exist in the database and transfer the page

 
Podal Au
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Murugesa Boopathy
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • 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
}
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic