How to invoke a Servlet or java method onSubmit ?

I am creating a Form in a Servlet.

e.g

<FORM ACTION="/servlet/addUser" onSubmit=? >

Lastname <INPUT TYPE ="text" NAME =lname >

Firsnname <INPUT TYPE ="text" NAME =fname >

<INPUT TYPE=submit name =submit value ="submit">

Now on hitting the submit button I need to check if a duplicate lastname exists in the database by invoking a servlet method and only if a duplicate does not exist I want to submit the form .

Since as I understand onSubmit can only invoke a Javascript method , how can I really invoke a servlet method to check for duplicate before addUser is invoked.

Thanks

S

[674 byte] By [sudipk] at [2007-9-26 7:52:44]
# 1

hi

sorry,i dont have a solution for ur problem.

but,

i dont think it is a good idea to invoke two servlets

just for validation.u can do that on the client side itself

by populating the a javascript array with the lastname

while invoking this form.

just a suggession though...

prasad

prasad_pn at 2007-7-1 18:05:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi!I think it's not good to use javascript and jsp. You can do the check in the addUser Servlet. If it exists, you can displaya messsage and go back to the original site.Regards,Geri
ge_ha at 2007-7-1 18:05:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
petstore give a very nice solution using handlers.did you see the accounthandler and account components in the petstore and how they track exception duplicateaccountexception
Dguimard at 2007-7-1 18:05:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...