0

I was trying to redirect after an alert message in servlet something like this :

out.println("<script>alert('Group Request Invitation Canceled');document.location='individualdetailstoadd.jsp?personid=''"+idperson+"'</script>");

But its not working.Though if I remove the redirection,the alert message is displayed . What can be the reason ?Please help

user3522121
  • 215
  • 3
  • 10
  • 23

1 Answers1

0

You do not need the single quotes before the double quotes.

Try

out.println("<script>alert('Group Request Invitation Canceled');document.location='individualdetailstoadd.jsp?personid="+idperson+"'</script>");

The generated HTML will be along the following lines:

<!DOCTYPE HTML>
<html>
<body>
<script>
alert('Group Request Invitation Canceled');
document.location='individualdetailstoadd.jsp?personid=5'</script>

</body>
</html>

I tested this in my browser and it redirects successfully.

David Brossard
  • 13,584
  • 6
  • 55
  • 88