Report new bug | New search | Development Roadmap Status: Open | Feedback | All

Bug #10155 php5servlet support for java 1.5 or 1.6
Submitted: 2007-02-22 09:30 UTC
From: camille dot gauthier at neuf dot fr Assigned: wiesemann
Status: Bogus Package: Bug System
PHP Version: 5.2.1 OS: windows
Roadmaps: (Not assigned)    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2007-03-06 22:45 UTC
Package:
Bug Type:
Summary:
From: camille dot gauthier at neuf dot fr
New email:
PHP Version: Package Version: OS:

 

 [2007-02-22 09:30 UTC] camille dot gauthier at neuf dot fr (camille gauthier)
Description: ------------ the last version of servlet.java in php5servlet.jar is not java5/6 compatible; it is linked to the fact that servlet.java uses enum (new reserved java word) for a local variable name; to fix that issue, it is sufficient to replace enum by en for example; i have recompiled it, rebuilt php5servlet.jar with it and now php over tomcat works fine. the complete new code for servlet.java is pasted below: /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2006 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Sam Ruby (rubys@us.ibm.com) | +----------------------------------------------------------------------+ */ /* $Id: servlet.java,v 1.19.8.1.8.1 2006/01/01 13:47:02 sniper Exp $ */ package net.php; import java.io.IOException; import java.net.URLEncoder; import java.util.Enumeration; import javax.servlet.*; import javax.servlet.http.*; import java.lang.reflect.Method; public class servlet extends HttpServlet { char slash = System.getProperty("file.separator").charAt(0); HttpServletRequest request; HttpServletResponse response; ServletInputStream stream; static int startup_count = 0; protected boolean display_source_mode = false; private Method addHeader; // Native methods public native void startup(); public native long define(String name); public native void send(String requestMethod, String queryString, String pathInfo, String pathTranslated, String contentType, int contentLength, String authUser, boolean display_source_mode ); public native void shutdown(); // SAPI Callbacks public String readPost(int bytes) { String result; if (!request.getMethod().equals("POST")) { result = request.getQueryString(); } else { Enumeration enum = request.getParameterNames(); String concat = ""; result = ""; while (enum.hasMoreElements()) { String name = (String)enum.nextElement(); String value = request.getParameter(name); try { result += concat + name + "=" + URLEncoder.encode(value, "UTF-8"); } catch (Exception e) { e.printStackTrace(System.err); } concat = "&"; } } if (result == null) return ""; return result; } public String readCookies() { reflect.setResult(define("request"), request); reflect.setResult(define("response"), response); reflect.setResult(define("PHP_SELF"), request.getRequestURI()); return request.getHeader("cookie"); } public void header(String data) { // try to send the header using the most specific servlet API // as possible (some servlet engines will add a content type // header unless the setContentType method is called). try { if (data.startsWith("Content-type: ")) { response.setContentType(data.substring(data.indexOf(" ") + 1)); } else if (data.startsWith("Location: ")) { response.sendRedirect(data.substring(data.indexOf(" ") + 1)); } else if (data.startsWith("HTTP/1")) { return; // this one is added from servlet container (Tomcat 4.1), we have to check for others } else { int colon = data.indexOf(": "); if (colon > 0) { try { addHeader.invoke(response, new Object[] { data.substring(0, colon), data.substring(colon + 2) } ); } catch (Exception e) { e.printStackTrace(System.err); } } else { write(data); } } } catch (IOException e) { e.printStackTrace(System.err); } } public void write(String data) { try { response.getWriter().print(data); } catch (IOException e) { e.printStackTrace(System.err); } } // Servlet interface public void init(ServletConfig config) throws ServletException { super.init(config); // first time in, initialize native code if (0 == startup_count++) { reflect.loadLibrary("servlet"); startup(); } // try to find the addHeader method (added in the servlet API 2.2) // otherwise settle for the setHeader method try { Class c = Class.forName("javax.servlet.http.HttpServletResponse"); Method method[] = c.getDeclaredMethods(); for (int i = 0; i < method.length; i++) { if (method[i].getName().equals("addHeader")) { addHeader = method[i]; break; } if (method[i].getName().equals("setHeader")) { addHeader = method[i]; } } } catch (Exception e) { e.printStackTrace(System.err); } } public void service(HttpServletRequest request, HttpServletResponse response, String contextPath) throws ServletException { this.request = request; this.response = response; send(request.getMethod(), request.getQueryString(), request.getRequestURI(), contextPath, request.getContentType(), request.getContentLength(), request.getRemoteUser(), display_source_mode ); try { if (stream != null) stream.close(); } catch (IOException e) { throw new ServletException(e.toString()); } } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException { String servletPath = request.getServletPath(); String contextPath = getServletContext().getRealPath(servletPath); service(request, response, contextPath); } public void destroy() { if (0 == --startup_count) shutdown(); super.destroy(); } }

Comments

 [2007-03-06 22:45 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2007-04-20 06:26 UTC] biplab_babu at rediffmail dot com
i want to run php5 by using tomcat6 pls.. help me . how i will get php5servlet.jar file