*
The moose likes JSP and the fly likes Check value is Exist in the database and transfer the page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Check value is Exist in the database and transfer the page" Watch "Check value is Exist in the database and transfer the page" New topic
Author

Check value is Exist in the database and transfer the page

Podal Au
Greenhorn

Joined: Dec 11, 2012
Posts: 2
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

Joined: Jul 16, 2012
Posts: 136
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

Joined: Dec 11, 2012
Posts: 2
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

Joined: Dec 14, 2012
Posts: 1
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
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Check value is Exist in the database and transfer the page
 
Similar Threads
request.getParameter() from same page as HTML FORM
alernate for session??
method="POST"
Check for ActiveX from JSP
how a servlet can return value to a html?