English 中文(简体)
贾瓦:菲律宾统计局停止在其余网页上执行。
原标题:Java: JSP halt execution on rest of page

你们如何阻止共同财产计划的执行?

我有联合材料,用“前线”的方式将用户点上下。

public boolean kickIfNotLoggedIn(
        HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    //code to check if user is logged in
    req.getRequestDispatcher(
            ACCESS_DENIED_PAGE).forward(request, response);
}

在我的联合调查组中,我有这一代码,即任何超文本产出:

<%
            //loginHelper.kickIfNotLoggedIn(request, response);
            if (!loginHelper.kickIfNotLoggedIn(request, response)) {
                return;
            }
%>

如果我不使用返回声明,联合调查组将继续处理,我收到Null PointerException。 如果我使用返回声明(如在净值各种来源上通常建议的那样),我就会发现非法国家:

StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: PWC3991: getOutputStream() has already been called for this response
        at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:717)
        at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:226)
        at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:187)

任何关于如何确定这种说法的想法,或实现一个被否定的页面访问的另一种方式?

增 编

最佳回答

你可以这样做。 错误信息是很不明确的,但必须着手以一种资源作出反应,停止,然后向试图重新处理吉大港山区问题对策的另一个资源迈进。

在需要标识的所有联合项目之前,使用一个服务器<代码>Filter,在任何联合项目甚至触及应对措施之前,重新定位。

问题回答

使用:

req.getRequestDispatcher(ACCESS_DENIED_PAGE).redirect(request, response);

确保你要求检查许可是避免这一错误信息的第一页。

“权利”方式当然是一种过滤器,但可能太涉及你们需要的东西。 在任何情况下:

http://java.sun.com/products/servlet/Filters.html

共同财产计划的一个令人痛心之处是,任何空间都会导致外层空间的裂缝(至少是散射)。 例如,以下法典将失败:

<%@ page import="javax.servlet.ServletOutputStream" %>

<%
  //note the blank line above^
  ServletOutputStream out = response.getOutputStream();
  //write some data...
%>

由于进口区和编码区之间的空白线被目录视为产出的一部分,因此将给作者带来两条新线。 因此,你需要工作,确保法典中不存在任何外在性质:

<%@ page import="javax.servlet.ServletOutputStream" %><%
  //no blank line, this will work OK
  ServletOutputStream out = response.getOutputStream();
  //write some data...
%>

如今,法典各栏之间没有特性,因此目录不会试图产生产出。 我的猜测是你例外的原因。 也就是说,这更加迅速、 d脏,像海恩所建议的那样,可能更适当的解决办法。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签