do.jsp为wills.htm的响应页面,
do.jsp有如下一段代码...
if(e)
{
response.sendRedirect("wills.htm");
out.write("<script>alert('Error occured.');location='wills.htm';</script>");
return;
}
...测试时发现,do.jsp页面可实现检测(boolean) e变量的功能,并实现页面跳转,但不能弹出出错提示框.
请问怎么实现?

解决方案 »

  1.   

    response.sendRedirect("wills.htm");以后当前页面就执行完成了,以后的代码不会再执行的
    想要弹出把提醒和跳转都写到script里。
      

  2.   

    script中可以用response.sendRedirect()方法吗
      

  3.   

    不可以用,,,你上面的代码不会是script中写的吧??
      

  4.   

    不是啊,都是<%  %>里的,谁知道怎么办啊
      

  5.   

    keyong19ryry(随风逐月) 说得对
    你把response.sendRedirect("wills.htm");
    写在前面,也就是说在执行
    out.write("<script>alert('Error occured.');location='wills.htm';</script>");
    之前
    已经重定向到wills.htm了.
    response.sendRedirect("wills.htm");后面的语句就不执行了.
    还有就是 你的out.write("<script>alert('Error occured.');location='wills.htm';</script>");
    可能有问题.没有指明languange=""
      

  6.   

    script 中加上type='text/javascript'试试
      

  7.   

    response.sendRedirect( "wills.htm ");
    out.write( " <script> alert( 'Error   occured. ');location= 'wills.htm '; </script> "); 改成这个out.write( " <script> alert( 'Error   occured. ');location.href= 'wills.htm '; </script> "); 
      

  8.   

    加了response.sendRedirect( ""); 进行跳转控制  在输出JavaScript是不起作用的 经验之谈  完全可以用JavaScript来控制跳转  别忘了location后面还有个.href
      

  9.   

    你那页面原先已经跳转了,再谈出对话框没用
    out.print("<script>alert('');window.href='';</script>");
      

  10.   

    想输出弹出框就别用response跳转
      

  11.   

    response.sendRedirect( "wills.htm "); 
    它下面的代码没执行
      

  12.   

    response.sendRedirect( "wills.htm "); 已经完成了网页跳转。
      

  13.   

    if(e) 

    response.sendRedirect( "wills.htm "); //这行都跳转了页面了。下面的JS代码怎么可能还会之行呢。out.write( " <script> alert( 'Error   occured. ');location= 'wills.htm '; </script> "); 
    return; 
      

  14.   

    out.write( " <script> alert( 'Error   occured. ');location= 'wills.htm '; </script> "); 
    我也觉得这句应该放在response前面~~~~~~~~~~
    你页面都转发了,当然弹不出对话框