Filter problem
I have the following code for an access filter. If I log in with the role of admin everything works as expected. If I try to log in with the role of user I immediately get a permissions error that denies access. I've added ${sessionScope.USER} to the jsp pages as well as adding entries for PWD and ROLE. The correct information is in the session variables. I'd appreciate any help in finding the error and fixing it. Thanks, Jack public class AccessControlFilter implements Filter { public static final String NO_ACCESS_PAGE = no-access-page; public static final String NO_AUTH_PAGE = no-auth-page; private FilterConfig fc; private String noAccessPage; private String notLoggedInPage; public AccessControlFilter() { fc = null; } /** * Destroy the Access Control Filter */ public void destroy() { fc = null; } /** * Initialize the Access Control Filter */ public void init(FilterConfig config) throws ServletException { fc = config; noAccessPage = fc.getInitParameter(no-access-page); if(noAccessPage == null) noAccessPage = noaccess.jsp; notLoggedInPage = fc.getInitParameter(no-auth-page); if(notLoggedInPage == null) notLoggedInPage = notloggedin.jsp; } public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest)req; HttpServletResponse httpResp = (HttpServletResponse)resp; String servletPath = httpReq.getServletPath(); String username = (String)httpReq.getSession().getAttribute(USER); if(username == null) { httpResp.sendRedirect(notLoggedInPage); return; } String role = (String)httpReq.getSession().getAttribute(ROLE); if(role == null) { httpResp.sendRedirect(notLoggedInPage); return; } if(role.equals(admin)) { chain.doFilter(req, resp); return; } if(role.equals(user)) { if(servletPath.startsWith(/secure/updateDb/add) || servletPath.startsWith(/secure/updateDb/delete) || servletPath.startsWith(/secure/updateDb/update) || servletPath.startsWith(/secure/updateDb/move) || servletPath.equals(/secure/updateDb/sectionAdd) || servletPath.equals(/secure/updateDb/sectionDelete)) { Integer id = new Integer(httpReq.getParameter(company)); if(id.equals(getAuthToken(username))) { chain.doFilter(req, resp); return; } } else if(servletPath.equals(/secure/updateDb/changePassword)) { if(username.equals(httpReq.getParameter(userName))) { chain.doFilter(req, resp); return; } } else if(servletPath.equals(/secure/index.jsp)) { ServletContext servletcontext = fc.getServletContext(); RequestDispatcher requestdispatcher = servletcontext.getRequestDispatcher(/secure/ControlPanel.jsp?company= + getAuthToken(username)); if(requestdispatcher == null) httpResp.sendError(500, Ccontrol panel doesn't exist.); requestdispatcher.forward(req, resp); return; } } else { httpResp.sendRedirect(notLoggedInPage); return; } httpResp.sendRedirect(noAccessPage); } private Integer getAuthToken(String servletPath) { Integer id = new Integer(-1); try { Context ctx = null; DataSource ds = null; Connection conn = null; Result result = null; SQLCommandBean sql = new SQLCommandBean(); try { String envBase = java:comp/env/; ctx = new InitialContext(); String dataSourceName = (String)ctx.lookup(envBase + dataSource); ds = (DataSource) ctx.lookup(envBase + dataSourceName); } catch (Exception e) { System.out.println(DataSource context lookup failed: + e); } try { conn = ds.getConnection(); } catch (SQLException se) { System.out.println(DataSource getConnection failed: + se); se.printStackTrace(); } try { sql.setConnection(conn); } catch (Exception e) { System.out.println(DataSource setConnection failed: + e); } sql.setSqlValue(SELECT CompanyID FROM Company WHERE UserID = ?); ArrayList arraylist = new ArrayList(); arraylist.add(servletPath); sql.setValues(arraylist); result =
Filter Problem
I have an access control filter that is supposed to grant all access to users wirh the role of 'admin' and limited access to those with the role of 'user. Specifically a 'user' can only manipulate the data that belongs to them. It uses 'contextPath.startsWith' and the users 'id' (int) from the database appended to it to access their records. If I logon as an 'admin' user it works fine. If I login using a bad password it forwards to the notLoggedInPage. It I login as a 'user' with a correct password it forwards to the noAccessPage. I'm not sure what's wrong here and would appreciate any help in resolving this matter, TIA, Jack import java.io.IOException; import java.sql.Connection; import java.util.ArrayList; import javax.naming.Context; import javax.naming.InitialContext; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.jstl.sql.Result; import javax.sql.DataSource; import com.nwc.SQLCommandBean; /** * Referenced classes of package com.nwc: * sql : SQLCommandBean */ /** * @web.filter * name=AccessControlFilter * display-name=JAAS Access Control Filter * @web.filter-init-param * name=no-access-page * value=/restaurants/noaccess.jsp * @web.filter-init-param * name=no-auth-page * value=/restaurants/notloggedin.jsp * @web.filter-mapping * url-pattern=/secure/* * @version 1.17 11/21/2004 */ public class AccessControlFilter implements Filter { /** * Comment for codeNO_ACCESS_PAGE/code * Value: [EMAIL PROTECTED] NO_ACCESS_PAGE} */ public static final String NO_ACCESS_PAGE = no-access-page; /** * Comment for codeNO_AUTH_PAGE/code * Value: [EMAIL PROTECTED] NO_AUTH_PAGE} */ public static final String NO_AUTH_PAGE = no-auth-page; /** * Field config */ private FilterConfig fc; /** * Field noAccessPage */ private String noAccessPage; /** * Field notLoggedInPage */ private String notLoggedInPage; /** * */ public AccessControlFilter() { fc = null; } /** * Initialize the Access Control Filter * * (non-Javadoc) * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) */ public void init(FilterConfig config) throws ServletException { fc = config; noAccessPage = fc.getInitParameter(no-access-page); if(noAccessPage == null) noAccessPage = noaccess.jsp; notLoggedInPage = fc.getInitParameter(no-auth-page); if(notLoggedInPage == null) notLoggedInPage = notloggedin.jsp; } /** * Destroy the Access Control Filter * * (non-Javadoc) * @see javax.servlet.Filter#destroy() */ public void destroy() { fc = null; } /** * Implements javx.servlet.Filter.doFilter * * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) */ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpReq = (HttpServletRequest)req; HttpServletResponse httpResp = (HttpServletResponse)resp; / String contextPath = httpReq.getContextPath(); / String username = (String)httpReq.getSession().getAttribute(USER); if(username == null) { httpResp.sendRedirect(notLoggedInPage); return; } String role = (String)httpReq.getSession().getAttribute(ROLE); if(role == null) { httpResp.sendRedirect(notLoggedInPage); return; } if(role.equals(admin)) { chain.doFilter(req, resp); return; } if(role.equals(user)) { if(contextPath.startsWith(/secure/updateDb/add) || contextPath.startsWith(/secure/updateDb/delete) || contextPath.startsWith(/secure/updateDb/update) || contextPath.startsWith(/secure/updateDb/move) || contextPath.equals(/secure/updateDb/sectionAdd) || contextPath.equals(/secure/updateDb/sectionDelete) || contextPath.startsWith(/secure/updateDb/sectionMove) || contextPath.equals(/secure/updateDb/validTimes) || contextPath.equals(/secure/updateDb/menuDelete) || contextPath.equals(/secure/updateDb/menuAdd) || contextPath.startsWith(/secure/updateDb/menuMove) ||
Re: Filter Problem
getContextPath is the path name of the webapp. For example, if my webapp is registered at /more. Then my contextPath is /more. If I request /more/cowbell.jsp. The contextPath is /more and the servletPath is /cowbell.jsp. -Tim Jack Lauman wrote: I have an access control filter that is supposed to grant all access to users wirh the role of 'admin' and limited access to those with the role of 'user. Specifically a 'user' can only manipulate the data that belongs to them. It uses 'contextPath.startsWith' and the users 'id' (int) from the database appended to it to access their records. If I logon as an 'admin' user it works fine. If I login using a bad password it forwards to the notLoggedInPage. It I login as a 'user' with a correct password it forwards to the noAccessPage. I'm not sure what's wrong here and would appreciate any help in resolving this matter, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter Problem
Can you append the two together to get the desired result? Jack Tim Funk wrote: getContextPath is the path name of the webapp. For example, if my webapp is registered at /more. Then my contextPath is /more. If I request /more/cowbell.jsp. The contextPath is /more and the servletPath is /cowbell.jsp. -Tim Jack Lauman wrote: I have an access control filter that is supposed to grant all access to users wirh the role of 'admin' and limited access to those with the role of 'user. Specifically a 'user' can only manipulate the data that belongs to them. It uses 'contextPath.startsWith' and the users 'id' (int) from the database appended to it to access their records. If I logon as an 'admin' user it works fine. If I login using a bad password it forwards to the notLoggedInPage. It I login as a 'user' with a correct password it forwards to the noAccessPage. I'm not sure what's wrong here and would appreciate any help in resolving this matter, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter Problem
You probably want to ignore context path. Its servletPath you really care about. -Tim Jack Lauman wrote: Can you append the two together to get the desired result? Jack Tim Funk wrote: getContextPath is the path name of the webapp. For example, if my webapp is registered at /more. Then my contextPath is /more. If I request /more/cowbell.jsp. The contextPath is /more and the servletPath is /cowbell.jsp. -Tim Jack Lauman wrote: I have an access control filter that is supposed to grant all access to users wirh the role of 'admin' and limited access to those with the role of 'user. Specifically a 'user' can only manipulate the data that belongs to them. It uses 'contextPath.startsWith' and the users 'id' (int) from the database appended to it to access their records. If I logon as an 'admin' user it works fine. If I login using a bad password it forwards to the notLoggedInPage. It I login as a 'user' with a correct password it forwards to the noAccessPage. I'm not sure what's wrong here and would appreciate any help in resolving this matter, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter Problem
Tim: Thanks for your help. It's fixed. Jack Tim Funk wrote: You probably want to ignore context path. Its servletPath you really care about. -Tim Jack Lauman wrote: Can you append the two together to get the desired result? Jack Tim Funk wrote: getContextPath is the path name of the webapp. For example, if my webapp is registered at /more. Then my contextPath is /more. If I request /more/cowbell.jsp. The contextPath is /more and the servletPath is /cowbell.jsp. -Tim Jack Lauman wrote: I have an access control filter that is supposed to grant all access to users wirh the role of 'admin' and limited access to those with the role of 'user. Specifically a 'user' can only manipulate the data that belongs to them. It uses 'contextPath.startsWith' and the users 'id' (int) from the database appended to it to access their records. If I logon as an 'admin' user it works fine. If I login using a bad password it forwards to the notLoggedInPage. It I login as a 'user' with a correct password it forwards to the noAccessPage. I'm not sure what's wrong here and would appreciate any help in resolving this matter, - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [FIXED] jndi realm filter problem
Hi, ok it's fixed i made another realm with a new mbean-descriptor bases on the JNDIRealm file from version 4.1.31 and that do the trick till an update of tomcat. However, for those runnin 4.1.30,the main difference between file is: * @version $Revision: 1.19 $ $Date: 2004/08/26 21:37:21 $ --- * @version $Revision: 1.16 $ $Date: 2003/12/12 21:31:56 $ 1295c1343,1344 String filter = roleFormat.format(new String[] { doRFC2254Encoding(dn), username }); --- String filter = roleFormat.format(new String[] { dn, username }); filter = doRFC2254Encoding(filter); so, instead of doing an new realm,just modifying this file and rebuild catalina.jar should do the trick But i guess all this is nearly historical :-) Thank for the excellent framework Xavier Xavier Renard wrote: Hi, I'm using the Debian package of tomcat (4.1.30) with ldap auth with the following config: myapplication.xml -- Context path=/myapplication docBase=/path/2/build Realm className=org.apache.catalina.realm.JNDIRealm debug=99 connectionURL=ldap://localhost:389; connectionName=uid=tomcatproxy,dc=example,dc=org connectionPassword=tomcatpwd roleName=cn roleBase=ou=groups,dc=example,dc=org roleSearch=(memberUid={1}) userBase=ou=people,dc=example,dc=org userSearch=(uid={0}) userSubtree=true/ /Context I have tried it with the tar.gz of tomcat-4.1.30 and tomcat-5.0.28 and it works perfectly well. However,with the debian package, my filter (rolesearch) become (?=undefined) sample from log -- conn=7 op=5 SRCH base=ou=groups,dc=example,dc=org scope=1 filter=(?=undefined) I have to use the debian package so i can't really change that. However, before submitting a bug report or write a mail to the debian-java mailing-list, i would like to know if someone could point me in the good direction to fix this,ie where to modify this behaviour if possible or override this realm by an other,... Regards Xavier - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
jndi realm filter problem
Hi, I'm using the Debian package of tomcat (4.1.30) with ldap auth with the following config: myapplication.xml -- Context path=/myapplication docBase=/path/2/build Realm className=org.apache.catalina.realm.JNDIRealm debug=99 connectionURL=ldap://localhost:389; connectionName=uid=tomcatproxy,dc=example,dc=org connectionPassword=tomcatpwd roleName=cn roleBase=ou=groups,dc=example,dc=org roleSearch=(memberUid={1}) userBase=ou=people,dc=example,dc=org userSearch=(uid={0}) userSubtree=true/ /Context I have tried it with the tar.gz of tomcat-4.1.30 and tomcat-5.0.28 and it works perfectly well. However,with the debian package, my filter (rolesearch) become (?=undefined) sample from log -- conn=7 op=5 SRCH base=ou=groups,dc=example,dc=org scope=1 filter=(?=undefined) I have to use the debian package so i can't really change that. However, before submitting a bug report or write a mail to the debian-java mailing-list, i would like to know if someone could point me in the good direction to fix this,ie where to modify this behaviour if possible or override this realm by an other,... Regards Xavier - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
filter problem
My web.xml fragment: filter-nameSet Character Encoding/filter-name filter-classfilters.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueISO-8859-2/param-value /init-param /filter filter-mapping filter-nameSet Character Encoding/filter-name url-pattern/*/url-pattern /filter-mapping In fact when I get request.CharacterEncoding I get iso-8859-2 (Central European) but why my national (polish) chars are wrong encoded??. For the Strings I post submitting the form and try to write into console I get something like ?. What I am doing wrong? Cheers Bartek - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: filter problem
Howdy, Perhaps something is messed up in your browser? I don't like using spaces in servlet or filter names, but that's just me ;) Yoav Shapira Millennium ChemInformatics -Original Message- From: bwasko [mailto:[EMAIL PROTECTED] Sent: Monday, November 24, 2003 7:29 AM To: Tomcat Users List Subject: filter problem My web.xml fragment: filter-nameSet Character Encoding/filter-name filter-classfilters.SetCharacterEncodingFilter/filter-class init-param param-nameencoding/param-name param-valueISO-8859-2/param-value /init-param /filter filter-mapping filter-nameSet Character Encoding/filter-name url-pattern/*/url-pattern /filter-mapping In fact when I get request.CharacterEncoding I get iso-8859-2 (Central European) but why my national (polish) chars are wrong encoded??. For the Strings I post submitting the form and try to write into console I get something like ?Â???Â?. What I am doing wrong? Cheers Bartek - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win2003 IIS6 ISAPI filter problem
I posted this thread back in June-03 as I was having problems making the ISAPI redirector work under IIS 6 on Windows 2003. Now thanks entirely to Andrew Duey of TerraScan Inc., I now have this working. If you are using IIS V6, which ships with Windows Server 2003, you must allow the Web Service Extension to operate. Earlier versions of IIS did not require this step. Using the IIS Internet Services Manager, click on the Web Services Extensions item in the left hand pane. In the right hand pane add a new Web Service Extension called, say, Tomcat ISAPI and browse and set the required file for this extension to the isapi_redirect.dll and set the status to allowed. Then restart IIS. It appears that no changes are needed to the standard Tomcat ISAPI redirector for this version of IIS. I hope this helps someone else. Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Win2003 IIS6 ISAPI filter problem
Excellent. Thank you for posting this, many IIS users have posted to the list trying to get the redirector to work with IIS 6. John Nick Tatham wrote: I posted this thread back in June-03 as I was having problems making the ISAPI redirector work under IIS 6 on Windows 2003. Now thanks entirely to Andrew Duey of TerraScan Inc., I now have this working. If you are using IIS V6, which ships with Windows Server 2003, you must allow the Web Service Extension to operate. Earlier versions of IIS did not require this step. Using the IIS Internet Services Manager, click on the Web Services Extensions item in the left hand pane. In the right hand pane add a new Web Service Extension called, say, Tomcat ISAPI and browse and set the required file for this extension to the isapi_redirect.dll and set the status to allowed. Then restart IIS. It appears that no changes are needed to the standard Tomcat ISAPI redirector for this version of IIS. I hope this helps someone else. Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win2003 IIS6 ISAPI filter problem
I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win2003 IIS6 ISAPI filter problem
I have been experiencing a similar problem with the ISAPI from 4.1.18. The application works fine when I hit Tomcat's HTTP listener, but going through IIS I receive the error with ACCESS DENIED. I have tried everything imaginable with the permissions. Is there a new ISAPI filter for 2003? Has anyone tried the ISAPI from Tomcat 5.0? - Kjell Eriksen -Original Message- From: Nick Tatham [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:14 AM To: Tomcat Users List Subject: Win2003 IIS6 ISAPI filter problem I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Win2003 IIS6 ISAPI filter problem
I'm using the latest isapi_redirector.dll (notice the 'or' at the end) with no problems. But I'm running 4.1.24. - Original Message - From: Eriksen, Kjell [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:20 AM Subject: RE: Win2003 IIS6 ISAPI filter problem I have been experiencing a similar problem with the ISAPI from 4.1.18. The application works fine when I hit Tomcat's HTTP listener, but going through IIS I receive the error with ACCESS DENIED. I have tried everything imaginable with the permissions. Is there a new ISAPI filter for 2003? Has anyone tried the ISAPI from Tomcat 5.0? - Kjell Eriksen -Original Message- From: Nick Tatham [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:14 AM To: Tomcat Users List Subject: Win2003 IIS6 ISAPI filter problem I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win2003 IIS6 ISAPI filter problem
Tom, Where did you get that redirectOR from - I can't find it on the download site? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com -Original Message- From: Tom Cole [mailto:[EMAIL PROTECTED] Sent: 27 June 2003 14:23 To: Tomcat Users List Subject: Re: Win2003 IIS6 ISAPI filter problem I'm using the latest isapi_redirector.dll (notice the 'or' at the end) with no problems. But I'm running 4.1.24. - Original Message - From: Eriksen, Kjell [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:20 AM Subject: RE: Win2003 IIS6 ISAPI filter problem I have been experiencing a similar problem with the ISAPI from 4.1.18. The application works fine when I hit Tomcat's HTTP listener, but going through IIS I receive the error with ACCESS DENIED. I have tried everything imaginable with the permissions. Is there a new ISAPI filter for 2003? Has anyone tried the ISAPI from Tomcat 5.0? - Kjell Eriksen -Original Message- From: Nick Tatham [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:14 AM To: Tomcat Users List Subject: Win2003 IIS6 ISAPI filter problem I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win2003 IIS6 ISAPI filter problem
On win2003 ? -Original Message- From: Tom Cole [mailto:[EMAIL PROTECTED] Sent: 27. júní 2003 13:23 To: Tomcat Users List Subject: Re: Win2003 IIS6 ISAPI filter problem I'm using the latest isapi_redirector.dll (notice the 'or' at the end) with no problems. But I'm running 4.1.24. - Original Message - From: Eriksen, Kjell [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:20 AM Subject: RE: Win2003 IIS6 ISAPI filter problem I have been experiencing a similar problem with the ISAPI from 4.1.18. The application works fine when I hit Tomcat's HTTP listener, but going through IIS I receive the error with ACCESS DENIED. I have tried everything imaginable with the permissions. Is there a new ISAPI filter for 2003? Has anyone tried the ISAPI from Tomcat 5.0? - Kjell Eriksen -Original Message- From: Nick Tatham [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:14 AM To: Tomcat Users List Subject: Win2003 IIS6 ISAPI filter problem I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win2003 IIS6 ISAPI filter problem
To answer my own question, I have now found the -or version: isapi_redirector.dll in /builds/jakarta-tomcat-connectors/jk/release/v1.2.0/bin/win32 I have upgraded to this version and still get the same problem on Win2003. I did earlier have access problems but fixed those in IIS6 by going to Properties on DefaultAppPool and changing the pre-defined security account to LocalSystem on the Identity tab - this gives the redirector more privs and probably makes IIS less secure but I got further with this setting than without. So I'm still stuck on 2003. Regards, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win2003 IIS6 ISAPI filter problem
On IIS 6? Is there light in this darkness? Is it possible get Tomcat to work with IIS 6 (win 2003)? -- Original Message -- Reply-To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Win2003 IIS6 ISAPI filter problem Date: Fri, 27 Jun 2003 13:39:55 - From: Reynir Hübner [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] On win2003 ? -Original Message- From: Tom Cole [mailto:[EMAIL PROTECTED] Sent: 27. júní 2003 13:23 To: Tomcat Users List Subject: Re: Win2003 IIS6 ISAPI filter problem I'm using the latest isapi_redirector.dll (notice the 'or' at the end) with no problems. But I'm running 4.1.24. - Original Message - From: Eriksen, Kjell [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:20 AM Subject: RE: Win2003 IIS6 ISAPI filter problem I have been experiencing a similar problem with the ISAPI from 4.1.18. The application works fine when I hit Tomcat's HTTP listener, but going through IIS I receive the error with ACCESS DENIED. I have tried everything imaginable with the permissions. Is there a new ISAPI filter for 2003? Has anyone tried the ISAPI from Tomcat 5.0? - Kjell Eriksen -Original Message- From: Nick Tatham [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:14 AM To: Tomcat Users List Subject: Win2003 IIS6 ISAPI filter problem I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Win2003 IIS6 ISAPI filter problem
Possible? Sure. Probable soon? Maybe. Please understand that the pool of people who are capable of understanding and developing a connector and have access to Win 2003 Server is decidedly small. When you consider that the number of overall Win 2003 Server installations is very tiny as well, it can't be surprising that there isn't a connector ready to go right away. If you need a connector for IIS 6 that fast, and it requires more than just tweaking settings, my advice is to get on the tomcat-dev list and make your case there, and convince someone who can do the work to make it a priority. John On Fri, 27 Jun 2003 16:04:40 +0200, [EMAIL PROTECTED] wrote: On IIS 6? Is there light in this darkness? Is it possible get Tomcat to work with IIS 6 (win 2003)? -- Original Message -- Reply-To: Tomcat Users List [EMAIL PROTECTED] Subject: RE: Win2003 IIS6 ISAPI filter problem Date: Fri, 27 Jun 2003 13:39:55 - From: Reynir Hübner [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] On win2003 ? -Original Message- From: Tom Cole [mailto:[EMAIL PROTECTED] Sent: 27. júní 2003 13:23 To: Tomcat Users List Subject: Re: Win2003 IIS6 ISAPI filter problem I'm using the latest isapi_redirector.dll (notice the 'or' at the end) with no problems. But I'm running 4.1.24. - Original Message - From: Eriksen, Kjell [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:20 AM Subject: RE: Win2003 IIS6 ISAPI filter problem I have been experiencing a similar problem with the ISAPI from 4.1.18. The application works fine when I hit Tomcat's HTTP listener, but going through IIS I receive the error with ACCESS DENIED. I have tried everything imaginable with the permissions. Is there a new ISAPI filter for 2003? Has anyone tried the ISAPI from Tomcat 5.0? - Kjell Eriksen -Original Message- From: Nick Tatham [mailto:[EMAIL PROTECTED] Sent: Friday, June 27, 2003 9:14 AM To: Tomcat Users List Subject: Win2003 IIS6 ISAPI filter problem I have a Tomcat 3 application and have been running this successfully on several NT and 2000 machines under IIS using the isapi_redirect.dll filter (from Tomcat 3.3). I'm now trying to make it work under IIS 6 on Windows server 2003. Debug to the logfile shows it processing the HttpFilterProc OK but not proceeding to the HttpExtensionProc - I get a 404 error returned instead - it never gets as far as Tomcat. Does anyone know if this configuration works and what magic is needed to get past this problem? Thanks, Nick -- Nick Tatham Peramon Technology Limited +44 118 984 0506 www.peramon.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: compression filter problem
I am Developing Web application using tomcat. I want to Comopress my all jsp pages in web application, for that i have make some java filter classes and make changes in web.xml. but I am facing two problems 1. in jsp i have to put header content encoding is gzip, without that brower display zip data 2. browser keep showing that page is comeing and showing progress bar in status bar even data is display completely. Jason Hunter has an article on Servlet Filters at http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html Page Three of the article talks specifically about Compression Filters. Regards Roger
RE: compression filter problem
I'm using the compression filter that comes bundled with Tomcats webapps/example. Works for me, so i didn't programm anything myself. Just don't map anything else than *.jsp with the filter because my old fellow Netscape 4.7x accepts gzip - in theory - ...but... if you compress images you won't see them. ;-) Other browsers, no problem at all. -Original Message- From: Varley, Roger [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 11. Februar 2003 13:50 To: 'Tomcat Users List' Subject: RE: compression filter problem I am Developing Web application using tomcat. I want to Comopress my all jsp pages in web application, for that i have make some java filter classes and make changes in web.xml. but I am facing two problems 1. in jsp i have to put header content encoding is gzip, without that brower display zip data 2. browser keep showing that page is comeing and showing progress bar in status bar even data is display completely. Jason Hunter has an article on Servlet Filters at http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters. html http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html Page Three of the article talks specifically about Compression Filters. Regards Roger - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
compression filter problem
Hi I am Developing Web application using tomcat. I want to Comopress my all jsp pages in web application, for that i have make some java filter classes and make changes in web.xml. but I am facing two problems1. in jsp i have to put header content encoding is gzip, without that brower display zip data2. browser keep showing that page is comeing and showing progress bar in status bar even data is display completely. here i have attached java files, jsp and web.xml Hope to get answerthank you ?xml version=1.0 encoding=ISO-8859-1? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; web-app filter filter-namehelloWorld/filter-name filter-classcom.phoenix.filter.HelloWorldFilter/filter-class /filter filter filter-namemessage/filter-name filter-classcom.phoenix.filter.MessageFilter/filter-class init-param param-namemessage/param-name param-valueA message to you!/param-value /init-param /filter filter filter-nameprePost/filter-name filter-classcom.phoenix.filter.PrePostFilter/filter-class /filter filter filter-namegzip/filter-name filter-classcom.phoenix.filter.GZIPFilter/filter-class /filter filter-mappingfilter-namegzip/filter-nameurl-pattern/fine.jsp/url-pattern/filter-mapping /web-app - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
compression filter problem
Hi I am Developing Web application using tomcat. I want to Comopress my all jsp pages in web application, for that i have make some java filter classes and make changes in web.xml. but I am facing two problems1. in jsp i have to put header content encoding is gzip, without that brower display zip data2. browser keep showing that page is comeing and showing progress bar in status bar even data is display completely. here i have attached zip file contains java files(com.phoenix.filter.*.java), jsp and web.xml Hope to get answerthank you javafile.zip Description: Zip compressed data - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: compression filter problem
All I found was your web.xml file. You'll need to re-attach your jsp and java files. Note that I posted stuff about this and still haven't found a simple solution. http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg82477.html Jacob Hookum figured out a way to do it using the same logic as the filter in Tomcat's examples app. However, that one seems unnecessarily complex. It seems the problem is resetting the content-type and content-length headers. I try to set them, but they just don't change and I just don't understand why. Must be somewhat perplexing because no one else came up with a reason why they weren't being set either. Not sure if it is a bug in Tomcat or what??? Anyway, if you figure it out, make sure you post your solution. I'd be very interested in it. I'll do likewise. Jake At 10:20 AM 2/11/2003 +0530, you wrote: Hi I am Developing Web application using tomcat. I want to Comopress my all jsp pages in web application, for that i have make some java filter classes and make changes in web.xml. but I am facing two problems 1. in jsp i have to put header content encoding is gzip, without that brower display zip data 2. browser keep showing that page is comeing and showing progress bar in status bar even data is display completely. here i have attached java files, jsp and web.xml Hope to get answer thank you - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: GZIP filter problem....
did you look at CompressionFilter.java that is part of the examples distributed with Tomcat? Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:22 PM To: Tomcat Users List Subject: GZIP filter problem I'm trying to use a GZIP servlet filter under Tomcat-4.1.18. I am basing this filter on an existing example at Orion ( http://www.orionserver.com/tutorials/filters/5.html ) It GZIPs fine and, in my debugging, I can decompress the data back to what it was originally (more on that below). The problem is, all I get when I send the data out to the browser is non-decompressed garbled data. That is, the browser doesn't seem to understand that it is gzip'ed stream and doesn't decode it. Here is the relevant code. Can anyone see what the problem might be? Note that in the no compression case where I simply call dofilter(res, wrapper.getData()) it works just fine, so it isn't a problem with the filter in general ... ... ... httpResponse.setHeader(Vary, Accept-Encoding); OutputStream out = response.getOutputStream(); httpResponse.setHeader(Content-Encoding, gzip); ByteArrayOutputStream compressed = new ByteArrayOutputStream(); GZIPOutputStream gzout = new GZIPOutputStream(compressed); gzout.write(wrapper.getData()); gzout.finish(); gzout.close(); if (logger.isDebugEnabled()) { logger.debug(compressed data...); logger.debug(compressed); ByteArrayInputStream bais = new ByteArrayInputStream(compressed.toByteArray()); GZIPInputStream gzin = new GZIPInputStream(bais); byte[] buffer = new byte[1024]; int n, i = 0, m = buffer.length; while ((n = gzin.read (buffer, i, m - i)) = 0) { i += n; if (i = m) { byte[] newBuffer = new byte[m *= 2]; System.arraycopy (buffer, 0, newBuffer, 0, i); buffer = newBuffer; } } byte[] result = new byte[i]; System.arraycopy (buffer, 0, result, 0, i); ByteArrayOutputStream decompressed = new ByteArrayOutputStream(); DataOutputStream daos = new DataOutputStream(decompressed); daos.write(result); daos.flush(); daos.close(); logger.debug(decompressed data...); logger.debug(decompressed); } out.write(compressed.toByteArray()); response.setContentLength(compressed.size()); if (logger.isDebugEnabled()) logger.debug(Wrote filter compressed data: +compressed.size()+ bytes); out.flush(); response.flushBuffer(); out.close(); ... ... ... Here is an example of the debugging output so you can see that I can compress and decompress the data without issue... compressed data... ³±¯ÈÍQ(K-*ÎÌϳU2Ô3P²·ã²qÉÏMÌÌ+¶f2òsSm*'ós ó**ôÑÄ Ró rRAÂú0? ºÒ'sX decompressed data... ?xml version=1.0? RootMyElement name=someName/MyElement name=someOtherName//Root Note that the contentType was set by the servlet as text/xml and was not reset by the filter. Any ideas? It wouldn't be a bug in Tomcat, would it? I just don't see anything wrong with the code??? Thanks, Jake -- Best regards, Jacob mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: GZIP filter problem....
Hi Charlie, I looked at it a little bit, but, to be honest, that one is less straightforward (kind of messy, actually) and I'm not even sure it is doing any compression as it doesn't provide any logging stating the difference between the original size of the response and the compressed size (although it logs lots of other stuff). I'll continue to investigate, however, I guess my point is that I've seen a good number of examples of how to do the GZIP compression and the example I am following pretty much does exactly what all of them recommend. There is one from More Servlets and Java Server Pages by Marty Hall that also doesn't work under Tomcat-4.1.18 ( http://archive.moreservlets.com/Filter-Code/filters/WEB-INF/classes/moreservlets/filters/CompressionFilter.java ). I have a really hard time believing that all these people are just plain wrong about how they did this. The code looks valid based on all examples I've seen, and I've proven that the GZIP compression was done properly because I was able to decompress and print that to logging. I just can't get it to the browsers (IE5.5/6.0 and Mozilla) to understand the output. So, apart from looking at the example in Tomcat which, presumably, works (and I will continue to study it), is there anything in my code that is just obviously incorrect? If not, why doesn't it work? Jake At 07:03 AM 1/7/2003 -0500, you wrote: did you look at CompressionFilter.java that is part of the examples distributed with Tomcat? Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:22 PM To: Tomcat Users List Subject: GZIP filter problem I'm trying to use a GZIP servlet filter under Tomcat-4.1.18. I am basing this filter on an existing example at Orion ( http://www.orionserver.com/tutorials/filters/5.html ) It GZIPs fine and, in my debugging, I can decompress the data back to what it was originally (more on that below). The problem is, all I get when I send the data out to the browser is non-decompressed garbled data. That is, the browser doesn't seem to understand that it is gzip'ed stream and doesn't decode it. Here is the relevant code. Can anyone see what the problem might be? Note that in the no compression case where I simply call dofilter(res, wrapper.getData()) it works just fine, so it isn't a problem with the filter in general ... ... ... httpResponse.setHeader(Vary, Accept-Encoding); OutputStream out = response.getOutputStream(); httpResponse.setHeader(Content-Encoding, gzip); ByteArrayOutputStream compressed = new ByteArrayOutputStream(); GZIPOutputStream gzout = new GZIPOutputStream(compressed); gzout.write(wrapper.getData()); gzout.finish(); gzout.close(); if (logger.isDebugEnabled()) { logger.debug(compressed data...); logger.debug(compressed); ByteArrayInputStream bais = new ByteArrayInputStream(compressed.toByteArray()); GZIPInputStream gzin = new GZIPInputStream(bais); byte[] buffer = new byte[1024]; int n, i = 0, m = buffer.length; while ((n = gzin.read (buffer, i, m - i)) = 0) { i += n; if (i = m) { byte[] newBuffer = new byte[m *= 2]; System.arraycopy (buffer, 0, newBuffer, 0, i); buffer = newBuffer; } } byte[] result = new byte[i]; System.arraycopy (buffer, 0, result, 0, i); ByteArrayOutputStream decompressed = new ByteArrayOutputStream(); DataOutputStream daos = new DataOutputStream(decompressed); daos.write(result); daos.flush(); daos.close(); logger.debug(decompressed data...); logger.debug(decompressed); } out.write(compressed.toByteArray()); response.setContentLength(compressed.size()); if (logger.isDebugEnabled()) logger.debug(Wrote filter compressed data: +compressed.size()+ bytes); out.flush(); response.flushBuffer(); out.close(); ... ... ... Here is an example of the debugging output so you can see that I can compress and decompress the data without issue... compressed data... ³±¯ÈÍQ(K-*ÎÌϳU2Ô3P²·ã²qÉÏMÌÌ+¶f2òsSm*'ós ó**ôÑÄ Ró rRAÂú0? ºÓ'sX decompressed data... ?xml version=1.0? RootMyElement name=someName/MyElement name=someOtherName//Root Note that the contentType was set by the servlet as text/xml and was not reset by the filter. Any ideas? It wouldn't be a bug in Tomcat, would it? I just don't see anything wrong with the code??? Thanks, Jake -- Best regards, Jacob mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: GZIP filter problem....
try setting the encoding before you request the output stream. You may be losing the header by requesting the output stream first. httpResponse.setHeader(Content-Encoding, gzip); OutputStream out = response.getOutputStream(); I know you can't set headers after writing to the output stream, but I'm not sure if you can after getting a reference to the outputstream. IIRC, the getOutputStream() determines whether you have written anything or not(i.e. try getWriter() immediately after getOutputStream() and it will throw an error) Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 9:19 AM To: Tomcat Users List Subject: RE: GZIP filter problem Hi Charlie, I looked at it a little bit, but, to be honest, that one is less straightforward (kind of messy, actually) and I'm not even sure it is doing any compression as it doesn't provide any logging stating the difference between the original size of the response and the compressed size (although it logs lots of other stuff). I'll continue to investigate, however, I guess my point is that I've seen a good number of examples of how to do the GZIP compression and the example I am following pretty much does exactly what all of them recommend. There is one from More Servlets and Java Server Pages by Marty Hall that also doesn't work under Tomcat-4.1.18 ( http://archive.moreservlets.com/Filter-Code/filters/WEB-INF/cl asses/moreservlets/filters/CompressionFilter.java ). I have a really hard time believing that all these people are just plain wrong about how they did this. The code looks valid based on all examples I've seen, and I've proven that the GZIP compression was done properly because I was able to decompress and print that to logging. I just can't get it to the browsers (IE5.5/6.0 and Mozilla) to understand the output. So, apart from looking at the example in Tomcat which, presumably, works (and I will continue to study it), is there anything in my code that is just obviously incorrect? If not, why doesn't it work? Jake At 07:03 AM 1/7/2003 -0500, you wrote: did you look at CompressionFilter.java that is part of the examples distributed with Tomcat? Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:22 PM To: Tomcat Users List Subject: GZIP filter problem I'm trying to use a GZIP servlet filter under Tomcat-4.1.18. I am basing this filter on an existing example at Orion ( http://www.orionserver.com/tutorials/filters/5.html ) It GZIPs fine and, in my debugging, I can decompress the data back to what it was originally (more on that below). The problem is, all I get when I send the data out to the browser is non-decompressed garbled data. That is, the browser doesn't seem to understand that it is gzip'ed stream and doesn't decode it. Here is the relevant code. Can anyone see what the problem might be? Note that in the no compression case where I simply call dofilter(res, wrapper.getData()) it works just fine, so it isn't a problem with the filter in general ... ... ... httpResponse.setHeader(Vary, Accept-Encoding); OutputStream out = response.getOutputStream(); httpResponse.setHeader(Content-Encoding, gzip); ByteArrayOutputStream compressed = new ByteArrayOutputStream(); GZIPOutputStream gzout = new GZIPOutputStream(compressed); gzout.write(wrapper.getData()); gzout.finish(); gzout.close(); if (logger.isDebugEnabled()) { logger.debug(compressed data...); logger.debug(compressed); ByteArrayInputStream bais = new ByteArrayInputStream(compressed.toByteArray()); GZIPInputStream gzin = new GZIPInputStream(bais); byte[] buffer = new byte[1024]; int n, i = 0, m = buffer.length; while ((n = gzin.read (buffer, i, m - i)) = 0) { i += n; if (i = m) { byte[] newBuffer = new byte[m *= 2]; System.arraycopy (buffer, 0, newBuffer, 0, i); buffer = newBuffer; } } byte[] result = new byte[i]; System.arraycopy (buffer, 0, result, 0, i); ByteArrayOutputStream decompressed = new ByteArrayOutputStream(); DataOutputStream daos = new DataOutputStream(decompressed); daos.write(result); daos.flush(); daos.close(); logger.debug(decompressed data...); logger.debug(decompressed); } out.write(compressed.toByteArray()); response.setContentLength(compressed.size()); if (logger.isDebugEnabled()) logger.debug(Wrote filter compressed data: +compressed.size()+ bytes); out.flush(); response.flushBuffer(); out.close(); ... ... ... Here is an example of the debugging output so you can see
RE: GZIP filter problem....
just noticed this. Two more lines reversed. Set the content lenght *before* you write to the response. IE can be really anal if it doesn't know the content length. you have: out.write(compressed.toByteArray()); response.setContentLength(compressed.size()); it is possible that the default servlet set the content-length for your static file and that could be why it worked and not your servlet. overall: httpResponse.setHeader(Vary, Accept-Encoding); httpResponse.setHeader(Content-Encoding, gzip); OutputStream out = response.getOutputStream(); ... response.setContentLength(compressed.size()); out.write(compressed.toByteArray()); out.close(); Another thing from above code. Is 'httpResponse' and 'response' the same object? I am assuming that one is the 'ServletResponse' and the other casted as the 'HttpServletResponse'. I would use the same reference in both places. You could be skipping some functionality in the HttpServletResponse since it has your headers. Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 2:55 PM To: Tomcat Users List Subject: RE: GZIP filter problem Hi Charlie, Thanks for the tip. Actually, that seems to make no difference. I finally decided to test it with a plain HTML page. It successfully GZIP'ed an html document with an original data size of 636 bytes down to 369 bytes and the output didn't get garbled on the browser side. This was with specifying the compressed header after I did response.getOuputStream() but before I actually wrote the data. So, that validates that my GZIP filter generally works correctly. The curious thing is that I also tried it with a simple .jsp page. I got the same sort of garbled data as I got when sending xml data from a servlet. In all cases, I can see the decompressed data just fine in debugging. So, this leads me to believe there is either a bug in Tomcat or there is some other header or something that I need to set. GZIP'ing static files, such as .html files, works fine. GZIP'ing data coming from a servlet or .jsp doesn't work. This narrows it down. Can you think of anything else which might be the issue here? Should I report a bug against Tomcat? I hate to do that until I really understand the problem, though. Thanks for continued your help! Jake Quoting Cox, Charlie [EMAIL PROTECTED]: try setting the encoding before you request the output stream. You may be losing the header by requesting the output stream first. httpResponse.setHeader(Content-Encoding, gzip); OutputStream out = response.getOutputStream(); I know you can't set headers after writing to the output stream, but I'm not sure if you can after getting a reference to the outputstream. IIRC, the getOutputStream() determines whether you have written anything or not(i.e. try getWriter() immediately after getOutputStream() and it will throw an error) Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 9:19 AM To: Tomcat Users List Subject: RE: GZIP filter problem Hi Charlie, I looked at it a little bit, but, to be honest, that one is less straightforward (kind of messy, actually) and I'm not even sure it is doing any compression as it doesn't provide any logging stating the difference between the original size of the response and the compressed size (although it logs lots of other stuff). I'll continue to investigate, however, I guess my point is that I've seen a good number of examples of how to do the GZIP compression and the example I am following pretty much does exactly what all of them recommend. There is one from More Servlets and Java Server Pages by Marty Hall that also doesn't work under Tomcat-4.1.18 ( http://archive.moreservlets.com/Filter-Code/filters/WEB-INF/cl asses/moreservlets/filters/CompressionFilter.java ). I have a really hard time believing that all these people are just plain wrong about how they did this. The code looks valid based on all examples I've seen, and I've proven that the GZIP compression was done properly because I was able to decompress and print that to logging. I just can't get it to the browsers (IE5.5/6.0 and Mozilla) to understand the output. So, apart from looking at the example in Tomcat which, presumably, works (and I will continue to study it), is there anything in my code that is just obviously incorrect? If not, why doesn't it work? Jake At 07:03 AM 1/7/2003 -0500, you wrote: did you look at CompressionFilter.java that is part of the examples distributed with Tomcat? Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:22 PM
RE: GZIP filter problem....
()+ bytes); } } else { out.write(origBytes); if (logger.isDebugEnabled()) { logger.debug(Bypassed GZIP filtering...); logger.debug(Orig data size: +origBytes.length+ bytes); } } out.flush(); response.flushBuffer(); out.close(); } thanks, Jake Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 2:55 PM To: Tomcat Users List Subject: RE: GZIP filter problem Hi Charlie, Thanks for the tip. Actually, that seems to make no difference. I finally decided to test it with a plain HTML page. It successfully GZIP'ed an html document with an original data size of 636 bytes down to 369 bytes and the output didn't get garbled on the browser side. This was with specifying the compressed header after I did response.getOuputStream() but before I actually wrote the data. So, that validates that my GZIP filter generally works correctly. The curious thing is that I also tried it with a simple .jsp page. I got the same sort of garbled data as I got when sending xml data from a servlet. In all cases, I can see the decompressed data just fine in debugging. So, this leads me to believe there is either a bug in Tomcat or there is some other header or something that I need to set. GZIP'ing static files, such as .html files, works fine. GZIP'ing data coming from a servlet or .jsp doesn't work. This narrows it down. Can you think of anything else which might be the issue here? Should I report a bug against Tomcat? I hate to do that until I really understand the problem, though. Thanks for continued your help! Jake Quoting Cox, Charlie [EMAIL PROTECTED]: try setting the encoding before you request the output stream. You may be losing the header by requesting the output stream first. httpResponse.setHeader(Content-Encoding, gzip); OutputStream out = response.getOutputStream(); I know you can't set headers after writing to the output stream, but I'm not sure if you can after getting a reference to the outputstream. IIRC, the getOutputStream() determines whether you have written anything or not(i.e. try getWriter() immediately after getOutputStream() and it will throw an error) Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 9:19 AM To: Tomcat Users List Subject: RE: GZIP filter problem Hi Charlie, I looked at it a little bit, but, to be honest, that one is less straightforward (kind of messy, actually) and I'm not even sure it is doing any compression as it doesn't provide any logging stating the difference between the original size of the response and the compressed size (although it logs lots of other stuff). I'll continue to investigate, however, I guess my point is that I've seen a good number of examples of how to do the GZIP compression and the example I am following pretty much does exactly what all of them recommend. There is one from More Servlets and Java Server Pages by Marty Hall that also doesn't work under Tomcat-4.1.18 ( http://archive.moreservlets.com/Filter-Code/filters/WEB-INF/cl asses/moreservlets/filters/CompressionFilter.java ). I have a really hard time believing that all these people are just plain wrong about how they did this. The code looks valid based on all examples I've seen, and I've proven that the GZIP compression was done properly because I was able to decompress and print that to logging. I just can't get it to the browsers (IE5.5/6.0 and Mozilla) to understand the output. So, apart from looking at the example in Tomcat which, presumably, works (and I will continue to study it), is there anything in my code that is just obviously incorrect? If not, why doesn't it work? Jake At 07:03 AM 1/7/2003 -0500, you wrote: did you look at CompressionFilter.java that is part of the examples distributed with Tomcat? Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:22 PM To: Tomcat Users List Subject: GZIP filter problem I'm trying to use a GZIP servlet filter under Tomcat-4.1.18. I am basing this filter on an existing example at Orion ( http://www.orionserver.com/tutorials/filters/5.html ) It GZIPs fine and, in my debugging, I can decompress the data back to what it was originally (more on that below). The problem is, all I get when I send the data out to the browser is non-decompressed garbled data. That is, the browser doesn't seem
RE: GZIP filter problem....
Hi Charlie, Thanks for the tip. Actually, that seems to make no difference. I finally decided to test it with a plain HTML page. It successfully GZIP'ed an html document with an original data size of 636 bytes down to 369 bytes and the output didn't get garbled on the browser side. This was with specifying the compressed header after I did response.getOuputStream() but before I actually wrote the data. So, that validates that my GZIP filter generally works correctly. The curious thing is that I also tried it with a simple .jsp page. I got the same sort of garbled data as I got when sending xml data from a servlet. In all cases, I can see the decompressed data just fine in debugging. So, this leads me to believe there is either a bug in Tomcat or there is some other header or something that I need to set. GZIP'ing static files, such as .html files, works fine. GZIP'ing data coming from a servlet or .jsp doesn't work. This narrows it down. Can you think of anything else which might be the issue here? Should I report a bug against Tomcat? I hate to do that until I really understand the problem, though. Thanks for continued your help! Jake Quoting Cox, Charlie [EMAIL PROTECTED]: try setting the encoding before you request the output stream. You may be losing the header by requesting the output stream first. httpResponse.setHeader(Content-Encoding, gzip); OutputStream out = response.getOutputStream(); I know you can't set headers after writing to the output stream, but I'm not sure if you can after getting a reference to the outputstream. IIRC, the getOutputStream() determines whether you have written anything or not(i.e. try getWriter() immediately after getOutputStream() and it will throw an error) Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 9:19 AM To: Tomcat Users List Subject: RE: GZIP filter problem Hi Charlie, I looked at it a little bit, but, to be honest, that one is less straightforward (kind of messy, actually) and I'm not even sure it is doing any compression as it doesn't provide any logging stating the difference between the original size of the response and the compressed size (although it logs lots of other stuff). I'll continue to investigate, however, I guess my point is that I've seen a good number of examples of how to do the GZIP compression and the example I am following pretty much does exactly what all of them recommend. There is one from More Servlets and Java Server Pages by Marty Hall that also doesn't work under Tomcat-4.1.18 ( http://archive.moreservlets.com/Filter-Code/filters/WEB-INF/cl asses/moreservlets/filters/CompressionFilter.java ). I have a really hard time believing that all these people are just plain wrong about how they did this. The code looks valid based on all examples I've seen, and I've proven that the GZIP compression was done properly because I was able to decompress and print that to logging. I just can't get it to the browsers (IE5.5/6.0 and Mozilla) to understand the output. So, apart from looking at the example in Tomcat which, presumably, works (and I will continue to study it), is there anything in my code that is just obviously incorrect? If not, why doesn't it work? Jake At 07:03 AM 1/7/2003 -0500, you wrote: did you look at CompressionFilter.java that is part of the examples distributed with Tomcat? Charlie -Original Message- From: Jacob Kjome [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 8:22 PM To: Tomcat Users List Subject: GZIP filter problem I'm trying to use a GZIP servlet filter under Tomcat-4.1.18. I am basing this filter on an existing example at Orion ( http://www.orionserver.com/tutorials/filters/5.html ) It GZIPs fine and, in my debugging, I can decompress the data back to what it was originally (more on that below). The problem is, all I get when I send the data out to the browser is non-decompressed garbled data. That is, the browser doesn't seem to understand that it is gzip'ed stream and doesn't decode it. Here is the relevant code. Can anyone see what the problem might be? Note that in the no compression case where I simply call dofilter(res, wrapper.getData()) it works just fine, so it isn't a problem with the filter in general ... ... ... httpResponse.setHeader(Vary, Accept-Encoding); OutputStream out = response.getOutputStream(); httpResponse.setHeader(Content-Encoding, gzip); ByteArrayOutputStream compressed = new ByteArrayOutputStream(); GZIPOutputStream gzout = new GZIPOutputStream(compressed); gzout.write(wrapper.getData()); gzout.finish(); gzout.close(); if (logger.isDebugEnabled()) { logger.debug
GZIP filter problem....
I'm trying to use a GZIP servlet filter under Tomcat-4.1.18. I am basing this filter on an existing example at Orion ( http://www.orionserver.com/tutorials/filters/5.html ) It GZIPs fine and, in my debugging, I can decompress the data back to what it was originally (more on that below). The problem is, all I get when I send the data out to the browser is non-decompressed garbled data. That is, the browser doesn't seem to understand that it is gzip'ed stream and doesn't decode it. Here is the relevant code. Can anyone see what the problem might be? Note that in the no compression case where I simply call dofilter(res, wrapper.getData()) it works just fine, so it isn't a problem with the filter in general ... ... ... httpResponse.setHeader(Vary, Accept-Encoding); OutputStream out = response.getOutputStream(); httpResponse.setHeader(Content-Encoding, gzip); ByteArrayOutputStream compressed = new ByteArrayOutputStream(); GZIPOutputStream gzout = new GZIPOutputStream(compressed); gzout.write(wrapper.getData()); gzout.finish(); gzout.close(); if (logger.isDebugEnabled()) { logger.debug(compressed data...); logger.debug(compressed); ByteArrayInputStream bais = new ByteArrayInputStream(compressed.toByteArray()); GZIPInputStream gzin = new GZIPInputStream(bais); byte[] buffer = new byte[1024]; int n, i = 0, m = buffer.length; while ((n = gzin.read (buffer, i, m - i)) = 0) { i += n; if (i = m) { byte[] newBuffer = new byte[m *= 2]; System.arraycopy (buffer, 0, newBuffer, 0, i); buffer = newBuffer; } } byte[] result = new byte[i]; System.arraycopy (buffer, 0, result, 0, i); ByteArrayOutputStream decompressed = new ByteArrayOutputStream(); DataOutputStream daos = new DataOutputStream(decompressed); daos.write(result); daos.flush(); daos.close(); logger.debug(decompressed data...); logger.debug(decompressed); } out.write(compressed.toByteArray()); response.setContentLength(compressed.size()); if (logger.isDebugEnabled()) logger.debug(Wrote filter compressed data: +compressed.size()+ bytes); out.flush(); response.flushBuffer(); out.close(); ... ... ... Here is an example of the debugging output so you can see that I can compress and decompress the data without issue... compressed data... ³±¯ÈÍQ(K-*ÎÌϳU2Ô3P²·ã²qÉÏMÌÌ+¶2òsSmósó*ôÑÄRórRAÂú0? ºÒX decompressed data... ?xml version=1.0? RootMyElement name=someName/MyElement name=someOtherName//Root Note that the contentType was set by the servlet as text/xml and was not reset by the filter. Any ideas? It wouldn't be a bug in Tomcat, would it? I just don't see anything wrong with the code??? Thanks, Jake -- Best regards, Jacob mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Tomcat 4 - Filter problem
I wrote a filter. Put it in a jar file and added to classpath. This is the result: java.lang.ClassCastException: net.indaco.klyx.auth.tomcat.KlyxFilter at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilter Config.java:250) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFil terConfig.java:311) at org.apache.catalina.core.ApplicationFilterConfig.init(ApplicationFilterCon fig.java:120) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:28 81) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3118) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1059) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1059) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:253) at org.apache.catalina.core.StandardService.start(StandardService.java:353) at org.apache.catalina.core.StandardServer.start(StandardServer.java:458) at org.apache.catalina.startup.Catalina.start(Catalina.java:707) at org.apache.catalina.startup.Catalina.execute(Catalina.java:627) at org.apache.catalina.startup.Catalina.process(Catalina.java:177) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:177) If I put the filter class in WEB-INF/classes all goes well. Where's the problem? I got a similar exception writing a custom Realm to authenticate against. Thx Francesco
Antwort: Tomcat 4 - Filter problem
Hi, It is a part of the Tomcat's user guide (http://jakarta.apache.org/tomcat/jakarta-tomcat/src/doc/uguide/tomcat_ug.html). Maybe, the point 3 applies to the problem. Each Context represents a path in the Tomcat hierarchy where you place a web application. A Tomcat Context has the following configuration: 1. The path where the context is located. This can be a full path or relative to the ContextManager's home. 2. Debug level used for logging debug messages. 3. A reloadable flag. When developing a servlet it is very convenient to have Tomcat reload it upon change, this lets you fix bugs and have Tomcat test the new code without the need to shutdown and restart. To turn on servlet reloading set the reloadable flag to true. Detecting changes however is time consuming; moreover, since the new servlets are getting loaded in a new class-loader object there are cases where this class-reloading trigger casts errors. To avoid these problems you can set the reloadable flag to false; this will disable the autoreload feature. Mit freundlichen Grüßen Christian Schildt Diplom-Betriebswirt (FH) Softwaredeveloper Phone: 089/89013023 Mailto: [EMAIL PROTECTED] ELAXY AG Gutenbergstr. 5 D-82178 Puchheim bei München Phone: +089/8901300 Fax: +089/89013089 www.elaxy.com Francesco Marsoni An: [EMAIL PROTECTED] [EMAIL PROTECTED]Kopie: enze.it Thema: Tomcat 4 - Filter problem 02.05.2001 13:40 Bitte antworten an tomcat-user I wrote a filter. Put it in a jar file and added to classpath. This is the result: java.lang.ClassCastException: net.indaco.klyx.auth.tomcat.KlyxFilter at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilter Config.java:250) at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFil terConfig.java:311) at org.apache.catalina.core.ApplicationFilterConfig.init(ApplicationFilterCon fig.java:120) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:28 81) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3118) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1059) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1059) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:253) at org.apache.catalina.core.StandardService.start(StandardService.java:353) at org.apache.catalina.core.StandardServer.start(StandardServer.java:458) at org.apache.catalina.startup.Catalina.start(Catalina.java:707) at org.apache.catalina.startup.Catalina.execute(Catalina.java:627) at org.apache.catalina.startup.Catalina.process(Catalina.java:177) at java.lang.reflect.Method.invoke(Native Method) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:177) If I put the filter class in WEB-INF/classes all goes well. Where's the problem? I got a similar exception writing a custom Realm to authenticate against. Thx Francesco
ISAPI filter problem on win2k, more info
I have triple checked all of my settings and whenever I try to start IIS I get the error below. Here's the strangest thing. I downloaded the source and added some DebugBreak() calls and recompiled it and put it into the designated filter location. When I do this I still get the problem and the DebugBreak() calls are never encountered. This is strange since I put the calls in all the filter entry points on the first line. Error from Win2k. Makes you think it can't find it, but it's there. The HTTP Filter DLL E:\Internet\tomcat\isapi\isapi_redirect.dll failed to load. The data is the error. For additional information specific to this message please visit the Microsoft Online Support site located at: http://www.microsoft.com/contentredirect.asp. Any ideas? Thanks, Dave Brown
isapi_redirect filter problem
Hi I tried to install the isapi+AF8-redirec dll on my windows 2000 IIS as explained in the document : 'Tomcat IIS HowTo' my problem is that the that the green arrow up (indicating that the dll is in the air) doesn't appear after restarting the iis as result the redirect doesn't work.( a red arrow down appear instead) if someone had this problem tell me, how can I overcome it ? Thanks allot for the attention Shlomi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]