Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Servlets Seam和ServletOutputStream-flush不立即可见_Servlets_Seam_Weblogic 10.x - Fatal编程技术网

Servlets Seam和ServletOutputStream-flush不立即可见

Servlets Seam和ServletOutputStream-flush不立即可见,servlets,seam,weblogic-10.x,Servlets,Seam,Weblogic 10.x,我正在将一个6年的应用程序转换为Seam 2.2。 该应用程序用于在Java1.4和WebLogic8中运行。 它只使用jsp和servlet。 在一个servlet中,我使用: public void doGet (HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { //... ServletOutp

我正在将一个6年的应用程序转换为Seam 2.2。 该应用程序用于在Java1.4和WebLogic8中运行。 它只使用jsp和servlet。 在一个servlet中,我使用:

    public void doGet (HttpServletRequest req,HttpServletResponse res) throws  ServletException,IOException
        {
            //...

            ServletOutputStream out = = res.getOutputStream();

            // displaying a lot of messages
            // after each println() I do a flush()
            out.println("lots of messages.....");
            out.flush();

            out.close(); 
            //...
        } 
运行应用程序时,浏览器中会立即显示消息

当我在Weblogic 10和Java 1.6中使用Seam 2.2运行此程序时,不会立即在浏览器中看到消息。 仅当servlet完成运行时

我能换些东西来解决这个问题吗

我不想将servlet更改/转换为Seam组件。servlet运行良好。唯一的事情是将消息刷新到浏览器窗口,这只发生在servlet停止运行之后

原因可能是servlet现在通过Seam过滤器:

<filter>
  <filter-name>Seam Filter</filter-name>
  <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>

<filter-mapping>
  <filter-name>Seam Filter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

接缝过滤器
org.jboss.seam.servlet.SeamFilter
接缝过滤器
/*

您正在运行一个servlet-这里与Seam无关。我怀疑您需要重新评估您的设计,因为从servlet到Seam结构实际上并没有一个精确的转换。

您正在运行一个servlet-这里与Seam无关。我怀疑您需要重新评估您的设计,因为实际上没有从servlet到Seam结构的精确转换。

原因可能是,正如您所想,请求通过SeamFilter。 我认为缓冲来自servlet的数据流的不是SeamFilter本身,而是在过滤器链中调用的Ajax4Jsf过滤器

如果类路径中有RichFaces,那么有一个seam组件在链中注册Ajax4jsf过滤器。也就是说,Seam组件是org.jboss.Seam.web.ajax4jsfFilter

如果不需要RichFaces,请尝试将其从类路径中删除。如果需要,我建议您重写
org.jboss.seam.web.ajax4jsfFilter
,以便跳过针对指向servlet的请求的Ajax4Jsf过滤器

另一种可能的解决方案是将过滤器中的servlet转换为Seam组件(请参见@filter annotation),并使用around属性将其定位在链的开头。比如:

@Name("FormerServlet")
@Scope(STATELESS)
@BypassInterceptors
@Filter(around = "org.jboss.seam.web.ajax4jsfFilterInstantiator")
public class FormerServletFilter implements Filter
{

    protected void init(FilterConfig filterConfig) throws Exception
    {
    }


    protected void doDestroy()
    {
    }

    /**
     * Performs the filtering for a request.
     */
    protected void doFilter(final HttpServletRequest request, final HttpServletResponse response,
                            final FilterChain chain) throws Exception
    {
        if (thisRequestShoudBeManagedByMyServlet(request) )
        {
           // do here what you previously did in the servlet

        } else
        {
            // go ahead with the Seam lifecycle
            chain.doFilter(request, response);
        }
    }

原因可能是,正如您所想,请求通过了SeamFilter。 我认为缓冲来自servlet的数据流的不是SeamFilter本身,而是在过滤器链中调用的Ajax4Jsf过滤器

如果类路径中有RichFaces,那么有一个seam组件在链中注册Ajax4jsf过滤器。也就是说,Seam组件是org.jboss.Seam.web.ajax4jsfFilter

如果不需要RichFaces,请尝试将其从类路径中删除。如果需要,我建议您重写
org.jboss.seam.web.ajax4jsfFilter
,以便跳过针对指向servlet的请求的Ajax4Jsf过滤器

另一种可能的解决方案是将过滤器中的servlet转换为Seam组件(请参见@filter annotation),并使用around属性将其定位在链的开头。比如:

@Name("FormerServlet")
@Scope(STATELESS)
@BypassInterceptors
@Filter(around = "org.jboss.seam.web.ajax4jsfFilterInstantiator")
public class FormerServletFilter implements Filter
{

    protected void init(FilterConfig filterConfig) throws Exception
    {
    }


    protected void doDestroy()
    {
    }

    /**
     * Performs the filtering for a request.
     */
    protected void doFilter(final HttpServletRequest request, final HttpServletResponse response,
                            final FilterChain chain) throws Exception
    {
        if (thisRequestShoudBeManagedByMyServlet(request) )
        {
           // do here what you previously did in the servlet

        } else
        {
            // go ahead with the Seam lifecycle
            chain.doFilter(request, response);
        }
    }

我不想将servlet更改为Seam结构。它运行良好,没有时间改变它。唯一的事情是将消息刷新到浏览器窗口,现在只有在servlet停止运行之后才会发生。以前,它会立即将数据刷新到浏览器中。那么,为什么要使用Seam呢?您没有从中获得任何好处,这可能会使您的应用程序复杂化。将其构建并部署为一个合适的J2EE WAR或EAR,并以这种方式使用它,因为其余部分正在转换为Seam。这是我们目前唯一的问题。其余的都很好,很公平。对不起,我不能帮忙,我从来没有做过你在这里做的事。祝你好运。我不想将servlet更改为Seam结构。它运行良好,没有时间改变它。唯一的事情是将消息刷新到浏览器窗口,现在只有在servlet停止运行之后才会发生。以前,它会立即将数据刷新到浏览器中。那么,为什么要使用Seam呢?您没有从中获得任何好处,这可能会使您的应用程序复杂化。将其构建并部署为一个合适的J2EE WAR或EAR,并以这种方式使用它,因为其余部分正在转换为Seam。这是我们目前唯一的问题。其余的都很好,很公平。对不起,我不能帮忙,我从来没有做过你在这里做的事。祝你好运。我在几个论坛上看到了另一个解决方案,到目前为止,它没有任何副作用。
我在
组件中添加了它。xml
我的“旧”servlet现在执行与以前相同的操作,并立即刷新输出。我在几个论坛上看到了另一个解决方案,到目前为止,它没有任何副作用效果。
我在
components.xml中添加了它
我的“旧”servlet现在执行与以前相同的操作,并立即刷新输出。