You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Mike Cox <co...@us.ibm.com> on 1999/01/06 00:32:12 UTC

mod_jserv/3628: When using ServerSideInclude to invoke servlet, I get exception when invoking getWriter() method.

>Number:         3628
>Category:       mod_jserv
>Synopsis:       When using ServerSideInclude to invoke servlet, I get exception when invoking getWriter() method.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jserv
>State:          open
>Class:          sw-bug
>Submitter-Id:   apache
>Arrival-Date:   Tue Jan  5 15:40:01 PST 1999
>Last-Modified:
>Originator:     coxm@us.ibm.com
>Organization:
apache
>Release:        1.3.3
>Environment:
WINNT Service pack 3, Using Apache 1.3.3, JSERV 1.0b, JSERVSSI 1.0, JSDK 2.0
Netscape 4.5 
>Description:
I am trying to use <SERVLET> ... </SERVLET> support in the webserver.  I
consistently get a failure with the simplist jhtml and servlet (i.e. 
HelloWorld).

Here is the output of the failed <servlet> ... <servlet>
---------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
 <HEAD>
  <TITLE>Test Page for Apache Installation on Web Site</TITLE>
 </HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
 <BODY
  BGCOLOR="#FFFFFF"
  TEXT="#000000"
  LINK="#0000FF"
  VLINK="#000080"
  ALINK="#FF0000"
 >
  <H1 ALIGN="CENTER">
   Servlet processing
  </H1>

  <!-- java.lang.IllegalStateException: Already called getOutputStream.
        at java.lang.Throwable.<init>(Compiled Code)
        at org.apache.jserv.JServConnection.getWriter(Compiled Code)
        at HelloWorld.doGet(Compiled Code)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at org.apache.jservssi.ServletInfoRequest.runServlet(JServSSI.java:917)
        at org.apache.jservssi.JServSSI.interpretPage(Compiled Code)
        at org.apache.jservssi.JServSSI.doGet(JServSSI.java:302)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at javax.servlet.http.HttpServlet.service(Compiled Code)
        at org.apache.jserv.JServConnection.run(Compiled Code)
        at java.lang.Thread.run(Compiled Code)
-->
    
  <DIV ALIGN="CENTER">
   <IMG SRC="apache_pb.gif" ALT="">
  </DIV>
 </BODY>
</HTML>


Here is the failing code....
----------------------------


   public void doGet(HttpServletRequest req, HttpServletResponse res) 
                     throws ServletException, IOException {
      
      res.setContentType("text/html");
  //    PrintWriter out = res.getWriter();                 // <<--  bug!! doesn't work
 
      ServletOutputStream out = res.getOutputStream(); // <<-- Gets around bug


Here is the jhtml with the <sevlet> tag
----------------------------------------

<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
 <BODY
  BGCOLOR="#FFFFFF"
  TEXT="#000000"
  LINK="#0000FF"
  VLINK="#000080"
  ALINK="#FF0000"
 >
  <H1 ALIGN="CENTER">
   Servlet processing
  </H1>

  <SERVLET CODE="Hello">
  <PARAM NAME="param1" VALUE="valueOfParam1">;
   There is an error here...
  </SERVLET>
    
  <DIV ALIGN="CENTER">
   <IMG SRC="apache_pb.gif" ALT="">
  </DIV>
 </BODY>
</HTML>

As you can see, I circumvented my problem by using getOutputStream rather than getWriter... just
took a day or so to figure this out... But I think the JServSSI support is broken.
>How-To-Repeat:
I will send anyone my configuration data and code...  Unfortunately, I am
inside the firewall....  Warning... Apache Rookie at work here... so this
may be something I have done incorrectly...  However, my servlet works fine
unless invoked by a <servlet> tag
>Fix:

>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]