Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Show error message using alert  RSS feed

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a JSP page for creating a user for an application.
That has two pages, in the first page User's Personal details like userId , name and other params are got.In the next page User's privileges are assigned.

Is there any possible way to check whether the provided userName already exists in the first page itself and show the errormessage in alert().

In the current scenerio user details are obtained ( first & 2nd page )
Then i'm contacting the DB for creating a user.If the user already exists i'm redirecting to an errorPage showing the exception.

I want the above process to happen in the first page with an alert message showing the error and not redirectin to an error page.

Is that possible. In the other way is it possible to access a java code in a script.


Srini
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to go to the server side for checking this. otherwise you have to load all the names from DB in some collection and set that collection to any relevent scope. but it is really a bad idea.

i think better option is to have a link or button there, on the page, to check the availablity of the user name. i.e. you can see this idea implemented at yahoo email account registration, gmail account registration.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So adeel,
you mean to redirect to the first page again when there is any error ?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah if record found then display any suitable message on the same page like, "sorry the chosen user name already exist", or something like that.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srini,

instead of submitting whole page or redirecting back, I would prefer to check availability of user in a pop.

which will be invoked on clicking the check availability link. same time it will update a flag in parent page.

but in any case every time you will have to handle same before inserting to avoid error in multi-user scenario
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Shailesh thats also a gud idea.
Thanks.
Srini
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shailesh Chandra:
Srini,

instead of submitting whole page or redirecting back, I would prefer to check availability of user in a pop.


there is no mean of sending the whole page because then it means you are not checking it before submittion, you are checking it on submittion, right??

what i said is the same, check the availablity of user name, not all the fields.

thanks.
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by srini vasan:
you mean to redirect to the first page again when there is any error ?


I elaborated adeel's point only while replying above. :roll:
[ October 26, 2004: Message edited by: Shailesh Chandra ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!