The problem is:

I just started working on java Servlets with java web server2.0 and working on
servlet chaining.

The purpose of chaining is to remove all the <h1></h1> tags from the *.html
files.
*.html files should pass through Deblink servlet(code is given below).For this
I made all reqiured additions in servlet aliases of java web server
administration.


But when i run any *.html file it is giving me following error:


500 Internal Server Error
The servlet named Deblink in a servlet chain at the requested URL

http://localhost:8082/name.html
reported this exception: can't mix text and binary input. Please report this
to the administrator of the web server.

java.lang.IllegalStateException: can't mix text and binary input at
java.lang.Throwable.(Compiled Code) at java.lang.Exception.(Compiled Code) at
java.lang.RuntimeException.(RuntimeException.java:50) at
java.lang.IllegalStateException.(IllegalStateException.java:48) at
com.sun.server.servlet.http.HttpRequest.getInputStream(Compiled Code) at
com.sun.server.http.stages.FilterManager.chainServlet(FilterManager.java:218)
at com.sun.server.http.stages.FilterManager.update(Compiled Code) at
com.sun.server.http.HttpServiceResponse.update(Compiled Code) at
com.sun.server.servlet.http.HttpOutputStream.flushBytes(Compiled Code) at
com.sun.server.servlet.http.HttpOutputStream.flush(Compiled Code) at
java.io.OutputStreamWriter.flush(Compiled Code) at
java.io.PrintWriter.flush(Compiled Code) at
com.sun.server.servlet.http.HttpResponse.finish(Compiled Code) at
com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code) at
com.sun.server.http.HttpServiceHandler.handleRequest(Compiled Code) at
com.sun.server.HandlerThread.run(Compiled Code)



**********************************************************************************

The error come with the line :  BufferedReader in=req.getReader();(see code)

**********************************************************************************
I wrote  the following code :

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Deblink extends HttpServlet
 {
   public void doPost(HttpServletRequest req,HttpServletResponse res) throws
IOException,ServletException
    {
     doGet(req,res);
    }
   public void doGet(HttpServletRequest req,HttpServletResponse res) throws
IOException,ServletException
    {

      String contentType=req.getContentType();
      if(contentType==null) return;

      res.setContentType(contentType);

      PrintWriter out=res.getWriter();
      BufferedReader in=req.getReader();

      String line=null;


      while((line=in.readLine())!=null)
       {
        line=replace(line,"<h1>"," ");
        line=replace(line,"</h1>"," ");
        out.println(line+"mssss");
       }

    }
   public String replace(String old,String toReplace,String newString)
    {
       int index=0;
       while((index=old.indexOf(toReplace))>=0)
        {
           old=old.substring(0,index)+
            newString+
            old.substring(index+toReplace.length());

         index+=newString.length();
        }
       return old;
    }
 }

************************************************************************************
please tell me the solution.Thanx


____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to