• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

script before redirecting

 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i want to display a message(through alert box of JavaScript) if updation of record is successful and then user will redirected to main page.
i am updating the database through servlet then if updation will successfull response forwarded to another page which is required to display alertbox first and then will redirect user to main page.
but it's redirecting without showing alertbox.
I put the script in head tag but ...

How could i solve this problem.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
87
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post an SSCCE showing the problem.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
UpdateServlet


success.jsp
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
87
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yeah, you're redirecting. That means, don't go here, go there!
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes because i can achieve it through it from servlet so i required some intermediate JSP
but i want this redirection after displaying that alert box.

What to do to achieve that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64994
87
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Personally, I'd be using Ajax to submit the operation so that I had complete control over what happens when it terminates, either successfully or not.

But to do it with pages, I'd probably suggest using JavaScript to perform the redirection after the alert. (Alert is blocking.) But that's all kind of primitive.
 
Singh Anisha
Ranch Hand
Posts: 100
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:jumpingjoy:
Now its working the way i wanted.
Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic