I recompiled it, but that didn't change anything. I still get an Internal
Server Error. Here is the servlet code. It uses classes from JSDK 2.1
which I put in /opt/jdk1.2/jre/lib/ext/jsdk21.jar

/**
 * This class simply generates a HTML Form for posting UTF8 characters
 * which are reflected by the servlet.
 * Thomas Kopp, 27.04.1999
 */
import java.io.*;
import java.net.*;

import javax.servlet.*;
import javax.servlet.http.*;

public class UTF8Mirror extends HttpServlet {


    public void init(ServletConfig config)

        throws ServletException {

        super.init(config);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
      exec(request, response, false);
    }


    protected void doPost(HttpServletRequest request, HttpServletResponse response)

        throws ServletException, IOException {
      exec(request, response, true);
    }

    private String getHomeURL(HttpServletRequest request, HttpServletResponse 
response) {
        String homeURL = HttpUtils.getRequestURL(request).toString();
        int paramStart = homeURL.indexOf('?');
        if (paramStart >= 0) homeURL = homeURL.substring(0, paramStart);
        return response.encodeURL(homeURL);
    }


    private void exec(HttpServletRequest request, HttpServletResponse response, 
boolean post)
        throws ServletException, IOException {

      response.setContentType("text/html; charset=utf-8");
      PrintWriter printer = response.getWriter();
      printer.println("<html><head>");
      printer.println("<meta http-equiv=\"Content-Type\" content=\"text/html; 
charset=utf-8\">");
      printer.println("</head><body>");

      printer.print("method=\"");
      if (post) printer.print("post"); 
      else printer.print("get");
      printer.println("\".<br>");

      printer.print("encoding=\"" + request.getCharacterEncoding() + "\".<br>");

      printer.println("native input=");
      ByteArrayOutputStream buffer = new ByteArrayOutputStream();
      InputStream input = request.getInputStream();
      int b = -1;
      int n = 0;
      while ((b = input.read()) >= 0) {
            if ((++n) > 2) { // discard the "A=" prefix.
               buffer.write((byte)b);
               String hex = Integer.toHexString(b);
                 if (hex.length() < 2) printer.print('0');
               printer.print(hex);
               printer.print(' ');
            }
      } 
      printer.println(".<br>");
      
      String parameter_default = buffer.toString();
      printer.println("default converted input=\"" + parameter_default + "\".<br>");

      String parameter_utf8 = buffer.toString("UTF8");
      printer.println("utf8 converted input=\"" + parameter_utf8 + "\".<br>");
      
      try {
            String urldecoded_default = URLDecoder.decode(parameter_default);
            printer.println("default decoded input=\"" + urldecoded_default + 
"\".<br>");
      
            String urldecoded_utf8 = URLDecoder.decode(parameter_utf8);
            printer.println("utf8 decoded input=\"" + urldecoded_utf8 + "\".<br>");

      

            String default_default = new String(urldecoded_default.getBytes());
            printer.println("default default converted input=\"" + default_default + 
"\".<br>");

            String default_utf8 = new String(urldecoded_utf8.getBytes());
            printer.println("default utf8 converted input=\"" + default_utf8 + 
"\".<br>");

      
            String utf8_default = new String(urldecoded_default.getBytes(),"UTF8");
            printer.println("utf8 default converted input=\"" + utf8_default + 
"\".<br>");

            String utf8_utf8 = new String(urldecoded_utf8.getBytes(),"UTF8");
            printer.println("utf8 utf8 converted input=\"" + utf8_utf8 + "\".<br>");
      }
      catch (Exception ex) {
            throw new ServletException(ex.getMessage());
      }


      printer.println("<form action=\"" + getHomeURL(request, response)
                                        + "\" method=\"post\">");


      printer.println("<input type=\"text\" name=\"A\">");
      printer.println("<input type=\"submit\">");
      printer.println("</form></body></html>");
      printer.close();
    }

}

On Tue, 18 May 1999, jon * wrote:

> >   By following http://java.apache.org/faq/fom-serve/cache/144.html I
> > finally got Apache 1.3.6 and JServ 1.0b4 working. The example servlet
> > Hello works, so I then tried to install another servlet by copying it to
> > /usr/local/apache/example, restarting Apache, and opening
> > http://localhost/example/UTF8Mirror
> 
> You shouldn't need to restart apache to put a new servlet into the system.
> 
> > [Tue May 18 13:49:48 1999] [notice] Apache/1.3.6 (Unix) ApacheJServ/1.0b4
> > configured -- resuming normal operations
> > java.lang.AbstractMethodError: org/apache/jserv/JServConnection.encodeURL
> >         at org.apache.jserv.JServConnection.run(Compiled Code)
> >         at java.lang.Thread.run(Compiled Code)
> 
> Try re-compiling the servlet.
> 
> -jon
> 
> 
> 
> -- --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> READ THE FAQ!!!!     <http://java.apache.org/faq/>
> Archives and Other:  <http://java.apache.org/main/mail.html/>
> Problems?:           [EMAIL PROTECTED]
> 



-- --------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to