java response.sendredirect_重定向是发生的问题。response.sendRedirect()

我的一个JSP文件中有这样一条语句:

response.sendRedirect("rmailerror.jsp");

在有的JSP中可以执行,有的JSP中就出现这样的错误提示:

type Exception report

message Internal Server Error

description The server encountered an internal error (Internal Server Error) that prevented it from fulfilling this request.

exception

java.lang.IllegalStateException: Cannot forward after response has been committed

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:367)

重点是这里:(Cannot forward after response has been committed)

为什么 response 会被禁止呢???

|

可以用下面的函数实现之,无此限制

-1)

{

wsStr=new wsString();

String[] url_a=wsStr.split(url,"|");

url_t=url_a[1];

url_lnk=url_a[0];

}

else

{

url_t="0";

url_lnk=url;

}

String tmp="";

return tmp;

}

%>

|

response.sendRedirect是通过设置http头来实现的,如果你已经输出网页的一部分了,就不能设置http头。

这与jsp引擎的实现有关。如果它是对输出进行缓存,最后才输出,那么就可以设置http头,否则哪怕你只输出了一个字符,也不能再设置http头了。

另一个指令flush也与此有关。

|

http://www.csdn.net/expert/topic/791/791072.xml?temp=.6192896

package walksing.string;

import java.text.*;

import java.util.*;

public class wsString

{

/***$id added by WalkSing [wcsz@mail.china.com] 2003-03-22 9:57 ***/

public String Jreplace(String S,String T,String I)

{  /*$id:walksing walksing@163.com 2002-03-12 9:57 make.

*para S --Source String will  find to be replaced String,which will be overwrite with T;

*para T --Target String which will overwrite S;

*para I --Input String from which to find;

*return String replacement Result;

*note:S,T,I can be String Type;

*ver 1.0;

*/

if (I.length()

您可能感兴趣的文章:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值