Re: filter: How to set browser encoding?
Mark, have a look here: http://javawebparts.sourceforge.net/javadocs/javawebparts/filter/CharacterEncodingFilter.html Just added that to JWP last weekend :) It essentially calls request.setCharacterEncoding() with whatever you configure. (Oops... ignore the description of the encodingScheme parameter... just realized I have a cut-and-paste error in the javadoc. D'oh!). -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] On Wed, October 12, 2005 10:53 am, Mark said: Hi everybody, I've got a request from my client to force an encoding in the browser, regardless what user have set. When I set encoding inside my filter to Windows-1257 in the HTML source code I see only ?s:??? ? ???. Is there any easy way to enforce browser to set proper encoding? May be I need to setContent type after I obtain a writer in the servlet? Note, all outputs are generated by servlets: public void doPost( HttpServletRequest req, HttpServletResponse resp ) throws IOException, ServletException { // do something resp.setContentType(text/html); resp.getWriter().println(output); } In MyFilter.doFilter() I do following: (HttpServletResponse)response).setContentType(text/html;charset=Windows-1257) I use 5.0.28 with Redhat 9. Any input is welcome. Thanks! Mark. __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.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: filter question
Hi Scott. Your filter should probably set an attribute in the request or perhaps the session, that your jsp could display, rather than writing to the response's writer object. By opening up the writer and writing to it you are effectively setting the response to the request to be the contents of your call to the printwriter.println() method. For example: your doFilter method could have something like: request.setAttribute(IPAddress, getIPAddress()); You'll have to write the getIPAddress() method. :-) In your jsp, you could pull the stored value out of the request and display it in the page: IP Address: %= request.getAttribute(IPAddress) % Hope that helps... Regards, Pete. Quoting Scott Purcell [EMAIL PROTECTED]: Hello, I am having trouble with a filter. Code below. What I am trying to achieve is as follows: We have a current web-site, with a lot of jsp pages, etc. We are moving the code to a load-balanced environment, and I would like to put a hidden IP address into each display page. This way I can know which environment the page came from when debugging, etc. I figured I could use a 'filter' and have each page insert the IP into itself in a hidden field. I am unable to achieve my goal and could use a hand if anyone has experience with this. Is this possible, or will I have to write into a header and then edit each jsp page to show the value? Here is what I have, but it does not print anything on pages. web.xml filter filter-nameHelloWorld/filter-name filter-classchapter18.HelloWorldFilter/filter-class /filter filter-mapping filter-nameHelloWorld/filter-name url-pattern/*.jsp/url-pattern /filter-mapping And I have the servlet code from SCWCD book package chapter18; import java.io.*; import javax.servlet.*; public class HelloWorldFilter implements Filter { public void destroy() { } public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) throws ServletException, IOException { PrintWriter printwriter = servletresponse.getWriter(); printwriter.println(); } public void init(FilterConfig filterconfig) { filterConfig = filterconfig; System.out.println(Chapter 18: HelloWorldFilter initialized); } public HelloWorldFilter() { } private FilterConfig filterConfig; } Thanks, Scott -- Peter Davison _/_/_/ _/_/_/ _/_/_/ e: [EMAIL PROTECTED] _/ _/ _/ _/ _/ _/ w: http://rpdavison.ca _/_/_/ _/_/_/ _/ _/ c: 647 883 6486_/ _/ _/ _/ _/ h: 416 699 2964 _/ _/ _/ _/_/_/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: filter question
Peter, I don't think Scott wants to modify every JSP in his application. Sounds like he has a lot! Scott, the reason your filter isn't working is because the response from your servlets is getting sent to the client before your filter has a chance to add it's text to it (using the PrintWriter). To have this work you need to wrap the original HttpServletResponse object with your own. You do this by writing your own object that extends the HttpServletResponse interface. This custom response object is then passed to the doFilter() method of your filter class. Your custom HttpServletResponse object needs to also implement it's own output stream so that you can capture any output that any downstream code adds to the response. Once the doFilter() method returns from the stack you can modify the output in your custom object's output buffer any way you want. Then you just send the contents of that buffer to the original output stream. This probably sounds pretty complicated. It's late (for me) and I'm tired. Sorry. Try doing some research on the HttpServletResponseWrapper class. It's a convenience class that already implements the HttpServletResponse interface and implements the methods of that interface (actually it just delegates the calls to the underlying response object). All you need to do is extend this class and override the methods you need to do any custom work. In your case you'd extend the getOutputStream() method and return your code's version of the output stream. To give you an idea of how to do it, do a Google on Servlet filters (try compression filters). Somebody out there has probably written an article and/or posted their code. Your code would be similar in nature. Good luck! Virtually, Andre Van Klaveren SCP On Wed, 23 Feb 2005 17:06:06 -0500, Peter Davison [EMAIL PROTECTED] wrote: Hi Scott. Your filter should probably set an attribute in the request or perhaps the session, that your jsp could display, rather than writing to the response's writer object. By opening up the writer and writing to it you are effectively setting the response to the request to be the contents of your call to the printwriter.println() method. For example: your doFilter method could have something like: request.setAttribute(IPAddress, getIPAddress()); You'll have to write the getIPAddress() method. :-) In your jsp, you could pull the stored value out of the request and display it in the page: IP Address: %= request.getAttribute(IPAddress) % Hope that helps... Regards, Pete. Quoting Scott Purcell [EMAIL PROTECTED]: Hello, I am having trouble with a filter. Code below. What I am trying to achieve is as follows: We have a current web-site, with a lot of jsp pages, etc. We are moving the code to a load-balanced environment, and I would like to put a hidden IP address into each display page. This way I can know which environment the page came from when debugging, etc. I figured I could use a 'filter' and have each page insert the IP into itself in a hidden field. I am unable to achieve my goal and could use a hand if anyone has experience with this. Is this possible, or will I have to write into a header and then edit each jsp page to show the value? Here is what I have, but it does not print anything on pages. web.xml filter filter-nameHelloWorld/filter-name filter-classchapter18.HelloWorldFilter/filter-class /filter filter-mapping filter-nameHelloWorld/filter-name url-pattern/*.jsp/url-pattern /filter-mapping And I have the servlet code from SCWCD book package chapter18; import java.io.*; import javax.servlet.*; public class HelloWorldFilter implements Filter { public void destroy() { } public void doFilter(ServletRequest servletrequest, ServletResponse servletresponse, FilterChain filterchain) throws ServletException, IOException { PrintWriter printwriter = servletresponse.getWriter(); printwriter.println(); } public void init(FilterConfig filterconfig) { filterConfig = filterconfig; System.out.println(Chapter 18: HelloWorldFilter initialized); } public HelloWorldFilter() { } private FilterConfig filterConfig; } Thanks, Scott -- Peter Davison _/_/_/ _/_/_/ _/_/_/ e: [EMAIL PROTECTED] _/ _/ _/ _/ _/ _/ w: http://rpdavison.ca _/_/_/ _/_/_/ _/ _/ c: 647 883 6486_/ _/ _/ _/ _/ h: 416 699 2964 _/ _/ _/ _/_/_/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
RE: Filter/...
Hi, The Servlet Spec v2.4, which Tomcat 5.x implements, provides an answer to your problem: add a forward/include directives to your filter-mapping. See SRV.13.1 for the syntax and examples. Yoav Shapira http://www.yoavshapira.com -Original Message- From: QM [mailto:[EMAIL PROTECTED] Sent: Saturday, December 04, 2004 10:24 PM To: Tomcat Users List Subject: Re: Filter/... On Sat, Dec 04, 2004 at 05:56:15PM +, Brij Naald wrote: : The filter I have now, always get called when there is an incoming request. : But when a servlet uses a requestdispatcher to include another servlet, the : filter doesn't get called. This makes sense: filters are for external requests, not intra-container requests. This is why you can include() data or forward() to resources that are otherwise protected from direct end-user requests (e.g. files under WEB-INF). : But what I need to get is: : Request -- Filter - Servlet1 - Filter - Servlet2 You may want to consider a high-level redesign, or at least change the include() to an HTTP request in and of itself. What's going on in your design that you require the filter to wrap the inner (include()'d) request? Storing/changing session objects? -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - 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: Filter/...
Hi Brij, I am not sure I have fully understood your question. In any case, I believe that for accomplishing what you've stated you have 2 options: - Use a listener class (it's like a filter, but it's automatically invoked by the servlet container on the ocurrence of different kinds of events, being one of those the initiailization of the servlet context. - Use the init() method on the servlet class. This method is executed prior to any request being delivered to that servlet through the service method. Agains, not sure if this solves your specific problem. Regards, Freddy. -Mensaje original- De: Brij Naald [mailto:[EMAIL PROTECTED] Enviado el: sábado, 04 de diciembre de 2004 17:20 Para: [EMAIL PROTECTED] Asunto: Filter/... Hi, I need to run a class everytime before a servlet is started. One option is to make a filter, the problem here is that a filter doesn't get called when a servlet is invoked via the requestDispatcher. Is there another solution for this problem? _ MSN Music: download je muziek legaal ! http://entertainment.msn.be/muziek/musicclub - 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/...
Hi, you indeed didn't the question :-) (but still, thanks for answering!) The problem is as follows: I'm making a plugin which puts a wrapper around the request of a servlet. A servlet gets invoked by: doGet(HttpServletRequest request, HttpServletResponse response) What I want to do now is to put a filter in front of it. When a request comes in, the filter does: newrequest= new RequestWrapper(request); chain.doFilter(newrequest, response); That way the servlet is invoked with a wrapper around the request. Until now, this approach works. Now comes the problem: the filter also does some other things than creating the wrapper. That way it always has to be called, before a servlet is called. The filter I have now, always get called when there is an incoming request. But when a servlet uses a requestdispatcher to include another servlet, the filter doesn't get called. In a little schema: Without filter the call looks like: Request -- Servlet1 -- Servlet2(so servlet1 uses a requestdispatcher to include servlet2) If you add a filter to this you get: Request -- Filter - Servlet1 - Servlet2 But what I need to get is: Request -- Filter - Servlet1 - Filter - Servlet2 _ Heb je MSN WebMessenger al ontdekt? http://webmessenger.msn.com/?mkt=nl-be - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter/...
Interesting issue. Anyway, can't think of anything that solves it in a clean way. If you give me (if you can) further information about what your filter does, I could give it a try at thinking about an alternative solution. Cheers, F. -Mensaje original- De: Brij Naald [mailto:[EMAIL PROTECTED] Enviado el: sábado, 04 de diciembre de 2004 18:56 Para: [EMAIL PROTECTED] Asunto: RE: Filter/... Hi, you indeed didn't the question :-) (but still, thanks for answering!) The problem is as follows: I'm making a plugin which puts a wrapper around the request of a servlet. A servlet gets invoked by: doGet(HttpServletRequest request, HttpServletResponse response) What I want to do now is to put a filter in front of it. When a request comes in, the filter does: newrequest= new RequestWrapper(request); chain.doFilter(newrequest, response); That way the servlet is invoked with a wrapper around the request. Until now, this approach works. Now comes the problem: the filter also does some other things than creating the wrapper. That way it always has to be called, before a servlet is called. The filter I have now, always get called when there is an incoming request. But when a servlet uses a requestdispatcher to include another servlet, the filter doesn't get called. In a little schema: Without filter the call looks like: Request -- Servlet1 -- Servlet2(so servlet1 uses a requestdispatcher to include servlet2) If you add a filter to this you get: Request -- Filter - Servlet1 - Servlet2 But what I need to get is: Request -- Filter - Servlet1 - Filter - Servlet2 _ Heb je MSN WebMessenger al ontdekt? http://webmessenger.msn.com/?mkt=nl-be - 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/...
On Sat, Dec 04, 2004 at 05:56:15PM +, Brij Naald wrote: : The filter I have now, always get called when there is an incoming request. : But when a servlet uses a requestdispatcher to include another servlet, the : filter doesn't get called. This makes sense: filters are for external requests, not intra-container requests. This is why you can include() data or forward() to resources that are otherwise protected from direct end-user requests (e.g. files under WEB-INF). : But what I need to get is: : Request -- Filter - Servlet1 - Filter - Servlet2 You may want to consider a high-level redesign, or at least change the include() to an HTTP request in and of itself. What's going on in your design that you require the filter to wrap the inner (include()'d) request? Storing/changing session objects? -QM -- software -- http://www.brandxdev.net tech news -- http://www.RoarNetworX.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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: Filter tricks in tomcat
Hi, I assume that when you say capture you mean handle ? Or maybe wrap? To only handle outgoing (response) data in a filter, do something like this: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws Blah { chain.doFilter(request, response); // Now do whatever you want with the response // Remember though that the response is likely committed by now } To only wrap a response is even simpler: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws Blah { // Do whatever chain.doFilter(request, new MyResponseWrapper(response)); // Do whatever } Yoav Shapira http://www.yoavshapira.com -Original Message- From: Pablo Carretero [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 09, 2004 3:06 AM To: [EMAIL PROTECTED] Subject: Filter tricks in tomcat Hi, I'm working with Tomcat 5 from 3 months ago. I understand the filter architecture, but I cannot capture the response filter for my JSP and servelt. Tomcat 5 is Servlet 2.4, so I thing it can filter either request or response. What I can do, is capture the entire request and its response, to have a good mechanism of statistics in my web application. So, can you help in order to know how can I catch the response in a filter?? Thanks in advanced, And best regards. .pcs __ Pablo Carretero Sánchez Cygnux Arquitecto de Software Pintor Velázquez nº 3 Esc Izq 7º B 28932 - Móstoles (Madrid) Movil: +34 699929150 [EMAIL PROTECTED] http://www.cygnux.com/egroupware/email/compose.php?folder=INBOXsessionid= 1 2a0f5acc6fd5805a190a5b55a147155kp3=7c4ad1ea016bfe58bf86addf2e6064d3domain = cygnux.com[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: Filter tricks in tomcat
actually, you can use filters to capture the response and then use a filter to dump the whole thing to the outputstream. What you'll have to do is create your own buffer to hold the content and not write to either the jspwriter or the printwriter in the servlet. the tricky part is this. if you have custom error pages, you'll have to be careful because there may already be stuff in the buffer. one of these days I'll have to write an example and post a patch for the tomcat jsp examples. peter On Tue, 9 Nov 2004 09:03:10 -0500, Shapira, Yoav [EMAIL PROTECTED] wrote: Hi, I assume that when you say capture you mean handle ? Or maybe wrap? To only handle outgoing (response) data in a filter, do something like this: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws Blah { chain.doFilter(request, response); // Now do whatever you want with the response // Remember though that the response is likely committed by now } To only wrap a response is even simpler: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws Blah { // Do whatever chain.doFilter(request, new MyResponseWrapper(response)); // Do whatever } Yoav Shapira http://www.yoavshapira.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter, HttpServletResponseWrapper, ServletOutputStream PrintWriter in Tomcat 5.x
Never mind: was a buffering issue. The JspWriter uses HttpServletResponseWrapper#flushBuffer() call, which I didn't override. Thanks anyway, Giampaolo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter question in 4.1.18, can my filter get unchunked and un zipped requests?
Hi Bill I've tried that but it doesn't appear to work. Is this because I need to upgrade to a later version of tomcat or what??? Thanks Donie -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Bill Barker Sent: 22 October 2004 03:54 To: [EMAIL PROTECTED] Subject: Re: Filter question in 4.1.18, can my filter get unchunked and unzipped requests? Donie Kelly [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all I've been reading up on filters to see if I can find a solution to an annoying problem. I can't find it so I'm looking here. I have this http filter that messes with the http request and response before it enters and leaves tomcat. The problem is that this filter works at a fairly low level on the data but a big mistake we made is that it assumes that the data is neither chunked or gzipped. Now we have a situation where some clients send data either in chunked form or gzipped form and out fairly complicated filter gets very confused as it's not expecting this. Ok, we can re-write the thing to handle this but doesn't tomcat already unzip and de-chunk data? Problem is where is it done? My question is, how can we arrange it so that the initial processing on the incoming data is done by tomcat so that it unzip and de-chunks the data before it reaches my filter? Is this possible??? Please say it is You may need to plug in a newer Coyote Connector (or, even, plug it in in the first place, since 4.1.18 is a bit old :), but it will at least unchunk the input for you. It doesn't currently unzip for you, but that should be a lot less common. Many thanks Donie - 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 question in 4.1.18, can my filter get unchunked and unzipped requests?
Donie Kelly [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi all I've been reading up on filters to see if I can find a solution to an annoying problem. I can't find it so I'm looking here. I have this http filter that messes with the http request and response before it enters and leaves tomcat. The problem is that this filter works at a fairly low level on the data but a big mistake we made is that it assumes that the data is neither chunked or gzipped. Now we have a situation where some clients send data either in chunked form or gzipped form and out fairly complicated filter gets very confused as it's not expecting this. Ok, we can re-write the thing to handle this but doesn't tomcat already unzip and de-chunk data? Problem is where is it done? My question is, how can we arrange it so that the initial processing on the incoming data is done by tomcat so that it unzip and de-chunks the data before it reaches my filter? Is this possible??? Please say it is You may need to plug in a newer Coyote Connector (or, even, plug it in in the first place, since 4.1.18 is a bit old :), but it will at least unchunk the input for you. It doesn't currently unzip for you, but that should be a lot less common. Many thanks Donie - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: filter config cause startup crash on Tomcat 5
the filter Tomcat no likie :) not sure what it is, any other suggestions. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:48:09 -0400 Try url-pattern /s.../* -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:31 PM To: [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 What order should it come in. Its near the top of the list. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:26:39 -0400 Check the order in web.xml. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:19 PM To: [EMAIL PROTECTED] Subject: filter config cause startup crash on Tomcat 5 I have created a DetectBrowser servlet to not allow certain browsers into the sillyApe directory/url. I wanted to use it as a filter rather then having to call it in each jsp since people can get to almost every page in the sillyApe directory without going through a single page, just thought it would be easier, as well as other issues. Anyway I am trying to figure out why I get a SEVERE: Error filterStart from Tomcat when I start it back up. HELP!!! filter filter-nameDetectBrowser/filter-name filter-classcom.dtribe.logic.DetectBrowser/filter-class /filter filter-mapping filter-nameDetectBrowser/filter-name url-pattern/sillyApe/url-pattern /filter-mapping HELP??? _ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034S U=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Take advantage of powerful junk e-mail filters built on patented Microsoft(r) SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] !DSPAM:4175798a322115253112009! _ Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=http://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: filter config cause startup crash on Tomcat 5
Have you changed it to url-pattern/sillyApe/*/url-pattern? BTW, post the error log. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 20, 2004 8:17 AM To: [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 the filter Tomcat no likie :) not sure what it is, any other suggestions. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:48:09 -0400 Try url-pattern /s.../* -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:31 PM To: [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 What order should it come in. Its near the top of the list. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:26:39 -0400 Check the order in web.xml. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:19 PM To: [EMAIL PROTECTED] Subject: filter config cause startup crash on Tomcat 5 I have created a DetectBrowser servlet to not allow certain browsers into the sillyApe directory/url. I wanted to use it as a filter rather then having to call it in each jsp since people can get to almost every page in the sillyApe directory without going through a single page, just thought it would be easier, as well as other issues. Anyway I am trying to figure out why I get a SEVERE: Error filterStart from Tomcat when I start it back up. HELP!!! filter filter-nameDetectBrowser/filter-name filter-classcom.dtribe.logic.DetectBrowser/filter-class /filter filter-mapping filter-nameDetectBrowser/filter-name url-pattern/sillyApe/url-pattern /filter-mapping HELP??? _ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034 S U=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Take advantage of powerful junk e-mail filters built on patented Microsoft(r) SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034S U=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Take advantage of powerful junk e-mail filters built on patented Microsoft(r) SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] !DSPAM:4176578399142061846259!
RE: filter config cause startup crash on Tomcat 5
Got it! Stupid error. thanks From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Wed, 20 Oct 2004 09:57:48 -0400 Have you changed it to url-pattern/sillyApe/*/url-pattern? BTW, post the error log. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 20, 2004 8:17 AM To: [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 the filter Tomcat no likie :) not sure what it is, any other suggestions. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:48:09 -0400 Try url-pattern /s.../* -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:31 PM To: [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 What order should it come in. Its near the top of the list. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:26:39 -0400 Check the order in web.xml. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:19 PM To: [EMAIL PROTECTED] Subject: filter config cause startup crash on Tomcat 5 I have created a DetectBrowser servlet to not allow certain browsers into the sillyApe directory/url. I wanted to use it as a filter rather then having to call it in each jsp since people can get to almost every page in the sillyApe directory without going through a single page, just thought it would be easier, as well as other issues. Anyway I am trying to figure out why I get a SEVERE: Error filterStart from Tomcat when I start it back up. HELP!!! filter filter-nameDetectBrowser/filter-name filter-classcom.dtribe.logic.DetectBrowser/filter-class /filter filter-mapping filter-nameDetectBrowser/filter-name url-pattern/sillyApe/url-pattern /filter-mapping HELP??? _ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034 S U=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Take advantage of powerful junk e-mail filters built on patented Microsoft(r) SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034S U=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Take advantage of powerful junk e-mail filters built on patented Microsoft(r) SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] !DSPAM:4176578399142061846259! _ Take charge with a pop-up guard built on patented Microsoft® SmartScreen Technology http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=http://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: filter config cause startup crash on Tomcat 5
Check the order in web.xml. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:19 PM To: [EMAIL PROTECTED] Subject: filter config cause startup crash on Tomcat 5 I have created a DetectBrowser servlet to not allow certain browsers into the sillyApe directory/url. I wanted to use it as a filter rather then having to call it in each jsp since people can get to almost every page in the sillyApe directory without going through a single page, just thought it would be easier, as well as other issues. Anyway I am trying to figure out why I get a SEVERE: Error filterStart from Tomcat when I start it back up. HELP!!! filter filter-nameDetectBrowser/filter-name filter-classcom.dtribe.logic.DetectBrowser/filter-class /filter filter-mapping filter-nameDetectBrowser/filter-name url-pattern/sillyApe/url-pattern /filter-mapping HELP??? _ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] !DSPAM:417576cc321718886279614!
RE: filter config cause startup crash on Tomcat 5
What order should it come in. Its near the top of the list. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:26:39 -0400 Check the order in web.xml. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:19 PM To: [EMAIL PROTECTED] Subject: filter config cause startup crash on Tomcat 5 I have created a DetectBrowser servlet to not allow certain browsers into the sillyApe directory/url. I wanted to use it as a filter rather then having to call it in each jsp since people can get to almost every page in the sillyApe directory without going through a single page, just thought it would be easier, as well as other issues. Anyway I am trying to figure out why I get a SEVERE: Error filterStart from Tomcat when I start it back up. HELP!!! filter filter-nameDetectBrowser/filter-name filter-classcom.dtribe.logic.DetectBrowser/filter-class /filter filter-mapping filter-nameDetectBrowser/filter-name url-pattern/sillyApe/url-pattern /filter-mapping HELP??? _ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] !DSPAM:417576cc321718886279614! _ Take advantage of powerful junk e-mail filters built on patented Microsoft® SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=http://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: filter config cause startup crash on Tomcat 5
Try url-pattern /s.../* -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:31 PM To: [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 What order should it come in. Its near the top of the list. From: Phillip Qin [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter config cause startup crash on Tomcat 5 Date: Tue, 19 Oct 2004 16:26:39 -0400 Check the order in web.xml. -Original Message- From: Didier McGillis [mailto:[EMAIL PROTECTED] Sent: October 19, 2004 4:19 PM To: [EMAIL PROTECTED] Subject: filter config cause startup crash on Tomcat 5 I have created a DetectBrowser servlet to not allow certain browsers into the sillyApe directory/url. I wanted to use it as a filter rather then having to call it in each jsp since people can get to almost every page in the sillyApe directory without going through a single page, just thought it would be easier, as well as other issues. Anyway I am trying to figure out why I get a SEVERE: Error filterStart from Tomcat when I start it back up. HELP!!! filter filter-nameDetectBrowser/filter-name filter-classcom.dtribe.logic.DetectBrowser/filter-class /filter filter-mapping filter-nameDetectBrowser/filter-name url-pattern/sillyApe/url-pattern /filter-mapping HELP??? _ Powerful Parental Controls Let your child discover the best the Internet has to offer. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034S U=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ Take advantage of powerful junk e-mail filters built on patented Microsoft(r) SmartScreen Technology. http://join.msn.com/?pgmarket=en-capage=byoa/premxAPID=1994DI=1034SU=htt p://hotmail.com/encaHL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN(r) Premium right now and get the first two months FREE*. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] !DSPAM:4175798a322115253112009!
Re: Filter on url example - Filter out hack attempts
Yoav, So from what I know so far my /usr/local/tomcat/webapps/myapplication/WEB-INF/web.xml should look like the following: web-app filter filter-nameUrlFilter/filter-name filter-classUrlFilter/filter-class *Don't know how this should layout.* /filter filter-mapping filter-nameUrlFilter/filter-name url-pattern/*/url-pattern /filter-mapping welcome-file-list welcome-fileindex.jsp/welcome-file welcome-fileindex.html/welcome-file /welcome-file-list /web-app Do I then create /usr/local/tomcat/webapps/myapplication/WEB-INF/classes/URLFilter.java? public class UrlFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { ...Send to Null // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever SubstringTest = False; SubstringTest = string.indexOf(GET / HTTP/1.1) 0; if(SubstringTest = True) return True; Do the same for the rest //GET / HTTP/1.0 //page1.jsp //page2.jsp //page3.jsp //page4.jsp //page5.jsp //graphic1.gif //graphic2.gif } } Thanks, Larry Nobs Hi, This is a trivial filter: public class URLFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever } } I omitted full prototype declarations above due to laziness. It's the javax.servlet.Filter interface. Take a look at the balancer webapp that ships with tomcat 5. The URLStringMatchRule is pretty close to what you want, and can be easily extended with a list of allow patterns and/or deny patterns. Tomcat has something similar as the base Valve for the RemoteAddr/RemoteHost valves. Yoav Shapira Millennium Research Informatics -Original Message- From: lrnobs [mailto:[EMAIL PROTECTED] Sent: Saturday, May 08, 2004 9:11 PM To: Tomcat Users List Subject: Filter on url example - Filter out hack attempts I have had no luck Googling so far for an example on how to filter based on urls. I thought I might put this in the AccessLogValve but will do whatever works. I have a limited number of jsp's and graphics on my site and would like to filter out all of the hack attempts that fill up my logs. I would like to do something like this (in plain english) Accept GET / HTTP/1.1 GET / HTTP/1.0 *page1.jsp* *page2.jsp* *page3.jsp* *page4.jsp* *page5.jsp* *graphic1.gif* *graphic2.gif* Drop All Other Requests - they are just hack attempts Thanks, Larry Nobs - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter on url example - Filter out hack attempts
First of this is not a Tomcat question. This type of information is always available at http://java.sun.com or http://forum.java.sun.com/ To answer your questionYes. in-fact you can place the class where ever you want as long as it is in your classpath. Of course you will also have to change the filter-class attribute accordingly. Nathan On May 11, 2004, at 7:42 AM, lrnobs wrote: Yoav, So from what I know so far my /usr/local/tomcat/webapps/myapplication/WEB-INF/web.xml should look like the following: web-app filter filter-nameUrlFilter/filter-name filter-classUrlFilter/filter-class *Don't know how this should layout.* /filter filter-mapping filter-nameUrlFilter/filter-name url-pattern/*/url-pattern /filter-mapping welcome-file-list welcome-fileindex.jsp/welcome-file welcome-fileindex.html/welcome-file /welcome-file-list /web-app Do I then create /usr/local/tomcat/webapps/myapplication/WEB-INF/classes/URLFilter.java? public class UrlFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { ...Send to Null // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever SubstringTest = False; SubstringTest = string.indexOf(GET / HTTP/1.1) 0; if(SubstringTest = True) return True; Do the same for the rest //GET / HTTP/1.0 //page1.jsp //page2.jsp //page3.jsp //page4.jsp //page5.jsp //graphic1.gif //graphic2.gif } } Thanks, Larry Nobs Hi, This is a trivial filter: public class URLFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever } } I omitted full prototype declarations above due to laziness. It's the javax.servlet.Filter interface. Take a look at the balancer webapp that ships with tomcat 5. The URLStringMatchRule is pretty close to what you want, and can be easily extended with a list of allow patterns and/or deny patterns. Tomcat has something similar as the base Valve for the RemoteAddr/RemoteHost valves. Yoav Shapira Millennium Research Informatics -Original Message- From: lrnobs [mailto:[EMAIL PROTECTED] Sent: Saturday, May 08, 2004 9:11 PM To: Tomcat Users List Subject: Filter on url example - Filter out hack attempts I have had no luck Googling so far for an example on how to filter based on urls. I thought I might put this in the AccessLogValve but will do whatever works. I have a limited number of jsp's and graphics on my site and would like to filter out all of the hack attempts that fill up my logs. I would like to do something like this (in plain english) Accept GET / HTTP/1.1 GET / HTTP/1.0 *page1.jsp* *page2.jsp* *page3.jsp* *page4.jsp* *page5.jsp* *graphic1.gif* *graphic2.gif* Drop All Other Requests - they are just hack attempts Thanks, Larry Nobs - 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] - 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 on url example - Filter out hack attempts
Hi, First of this is not a Tomcat question. This type of information is always available at http://java.sun.com or http://forum.java.sun.com/ Right, but we do encourage general servlet and JSP related discussions here too. So from what I know so far my /usr/local/tomcat/webapps/myapplication/WEB-INF/web.xml should look like the following: web-app filter filter-nameUrlFilter/filter-name filter-classUrlFilter/filter-class *Don't know how this should layout.* /filter filter-mapping filter-nameUrlFilter/filter-name url-pattern/*/url-pattern /filter-mapping That's fine. I'd suggest you put your UrlFilter in a package, e.g. com.yourclasses.UrlFilter, and change the filter-class accordingly. Do I then create /usr/local/tomcat/webapps/myapplication/WEB-INF/classes/URLFilter.java? Sure. For general help on the source and deployment organization of a webapp, see http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/index.html. private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever SubstringTest = False; SubstringTest = string.indexOf(GET / HTTP/1.1) 0; Make sure you understand what a request URI is for the HTTP protocol. It will have neither the GET (method name) nor the protocol spec (HTTP/1.1 above). Read and understand the JavaDocs for the HttpServletRequest interface completely. Yoav Shapira 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: Filter on url example - Filter out hack attempts
Nathan, I am a newbie to Java and Tomcat, and I did spend two days with two Tomcat books I bought and Google trying to find some instructions I could understand before posting a question to this list. Please let me know if there is a list more appropriate for new users. Thanks, Larry Nobs - Original Message - From: Nathan Maves [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, May 11, 2004 8:56 AM Subject: Re: Filter on url example - Filter out hack attempts First of this is not a Tomcat question. This type of information is always available at http://java.sun.com or http://forum.java.sun.com/ To answer your questionYes. in-fact you can place the class where ever you want as long as it is in your classpath. Of course you will also have to change the filter-class attribute accordingly. Nathan On May 11, 2004, at 7:42 AM, lrnobs wrote: Yoav, So from what I know so far my /usr/local/tomcat/webapps/myapplication/WEB-INF/web.xml should look like the following: web-app filter filter-nameUrlFilter/filter-name filter-classUrlFilter/filter-class *Don't know how this should layout.* /filter filter-mapping filter-nameUrlFilter/filter-name url-pattern/*/url-pattern /filter-mapping welcome-file-list welcome-fileindex.jsp/welcome-file welcome-fileindex.html/welcome-file /welcome-file-list /web-app Do I then create /usr/local/tomcat/webapps/myapplication/WEB-INF/classes/URLFilter.java? public class UrlFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { ...Send to Null // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever SubstringTest = False; SubstringTest = string.indexOf(GET / HTTP/1.1) 0; if(SubstringTest = True) return True; Do the same for the rest //GET / HTTP/1.0 //page1.jsp //page2.jsp //page3.jsp //page4.jsp //page5.jsp //graphic1.gif //graphic2.gif } } Thanks, Larry Nobs Hi, This is a trivial filter: public class URLFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever } } I omitted full prototype declarations above due to laziness. It's the javax.servlet.Filter interface. Take a look at the balancer webapp that ships with tomcat 5. The URLStringMatchRule is pretty close to what you want, and can be easily extended with a list of allow patterns and/or deny patterns. Tomcat has something similar as the base Valve for the RemoteAddr/RemoteHost valves. Yoav Shapira Millennium Research Informatics -Original Message- From: lrnobs [mailto:[EMAIL PROTECTED] Sent: Saturday, May 08, 2004 9:11 PM To: Tomcat Users List Subject: Filter on url example - Filter out hack attempts I have had no luck Googling so far for an example on how to filter based on urls. I thought I might put this in the AccessLogValve but will do whatever works. I have a limited number of jsp's and graphics on my site and would like to filter out all of the hack attempts that fill up my logs. I would like to do something like this (in plain english) Accept GET / HTTP/1.1 GET / HTTP/1.0 *page1.jsp* *page2.jsp* *page3.jsp* *page4.jsp* *page5.jsp* *graphic1.gif* *graphic2.gif* Drop All Other Requests - they are just hack attempts Thanks, Larry Nobs - 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
Re: Filter on url example - Filter out hack attempts
Hi Larry, as someone who has only been using tomcat (apart from the deploy tool) since August and who has had to greatly improve my Java skills since the same time... I suggest the best way to learn is to get your hands dirty, so to speak. Thoroughly read the provided Tomcat docs including any ReadMe files you can get your hands on. Get you hands on any example server.xml files that you can (there'll probably be some in your books and on the web). As for Java, find some good books to teach you Java and JSPs. I found Java a very steep learning curve at first. I have also found the following Java site very useful (and the book that goes with it): http://javagently.cs.up.ac.za/ and these pages: http://java.sun.com/j2se/1.3/docs/api/ I expect you'll find all the pages quoted by Nathan as being useful also. I've found the best way is to dive in and use them, preferably install Suns Java compiler and Tomcat onto a system somewhere where they can't do major harm if they go wrong (ie. not a server that's already in use!) and just have a go. I've had to do a lot of it on an up and running server but I don't advise this!! Anyway those are just some thoughts and suggestions that may or may not work for you. Hope it helps. Adam. On Tue, 2004-05-11 at 15:16, lrnobs wrote: Nathan, I am a newbie to Java and Tomcat, and I did spend two days with two Tomcat books I bought and Google trying to find some instructions I could understand before posting a question to this list. Please let me know if there is a list more appropriate for new users. Thanks, Larry Nobs - Original Message - From: Nathan Maves [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, May 11, 2004 8:56 AM Subject: Re: Filter on url example - Filter out hack attempts First of this is not a Tomcat question. This type of information is always available at http://java.sun.com or http://forum.java.sun.com/ To answer your questionYes. in-fact you can place the class where ever you want as long as it is in your classpath. Of course you will also have to change the filter-class attribute accordingly. Nathan On May 11, 2004, at 7:42 AM, lrnobs wrote: Yoav, So from what I know so far my /usr/local/tomcat/webapps/myapplication/WEB-INF/web.xml should look like the following: web-app filter filter-nameUrlFilter/filter-name filter-classUrlFilter/filter-class *Don't know how this should layout.* /filter filter-mapping filter-nameUrlFilter/filter-name url-pattern/*/url-pattern /filter-mapping welcome-file-list welcome-fileindex.jsp/welcome-file welcome-fileindex.html/welcome-file /welcome-file-list /web-app Do I then create /usr/local/tomcat/webapps/myapplication/WEB-INF/classes/URLFilter.java? public class UrlFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { ...Send to Null // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever SubstringTest = False; SubstringTest = string.indexOf(GET / HTTP/1.1) 0; if(SubstringTest = True) return True; Do the same for the rest //GET / HTTP/1.0 //page1.jsp //page2.jsp //page3.jsp //page4.jsp //page5.jsp //graphic1.gif //graphic2.gif } } Thanks, Larry Nobs Hi, This is a trivial filter: public class URLFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever } } I omitted full prototype declarations above due to laziness. It's the javax.servlet.Filter interface. Take a look at the balancer webapp that ships with tomcat 5. The URLStringMatchRule is pretty close to what you want, and can be easily extended with a list of allow patterns and/or deny patterns. Tomcat has something similar as the base Valve for the RemoteAddr/RemoteHost valves. Yoav Shapira
Re: Filter on url example - Filter out hack attempts
Yoav, Make sure you understand what a request URI is for the HTTP protocol. It will have neither the GET (method name) nor the protocol spec (HTTP/1.1 above). Read and understand the JavaDocs for the HttpServletRequest interface completely. I have been looking at the Access Logs daily. Anytime a legitimate user accesses my site everything is preceded with a GET or POST and a jsp or gif that I can recognize. Initially a session starts off with a plain GET / HTTP/1.1 or 1.0 so I should allow these, but all other legitimate usage mentions my files. It sounds like you are saying that there are other requests that are not in the access log? Thanks, Larry Nobs - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter on url example - Filter out hack attempts
Hi, I have been looking at the Access Logs daily. Anytime a legitimate user accesses my site everything is preceded with a GET or POST and a jsp or gif that I can recognize. Initially a session starts off with a plain GET / HTTP/1.1 or 1.0 so I should allow these, but all other legitimate usage mentions my files. It sounds like you are saying that there are other requests that are not in the access log? No, that's not what I'm saying. I'm saying you have a lot to learn with regards to the Servlet API. The information returned from the getRequestURI method in HttpServletRequest is not the same information that is logged in the access logs. (And for that matter, the latter is highly configurable whereas the former is strictly defined). So that's why I said you should read and understand the HttpServletRequest interface and its methods. Yoav Shapira 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: Filter on url example - Filter out hack attempts
Adam, Thanks for the additional links. I'm a twenty year IT professional and I feel like I am in kindergarden all over again. It is hard to make the switch from Microsoft products and not lose the house in the process. I've taken a Unix class and a Java class at the local community college, and have gotten some basic Samba servers going, after crawling through the documentation for hours. I appreciate any help I can get from this list. Larry Nobs - Original Message - From: Adam Buglass [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, May 11, 2004 9:30 AM Subject: Re: Filter on url example - Filter out hack attempts Hi Larry, as someone who has only been using tomcat (apart from the deploy tool) since August and who has had to greatly improve my Java skills since the same time... I suggest the best way to learn is to get your hands dirty, so to speak. Thoroughly read the provided Tomcat docs including any ReadMe files you can get your hands on. Get you hands on any example server.xml files that you can (there'll probably be some in your books and on the web). As for Java, find some good books to teach you Java and JSPs. I found Java a very steep learning curve at first. I have also found the following Java site very useful (and the book that goes with it): http://javagently.cs.up.ac.za/ and these pages: http://java.sun.com/j2se/1.3/docs/api/ I expect you'll find all the pages quoted by Nathan as being useful also. I've found the best way is to dive in and use them, preferably install Suns Java compiler and Tomcat onto a system somewhere where they can't do major harm if they go wrong (ie. not a server that's already in use!) and just have a go. I've had to do a lot of it on an up and running server but I don't advise this!! Anyway those are just some thoughts and suggestions that may or may not work for you. Hope it helps. Adam. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter on url example - Filter out hack attempts
It's not always easy easy to find the right list for a question. The opinions about what is right or wrong vary with the members of the list. (In my opinion your question is right in this list, although I can understand that others have different opinions in this case) I have seen questions that where more of topic than yours. http://forum.java.sun.com/ is not a bad idea as there you may ask questions about java, jsp, servlets and other things that are not drectly related with tomcat. -Original Message- From: lrnobs [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 11, 2004 4:17 PM To: Tomcat Users List Subject: Re: Filter on url example - Filter out hack attempts I am a newbie to Java and Tomcat, and I did spend two days with two Tomcat books I bought and Google trying to find some instructions I could understand before posting a question to this list. Please let me know if there is a list more appropriate for new users. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter on url example - Filter out hack attempts
Yoav, Ok, thank you. I appreciate all your help. Larry Nobs - Original Message - From: Shapira, Yoav [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Tuesday, May 11, 2004 9:37 AM Subject: RE: Filter on url example - Filter out hack attempts Hi, I have been looking at the Access Logs daily. Anytime a legitimate user accesses my site everything is preceded with a GET or POST and a jsp or gif that I can recognize. Initially a session starts off with a plain GET / HTTP/1.1 or 1.0 so I should allow these, but all other legitimate usage mentions my files. It sounds like you are saying that there are other requests that are not in the access log? No, that's not what I'm saying. I'm saying you have a lot to learn with regards to the Servlet API. The information returned from the getRequestURI method in HttpServletRequest is not the same information that is logged in the access logs. (And for that matter, the latter is highly configurable whereas the former is strictly defined). So that's why I said you should read and understand the HttpServletRequest interface and its methods. Yoav Shapira 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter on url example - Filter out hack attempts
True every alias is subject to the occasional OT question. I think for the most part people are not aware of other areas where information is available. my $.02 On May 11, 2004, at 8:55 AM, Ralph Einfeldt wrote: It's not always easy easy to find the right list for a question. The opinions about what is right or wrong vary with the members of the list. (In my opinion your question is right in this list, although I can understand that others have different opinions in this case) I have seen questions that where more of topic than yours. http://forum.java.sun.com/ is not a bad idea as there you may ask questions about java, jsp, servlets and other things that are not drectly related with tomcat. -Original Message- From: lrnobs [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 11, 2004 4:17 PM To: Tomcat Users List Subject: Re: Filter on url example - Filter out hack attempts I am a newbie to Java and Tomcat, and I did spend two days with two Tomcat books I bought and Google trying to find some instructions I could understand before posting a question to this list. Please let me know if there is a list more appropriate for new users. - 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 on url example - Filter out hack attempts
Hi, This is a trivial filter: public class URLFilter implements Filter { ... public void doFilter(...) { if(req instance of HttpServletRequest) { HttpServletRequest hreq = (HttpServletRequest) req; String uri = hreq.getRequestURI(); if(allow(uri)){ chain.doFilter(req, res); } else { // Do whatever: error page, redirect, etc. } } else { // Non-HTTP requests chain.doFilter(req, res); } } private boolean allow(String uri) { // Look up allowed urls in a DB, Collection, whatever } } I omitted full prototype declarations above due to laziness. It's the javax.servlet.Filter interface. Take a look at the balancer webapp that ships with tomcat 5. The URLStringMatchRule is pretty close to what you want, and can be easily extended with a list of allow patterns and/or deny patterns. Tomcat has something similar as the base Valve for the RemoteAddr/RemoteHost valves. Yoav Shapira Millennium Research Informatics -Original Message- From: lrnobs [mailto:[EMAIL PROTECTED] Sent: Saturday, May 08, 2004 9:11 PM To: Tomcat Users List Subject: Filter on url example - Filter out hack attempts I have had no luck Googling so far for an example on how to filter based on urls. I thought I might put this in the AccessLogValve but will do whatever works. I have a limited number of jsp's and graphics on my site and would like to filter out all of the hack attempts that fill up my logs. I would like to do something like this (in plain english) Accept GET / HTTP/1.1 GET / HTTP/1.0 *page1.jsp* *page2.jsp* *page3.jsp* *page4.jsp* *page5.jsp* *graphic1.gif* *graphic2.gif* Drop All Other Requests - they are just hack attempts Thanks, Larry Nobs - 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: Filter chain
Hi, Is it possible to specify the sequence of filters being processed by the container? I have a checksession filter that throws a user object into the session and a second filter will gather statistics on requestsI want the checksession filter to be processed first The Servlet Spec is your friend. From SRC.6.2.4: The order the container uses in building the chain of filters to be applied for a particular request URI is as follows: 1. First, the url-pattern matching filter mappings in the same order that these elements appear in the deployment descriptor. 2. Next, the servlet-name matching filter mappings in the same order that these elements appear in the deployment descriptor. There is more in that section if you're interested. Yoav Shapira 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: Filter chain
Thanx, I must have over looked it ;) -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Friday, March 12, 2004 10:44 AM To: Tomcat Users List Subject: RE: Filter chain Hi, Is it possible to specify the sequence of filters being processed by the container? I have a checksession filter that throws a user object into the session and a second filter will gather statistics on requestsI want the checksession filter to be processed first The Servlet Spec is your friend. From SRC.6.2.4: The order the container uses in building the chain of filters to be applied for a particular request URI is as follows: 1. First, the url-pattern matching filter mappings in the same order that these elements appear in the deployment descriptor. 2. Next, the servlet-name matching filter mappings in the same order that these elements appear in the deployment descriptor. There is more in that section if you're interested. Yoav Shapira 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter causing memory on TC-5.0.18 and 5.0.19
Hi, We also are experiencing memory leaks in tomcat since we upgraded from 5.0.16 to 5.0.19. In particular I found out that web app sessions will not timeout with session-timeout=1 (or rather it will, but not after 1 minute): session-config session-timeout1/session-timeout /session-config using StandardManager. Does 5.0.19 honor session-timeout parameter at all? The output of /manager/sessions?path=/testcontext is: - OK - Session information for application at context path /testcontext Default maximum session inactive interval 1 minutes 60 - 70 minutes:2 sessions - Regards, Vlad Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, March 08, 2004 1:53 PM To: Tomcat Users List Subject: RE: Filter causing memory on TC-5.0.18 and 5.0.19 Hi, We search hard in the archive and found many, many questions in regards of this. Can you please point out specific messages or threads in the archives that ask about a filter causing a tomcat memory leak? Yoav Shapira 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] The information contained in this email message may be confidential. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. Although this message and any attachments are believed to be free of viruses, no responsibility is accepted by Informa for any loss or damage arising in any way from receipt or use thereof. Messages to and from the company are monitored for operational reasons and in accordance with lawful business practices. If you have received this message in error, please notify us by return and delete the message and any attachments. Further enquiries/returns can be sent to [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter causing memory on TC-5.0.18 and 5.0.19
Hi, We also are experiencing memory leaks in tomcat since we upgraded from 5.0.16 to 5.0.19. In particular I found out that web app sessions will not timeout with session-timeout=1 (or rather it will, but not after 1 minute): What is it recently with people hijacking threads? Please use a separate thread for the session timeout question, this one is about filters. Yoav Shapira 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: Filter causing memory on TC-5.0.18 and 5.0.19
Sorry about that. I was thinking that those issues are related. -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Monday, March 08, 2004 3:54 PM To: Tomcat Users List Subject: RE: Filter causing memory on TC-5.0.18 and 5.0.19 Hi, We also are experiencing memory leaks in tomcat since we upgraded from 5.0.16 to 5.0.19. In particular I found out that web app sessions will not timeout with session-timeout=1 (or rather it will, but not after 1 minute): What is it recently with people hijacking threads? Please use a separate thread for the session timeout question, this one is about filters. Yoav Shapira 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] The information contained in this email message may be confidential. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. Although this message and any attachments are believed to be free of viruses, no responsibility is accepted by Informa for any loss or damage arising in any way from receipt or use thereof. Messages to and from the company are monitored for operational reasons and in accordance with lawful business practices. If you have received this message in error, please notify us by return and delete the message and any attachments. Further enquiries/returns can be sent to [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter causing memory on TC-5.0.18 and 5.0.19
Hi, We search hard in the archive and found many, many questions in regards of this. Can you please point out specific messages or threads in the archives that ask about a filter causing a tomcat memory leak? Yoav Shapira 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: Filter mapping problem under Solaris 9
(Ooops, newbie problems sending mail - apologies to Yoav! ) Now I am really confused. I also have the same problem under Linux ( White Hat Enterprise - not sure of version number.. ) This raises the obvious question of 'am I setting the url-pattern correctly?' I would assume that it would be possible to set a pattern that narrows the field more than simply a plain wildcard '/*' ... is this right? As I said, it works fine on Widnows 2k ... As a simple and reproducable example, I am using the supplied 'NtlmHttpAuthExample' servlet with jCifs0.8.0. Under Unix, if I set a filter mapping that is specific, I can't get the expected parameters from the request object, but under Widnows I do. Very odd. Has anyone played with non-wildcard filter mappings? At the moment, I am about to split out a couple of apps into two separate contexts to handle restricted and public rather than just filter appropriate elements... My final test will be to use a completely cleanly built server ( ours have ssh, etc ) and test the pattern matching with a new dummy class on that, but that won't be today. Anyone got any ideas? Cheers Dave -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Thursday, February 19, 2004 1:44 PM To: Tomcat Users List Subject: RE: Filter mapping problem under Solaris 9 Howdy, Hmm, strange ;(. Are these parameters/your form using standard encoding or a different charset? Yoav Shapira Millennium ChemInformatics -Original Message- From: Boland, Dave [mailto:[EMAIL PROTECTED] Sent: Thursday, February 19, 2004 7:15 AM To: '[EMAIL PROTECTED]' Subject: Filter mapping problem under Solaris 9 Hello All, Apologies if this has been brought up already, but I have a slightly odd problem with filter-mapping in Tomcat 4.1.x ( I've tried under 4.1.24 and 4.1.29 ), which works fine under Windows 2K. I am using j2se 1.4.1_03 and have tried j2se1.4.2_03 ( with 64 bit extension ) with j2ee 1.3.1 running under a vanilla Solaris 9 instance on a Sun Netra T1. I can replicate the problem with a clean install of all products and the only thing that I haven't been able to change is the OS. The problem concerns getting parameters from the request object after a filter has been applied. Under Win2K it is possible to specify a URL mapping of '/main.jsp' for example so that only certain files have filters applied ( I am using the jCIFs to authenticate certain files, but I have proved the problem with custom/dummy classes ). The problem occurs in Solaris when a filter mapping is specified and the url does not fit the pattern. Under these circumstaces, I am then unable to get the information from the request object if the parameters are passed by a form. Parameters enbedded in the URL are fine, but form params are not available ( not sure of the state of the request object as a whole - when I have some spare time !! I'll check ). Most people / examples that I have come across when googling use a url-pattern of /* and this is fine as everything is pattern matched ok. And as I said, under Windows, there is no problem in specifiying specific urls / patterns for it to match, just Solaris is the problem ( I'm trying to scrounge a Linux box to try, but that is just problem narrowing as we don't have any Linux webservers... ) Cheers Dave The contents of this email and any attachments are sent for the personal attention of the addressee(s) only and may be confidential. If you are not the intended addressee, any use, disclosure or copying of this email and any attachments is unauthorised - please notify the sender by return and delete the message. Any representations or commitments expressed in this email are subject to contract. ntl Group Limited - 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. The contents of this email and any attachments are sent for the personal attention of the addressee(s) only and may be confidential. If you are not the intended addressee, any use, disclosure or copying of this email and any attachments is unauthorised - please notify the sender by return and delete the message. Any representations or commitments expressed in this email are subject to contract. ntl Group Limited - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter mapping problem under Solaris 9
Howdy, Now I am really confused. I also have the same problem under Linux ( White Hat Enterprise - not sure of version number.. ) This is good, in that it's more consistent. This raises the obvious question of 'am I setting the url-pattern correctly?' I would assume that it would be possible to set a pattern that narrows the field more than simply a plain wildcard '/*' ... is this right? As I said, it works fine on Widnows 2k ... Yes, it's possible to set the filter-mapping url-pattern to something more complex than /* ;) See the Servlet Specification SRV.11 for the exact specification. I personally have used /*, /foo/*, *.do (the classic Struts mapping), and specific servlet-name mappings instead of url-pattern, for filters successfully with tomcat 5.x. As a simple and reproducable example, I am using the supplied 'NtlmHttpAuthExample' servlet with jCifs0.8.0. Under Unix, if I set a filter mapping that is specific, I can't get the expected parameters from the request object, but under Widnows I do. Very odd. As a sidenote, NtlmHttpAuth is NOT a simple example. Pick or write something very trivial. Someone was complaining earlier about a bug with POST request parameters when using NtlmHttpAuth. Yoav Shapira 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: Filter mapping problem under Solaris 9
Sitting here mildly red-faced. Yes, you are right - the problem is narrowing down to be a problem with the jCIFS code. I have just finished testing using a couple of Linux and a Solaris box, and I am coming round to the conclusion that there is something awry with the NtlmAuth code. Using the example RequestDumperFilter and a couple of files, the pattern matching _is_ ok after all ... so I am interested in the reported problem with POSTing. I'll have a dig around the archives and see if I can find anything out. Cheers for the help! Dave -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Friday, February 20, 2004 1:53 PM To: Tomcat Users List Subject: RE: Filter mapping problem under Solaris 9 Howdy, Now I am really confused. I also have the same problem under Linux ( White Hat Enterprise - not sure of version number.. ) This is good, in that it's more consistent. This raises the obvious question of 'am I setting the url-pattern correctly?' I would assume that it would be possible to set a pattern that narrows the field more than simply a plain wildcard '/*' ... is this right? As I said, it works fine on Widnows 2k ... Yes, it's possible to set the filter-mapping url-pattern to something more complex than /* ;) See the Servlet Specification SRV.11 for the exact specification. I personally have used /*, /foo/*, *.do (the classic Struts mapping), and specific servlet-name mappings instead of url-pattern, for filters successfully with tomcat 5.x. As a simple and reproducable example, I am using the supplied 'NtlmHttpAuthExample' servlet with jCifs0.8.0. Under Unix, if I set a filter mapping that is specific, I can't get the expected parameters from the request object, but under Widnows I do. Very odd. As a sidenote, NtlmHttpAuth is NOT a simple example. Pick or write something very trivial. Someone was complaining earlier about a bug with POST request parameters when using NtlmHttpAuth. Yoav Shapira 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. The contents of this email and any attachments are sent for the personal attention of the addressee(s) only and may be confidential. If you are not the intended addressee, any use, disclosure or copying of this email and any attachments is unauthorised - please notify the sender by return and delete the message. Any representations or commitments expressed in this email are subject to contract. ntl Group Limited - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter mapping problem under Solaris 9
Howdy, Using the example RequestDumperFilter and a couple of files, the pattern matching _is_ ok after all ... so I am interested in the reported problem with POSTing. I'll have a dig around the archives and see if I can find anything out. Good, glad to hear that. The thread I had in mind was http://marc.theaimsgroup.com/?l=tomcat-userm=107660839928798w=2 but I'm not sure how directly relevant it is to you. Yoav Shapira 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: Filter mapping problem under Solaris 9
Howdy, Hmm, strange ;(. Are these parameters/your form using standard encoding or a different charset? Yoav Shapira Millennium ChemInformatics -Original Message- From: Boland, Dave [mailto:[EMAIL PROTECTED] Sent: Thursday, February 19, 2004 7:15 AM To: '[EMAIL PROTECTED]' Subject: Filter mapping problem under Solaris 9 Hello All, Apologies if this has been brought up already, but I have a slightly odd problem with filter-mapping in Tomcat 4.1.x ( I've tried under 4.1.24 and 4.1.29 ), which works fine under Windows 2K. I am using j2se 1.4.1_03 and have tried j2se1.4.2_03 ( with 64 bit extension ) with j2ee 1.3.1 running under a vanilla Solaris 9 instance on a Sun Netra T1. I can replicate the problem with a clean install of all products and the only thing that I haven't been able to change is the OS. The problem concerns getting parameters from the request object after a filter has been applied. Under Win2K it is possible to specify a URL mapping of '/main.jsp' for example so that only certain files have filters applied ( I am using the jCIFs to authenticate certain files, but I have proved the problem with custom/dummy classes ). The problem occurs in Solaris when a filter mapping is specified and the url does not fit the pattern. Under these circumstaces, I am then unable to get the information from the request object if the parameters are passed by a form. Parameters enbedded in the URL are fine, but form params are not available ( not sure of the state of the request object as a whole - when I have some spare time !! I'll check ). Most people / examples that I have come across when googling use a url-pattern of /* and this is fine as everything is pattern matched ok. And as I said, under Windows, there is no problem in specifiying specific urls / patterns for it to match, just Solaris is the problem ( I'm trying to scrounge a Linux box to try, but that is just problem narrowing as we don't have any Linux webservers... ) Cheers Dave The contents of this email and any attachments are sent for the personal attention of the addressee(s) only and may be confidential. If you are not the intended addressee, any use, disclosure or copying of this email and any attachments is unauthorised - please notify the sender by return and delete the message. Any representations or commitments expressed in this email are subject to contract. ntl Group Limited - 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: Filter to detect a user not logged in
Merrill Cornish [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I'm trying to learn filters by writing one to detect when someone who has not logged in tries to access a JSP page that requires login. From what I've read, this seems to be one common use of filters. I think I understand how to write the filter, but to determine whether the session had been logged in, I need to HttpSession object. The doFilter() method receives ServletRequest rather than HttpServletRequest, so there is no getSession() method. At the same time, since the filter is tied to ServletRequest and ServletResponse, it appears that the filter runs at a level above individual sessions, implying that a filter could never check whether a specific session was logged in. Well, something like: HttpServletRequest hreq; if(request instanceof HttpServletRequest) { // always true for Tomcat hreq = (HttpServletRequest)request; } Can filters be used to check whether a user is logged in? Merrill - 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: Filter for Form Authentication Problem
That bugzilla issue only addresses filters, not character encoding, with j_security_check. On the one hand the servlet 2.4 spec actually addresses response character encoding issues nicely, with the addition of stuff like: locale-encoding-mapping-list locale-encoding-mapping localeja/locale encodingShift_JIS/encoding /locale-encoding-mapping /locale-encoding-mapping-list to the web.xml . It would be a shame if the solution doesn't extend to the request encoding as well, i.e. so that the tomcat SetCharacterEncodingFilter class becomes redundant, but at this point I haven't got to the point where I can tell. I guess the tomcat committers would know :) I only upgraded to tomcat 5 on Sunday and I'm still trying to get back to the stage where I was with tomcat 4. Do you know when the 2.4 spec goes final? Adam On 09/30/2003 12:58 PM Tim Funk wrote: Did that alrady. Here's the gory details and the conclusion is valid for 4 and 5. It seems the spec folks took care of the character encoding issue but forgot how to fix it for j_security_check. So the short term solution is probably a custom solution per platform. :( (Maybe google has the answer, haven't checked yet) http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21795 -Tim Bill Barker wrote: This is a really interesting issue. I would hope that you would send a message to [EMAIL PROTECTED] to hopefully get the expert-team to clarify this before the 2.4 spec goes final. Because the Servlet-2.2 spec lacks the request.setCharacterEncoding method, Tomcat 3.3 jumps through a lot of hoops to try and guess the charset. These were dropped in Tomcat 4+, since the request.setCharacterEncoding method was supposed to solve all of these problems. As you have pointed out, it is not possible to use this in a Filter for the standard Form-auth config (for the simple reason that Auth is called before Filters). Therefore, the j_security_check target is flying blind wrt charset. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- struts 1.1 + tomcat 5.0.12 + java 1.4.2 Linux 2.4.20 RH9 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter for Form Authentication Problem
See the tomcat-dev list archives, there are conversations about that now. (or the last day or 2) -Tim Adam Hardy wrote: Do you know when the 2.4 spec goes final? Adam - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter for Form Authentication Problem
Joerg Heinicke [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Tim Funk wrote: You can't intercept j_security_check with a filter, it violates the spec. -Tim This is at least one answer to my thread started last week: http://www.mail-archive.com/[EMAIL PROTECTED]/msg104931.html. What are the consequences/possibilities to set the request character encoding with servlet standard API mechanisms instead of using the Tomcat proprietary solution of using a Valve? This is a really interesting issue. I would hope that you would send a message to [EMAIL PROTECTED] to hopefully get the expert-team to clarify this before the 2.4 spec goes final. Because the Servlet-2.2 spec lacks the request.setCharacterEncoding method, Tomcat 3.3 jumps through a lot of hoops to try and guess the charset. These were dropped in Tomcat 4+, since the request.setCharacterEncoding method was supposed to solve all of these problems. As you have pointed out, it is not possible to use this in a Filter for the standard Form-auth config (for the simple reason that Auth is called before Filters). Therefore, the j_security_check target is flying blind wrt charset. Joerg Lawence wrote: Dear All, I wrote a filter servlet that does some preprocessing. Basically it intercepts the call of j_secuity_check. The problem is that most of the time it was just bypassed. The only way to trigger it as I found is to first fill the form and got authenticated, then go back and try the authentication again. Anybody knows the solution? Another question is how to sepcify the url pattern of j_security_check. My login page is /secured/login.jsp, I think the url should be /secured/j_security_check, am I right? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter for Form Authentication Problem
Did that alrady. Here's the gory details and the conclusion is valid for 4 and 5. It seems the spec folks took care of the character encoding issue but forgot how to fix it for j_security_check. So the short term solution is probably a custom solution per platform. :( (Maybe google has the answer, haven't checked yet) http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21795 -Tim Bill Barker wrote: This is a really interesting issue. I would hope that you would send a message to [EMAIL PROTECTED] to hopefully get the expert-team to clarify this before the 2.4 spec goes final. Because the Servlet-2.2 spec lacks the request.setCharacterEncoding method, Tomcat 3.3 jumps through a lot of hoops to try and guess the charset. These were dropped in Tomcat 4+, since the request.setCharacterEncoding method was supposed to solve all of these problems. As you have pointed out, it is not possible to use this in a Filter for the standard Form-auth config (for the simple reason that Auth is called before Filters). Therefore, the j_security_check target is flying blind wrt charset. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter for Form Authentication Problem
Thanks for the replies. So this means I have to go with custom realm and authenticator? Actually I first tried with them but got stuck, I guess I was quite close to success though. I posted one article asking for help several days ago but got no response at all. I am reposting it below, hopefully sb. would kindly point me a way out. === Dear all, I wrote my own authenticator (extends FormAuthenticator) realm (extends JDBCRealm). What I need is to check one more field in the database besides password for authentication. Only minor modifications are made on the original codes so I think it should be fine. What I also did include changing the org/apache/catalina/startup/Authenticators.properties file to add the new authenticator; modifying the server.xml and web.xml accordingly. Furthermore, I added the entries for my authenticator and realm in the mbeans-descriptor.xml file. I expected everything to work perfectly but when I tried to access the secured area, I got the following error: HTTP Status 500 - Configuration error: Cannot perform access control without an authenticated principal - type Status report message Configuration error: Cannot perform access control without an authenticated principal description The server encountered an internal error (Configuration error: Cannot perform access control without an authenticated principal) that prevented it from fulfilling this request. This error was triggered instantly. I mean I even did not have a chance to see the login webpage. Now I have several questions: What is the flow of the authentication? Was my authenticator got executed at all? Any suggestions would be greatly appreciated. Bill Barker [EMAIL PROTECTED] wrote: Joerg Heinicke wrote in message news:[EMAIL PROTECTED] Tim Funk wrote: You can't intercept j_security_check with a filter, it violates the spec. -Tim This is at least one answer to my thread started last week: http://www.mail-archive.com/[EMAIL PROTECTED]/msg104931.html. What are the consequences/possibilities to set the request character encoding with servlet standard API mechanisms instead of using the Tomcat proprietary solution of using a Valve? This is a really interesting issue. I would hope that you would send a message to [EMAIL PROTECTED] to hopefully get the expert-team to clarify this before the 2.4 spec goes final. Because the Servlet-2.2 spec lacks the request.setCharacterEncoding method, Tomcat 3.3 jumps through a lot of hoops to try and guess the charset. These were dropped in Tomcat 4+, since the request.setCharacterEncoding method was supposed to solve all of these problems. As you have pointed out, it is not possible to use this in a Filter for the standard Form-auth config (for the simple reason that Auth is called before Filters). Therefore, the j_security_check target is flying blind wrt charset. Joerg Lawence wrote: Dear All, I wrote a filter servlet that does some preprocessing. Basically it intercepts the call of j_secuity_check. The problem is that most of the time it was just bypassed. The only way to trigger it as I found is to first fill the form and got authenticated, then go back and try the authentication again. Anybody knows the solution? Another question is how to sepcify the url pattern of j_security_check. My login page is /secured/login.jsp, I think the url should be /secured/j_security_check, am I right? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Do you Yahoo!? The New Yahoo! Shopping - with improved product search
Re: Filter for Form Authentication Problem
You can't intercept j_security_check with a filter, it violates the spec. -Tim Lawence wrote: Dear All, I wrote a filter servlet that does some preprocessing. Basically it intercepts the call of j_secuity_check. The problem is that most of the time it was just bypassed. The only way to trigger it as I found is to first fill the form and got authenticated, then go back and try the authentication again. Anybody knows the solution? Another question is how to sepcify the url pattern of j_security_check. My login page is /secured/login.jsp, I think the url should be /secured/j_security_check, am I right? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter for Form Authentication Problem
Tim Funk wrote: You can't intercept j_security_check with a filter, it violates the spec. -Tim This is at least one answer to my thread started last week: http://www.mail-archive.com/[EMAIL PROTECTED]/msg104931.html. What are the consequences/possibilities to set the request character encoding with servlet standard API mechanisms instead of using the Tomcat proprietary solution of using a Valve? Joerg Lawence wrote: Dear All, I wrote a filter servlet that does some preprocessing. Basically it intercepts the call of j_secuity_check. The problem is that most of the time it was just bypassed. The only way to trigger it as I found is to first fill the form and got authenticated, then go back and try the authentication again. Anybody knows the solution? Another question is how to sepcify the url pattern of j_security_check. My login page is /secured/login.jsp, I think the url should be /secured/j_security_check, am I right? Thanks in advance. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter for Form Authentication Problem
Honestly, I personally have no clue with respect to encoding issues. I will be playing with UTF-8 soon but ala, I am stuck in ISO8859-1 for now. But my gut feel is container authentication implementation is purely container dependent. So you'll be stuck with tomcat, or weblogic, or ???. Hopefully, the dependency will be very simple and lightweight to ease the portability issue. If you have a lot of time to waste, I think there and many resolved issues in bugzilla with some probably interesting conversations. Hopefully someone else is lurking and has more insight. -Tim Joerg Heinicke wrote: Tim Funk wrote: You can't intercept j_security_check with a filter, it violates the spec. -Tim This is at least one answer to my thread started last week: http://www.mail-archive.com/[EMAIL PROTECTED]/msg104931.html. What are the consequences/possibilities to set the request character encoding with servlet standard API mechanisms instead of using the Tomcat proprietary solution of using a Valve? Joerg - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter and servlet mapping problem
By the time it has gotten to your Filter, Tomcat has already decided on which Servlet will serve the request (and it is too late to change it's mind :). You need to do something like: String oldURI = unWritePath(request.getServletPath()+request.getPathInfo()); RequestDispatcher rd = getServletContext().getRequestDispacher(oldURI); rd.forward(request, response); return; Mailing Listen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I have written a filter for my webapp where i catch the response and Rewrite all URLs with a timestamp for bypassing some proxies that ignore The settings i set on my webserver (e.g. no-cache, no-store,...). The Filter works fine, but i haveto modify the requests when the reache my webserver. I am able to do this, but this only works if i the servlets i access are mapped in the web.xml of tomcat in the conf directory. The servlets that are mapped within the web.xmnl in the current context are not found. For explaining my problem a little more here an example: I have a URL like /myjsp.jsp I rewrite ist with /myjsp_timstamp_in_millis.jsp (timstamp_in_millis is the current timestamp) I filter this to /myjsp.jsp if the user requests the rewritten URL For .jsps that are mapped in the conf/web.xml file (by the default jsp servlet) anything works But i have some more servlet and some special jsp mappings that are mapped within the context and here i recieve an 404 although the servlet pathe and the URI are set correctly. Any advice is welcome Burkard Endres - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter and servlet mapping problem
Maybe you could try rewriting your URL as /myjsp.jsp?time=timestamp_in_millis instead of /myjsp_timestamp_in_millis.jsp -Original Message- From: Mailing Listen [mailto:[EMAIL PROTECTED] Sent: 28 July 2003 11:16 To: Tomcat Users List Subject: Filter and servlet mapping problem I have written a filter for my webapp where i catch the response and Rewrite all URLs with a timestamp for bypassing some proxies that ignore The settings i set on my webserver (e.g. no-cache, no-store,...). The Filter works fine, but i haveto modify the requests when the reache my webserver. I am able to do this, but this only works if i the servlets i access are mapped in the web.xml of tomcat in the conf directory. The servlets that are mapped within the web.xmnl in the current context are not found. For explaining my problem a little more here an example: I have a URL like /myjsp.jsp I rewrite ist with /myjsp_timstamp_in_millis.jsp (timstamp_in_millis is the current timestamp) I filter this to /myjsp.jsp if the user requests the rewritten URL For .jsps that are mapped in the conf/web.xml file (by the default jsp servlet) anything works But i have some more servlet and some special jsp mappings that are mapped within the context and here i recieve an 404 although the servlet pathe and the URI are set correctly. Any advice is welcome Burkard Endres - 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 and servlet mapping problem
Howdy, Taking the Filter out of the equation, can you find and use the servlets in your context? Yoav Shapira Millennium ChemInformatics -Original Message- From: Mailing Listen [mailto:[EMAIL PROTECTED] Sent: Monday, July 28, 2003 8:19 AM To: [EMAIL PROTECTED] Subject: Filter and servlet mapping problem I have written a filter for my webapp where i catch the response and Rewrite all URLs with a timestamp for bypassing some proxies that ignore The settings i set on my webserver (e.g. no-cache, no-store,...). The Filter works fine, but i haveto modify the requests when the reache my webserver. I am able to do this, but this only works if i the servlets i access are mapped in the web.xml of tomcat in the conf directory. The servlets that are mapped within the web.xmnl in the current context are not found. For explaining my problem a little more here an example: I have a URL like /myjsp.jsp I rewrite ist with /myjsp_timstamp_in_millis.jsp (timstamp_in_millis is the current timestamp) I filter this to /myjsp.jsp if the user requests the rewritten URL For .jsps that are mapped in the conf/web.xml file (by the default jsp servlet) anything works But i have some more servlet and some special jsp mappings that are mapped within the context and here i recieve an 404 although the servlet pathe and the URI are set correctly. Any advice is welcome Burkard Endres 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: Filter out certain user accounts
You should be able to cast ServletRequest to HttpServletRequest. Then you'll have access to getUserPrincipal() -Tim Dan Tran wrote: Hello, I would like the build filter to check for a site maintainant flag set in application context and disallow certain user to passthruand route them to another page. The problem here, the interface doFilter's ServletRequest does not have access to getUserPrincipal, so I have no way to find out the actual user. Any work around? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter out certain user accounts
supper!!! Thanks - Original Message - From: Tim Funk [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Sunday, June 01, 2003 5:35 PM Subject: Re: Filter out certain user accounts You should be able to cast ServletRequest to HttpServletRequest. Then you'll have access to getUserPrincipal() -Tim Dan Tran wrote: Hello, I would like the build filter to check for a site maintainant flag set in application context and disallow certain user to passthruand route them to another page. The problem here, the interface doFilter's ServletRequest does not have access to getUserPrincipal, so I have no way to find out the actual user. Any work around? - 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 setup problem
Nevermind I found it. Stupidness strikes again. --mikej -Original Message- From: mike jackson [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2003 10:24 AM To: 'Tomcat Users List' Subject: Filter setup problem I'm having a problem with the initial parameter options with filters. My setup is as follows: I've got a filter that I wrote SecurityFilter. I setup the web.xml file to contain: filter filter-nameSecurityFilter/filter-name filter-class com.cdi.security.http.filters.SecurityFilter /filter-class init-param param-namesecurity_bundle/param-name param-valueapplication/param-value /init-param /filter Everything looks ok at this point, no problems parsing anything on startup. Ok, in my filter code I've got the following (in the init method): String bundleName = application; try { bundleName = filterConfig.getInitParameter( BUNDLE_PARAMETER ); } catch( Exception e ) { Log.log( Log.WARNING, this, init(), Exception: + e ); } Where BUNDLE_PARAMETER is set to security_bundle. Again this all see right, at least I don't see any errors. However when I go to init I get a null pointer exception on the attempt to retrieve the init-parameter. I've run it through my debugger and it'd definitely occurring in this try/catch block, but I don't have a clue why. Does anyone have any idea why? --mikej -=- mike jackson [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: Filter - ServletContext
Try: sctx.getInitParameter(...) instead of sctx.getAttribute(...) Günter Kukies wrote: Hello, I want to read some context-param from web.xml within a filter. But the getAttribute is always null. There is no problem to get the same context-param within a Servlet. Thanks Günter Here is the code snippet: import java.io.*; import java.net.*; import java.util.*; import java.text.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import javax.sql.*; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.naming.*; public class MyFilter implements Filter { // The filter configuration object we are associated with. If // this value is null, this filter instance is not currently // configured. private FilterConfig filterConfig = null; String category_server_ip = ; int category_server_port = 8080; String category_root = ; String category_base = ; /** * Init method for this filter * */ public void init(FilterConfig filterConfig) { this.filterConfig = filterConfig; ServletContext sctx = filterConfig.getServletContext(); sctx.getServletContextName(); category_server_ip = (String)sctx.getAttribute(category_server_ip); category_server_port = stringToInt((String)sctx.getAttribute(category_server_port)); category_root = (String)sctx.getAttribute(category_root); category_base = (String)sctx.getAttribute(category_base); if (filterConfig != null) { if (debug) { log(MyFilter :Initializing filter); } } } public MyFilter () { } . - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter - ServletContext
Günter Kukies wrote: Hello, I want to read some context-param from web.xml within a filter. But the getAttribute is always null. There is no problem to get the same context-param within a Servlet. Don't you want getInitParameter() ? Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter - ServletContext
Oh, sorry getInitParameter() was the solution. Thanks for your hint. But why is the ServletContext not the same in Filter and HTTPServlet? Günter - Original Message - From: Erik Price [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Sent: Thursday, February 27, 2003 4:54 PM Subject: Re: Filter - ServletContext Günter Kukies wrote: Hello, I want to read some context-param from web.xml within a filter. But the getAttribute is always null. There is no problem to get the same context-param within a Servlet. Don't you want getInitParameter() ? Erik - 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 - ServletContext
Günter Kukies wrote: Oh, sorry getInitParameter() was the solution. Thanks for your hint. But why is the ServletContext not the same in Filter and HTTPServlet? I am confused. There is one ServletContext in a webapp (as far as I know, which isn't very far). You can access it from a Filter using getFilterConfig().getServletContext(), and you can access it from a HttpServlet using getServletContext(). It is the same. Erik - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter problems
On Sat, 8 Feb 2003, Manavendra Gupta wrote: Date: Sat, 8 Feb 2003 14:12:38 -0800 From: Manavendra Gupta [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Filter problems Hi, I have a simple security filter for authentication used for a custom MVC framework application. Everything works properly, however, if a large file is uploaded (about 17MB), I get the error listed below. As you can see the root cause is RTIFilter.java line 67. This line has the following code: next.doFilter(request, response); Any idea why that NullPointerException exception would occur? If the next variable were null when this statement was executed, you'd get an NPE. But, according to your stack trace, that is *not* where the NPE actually happened -- it's at line 172 of FrontController, in the doProcess() method. Thanks, Manav. Craig java.lang.NullPointerException at com.bsil.rti.controller.FrontController.doProcess(FrontController.java:172) at com.bsil.rti.controller.FrontController.doPost(FrontController.java:140) at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at com.bsil.rti.filter.RTIFilter.doFilter(RTIFilter.java:67) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:213) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172 ) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:641) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok eNext(StandardPipeline.java:643) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne ction(Http11Protocol.java:386) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:530) at java.lang.Thread.run(Thread.java:536) - 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 and RequestDispatcher.forward()
I have noticed that, too, while preparing a WebLogic web application to run on Tomcat. The code of ApplicationDispatcher says: strongIMPLEMENTATION NOTE/strong: This implementation assumes that no filters are applied to a forwarded or included resource, because they were already done for the original request. For authorization that might even be better, check it once as it comes from outside and if you pass you can go everywhere the current security police allows. I can imagine cases where it wouldn't work though - think about pre-/post-processing each request for whatever reason (your own proprietary security? to decorate each request? decompress in case not all resource has been compressed and you have to decide request by request?), regardless if included or forwarded. In my case I was able to change my code but it was not trivial :-( I think it should be at least controlled by parameters, nothing in the Servlet API v.2 spec leads to believe that it should work that way. Tomasz --- Tim Funk [EMAIL PROTECTED] schrieb: Filters are only run once for the incoming request. See the archives for more information. -Tim Karl Kraft wrote: I've written a Filter to get applied to all page requests so that I can perform some access control and logging. However, when a servlet redirects using the forward() method of RequestDispatcher, it doesn't seem to go through the filter. If needed, I can call the Filter manually before I do the forward(), but I'm wondering if there is a more preferred way to do this. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __ Gesendet von Yahoo! Mail - http://mail.yahoo.de Bis zu 100 MB Speicher bei http://premiummail.yahoo.de - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter: Reading the http response content
You must wrap the response in a HttpServletResponse wrapper then override the getOutputStream/Writer with your own methods which provide a proxy to the real getOutputStream/Writer. The wrapped object then goes to the next filter in the chain. In other words, a pain in the a$$. Before re-inventing this - look around to what other people already did. If you really want to do this - look at the various compression fitlers available and store in cache instead of compress. -Tim rf wrote: In my filter I want to cache the content of HttpServletResponse so that I can save that in a file and use a static file's servlet for the next request. However, I am not able find interface to get the (html)content from the response object. if (up2date) { RequestDispatcher rd = request.getServletDispatcher (static.html); rd.forward (request, response); } else { chain.doFilter (request, response); //***Then save the html response to static html } So any clues as to how to obtain the content of response. The HttpServletResponse has methods to get/set the HTTP headers and cookies, but does not have anything for the HTTP's body. It is also not possible to read from response.getOutputStream. What do you guys think? Thank you ~rf __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.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: Filter: Reading the http response content
Tim Funk wrote: You must wrap the response in a HttpServletResponse wrapper then override the getOutputStream/Writer with your own methods which provide a proxy to the real getOutputStream/Writer. The wrapped object then goes to the next filter in the chain. I think that what he is asking is how to extract the contents of the HttpServletRequest [so that they can be cached to the filesystem, etc]. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Filter: Reading the http response content
Thanks guys, Google actually gave me the fish itself :-) http://forum.java.sun.com/thread.jsp?thread=338226forum=33message=1387958 The whole code is there at the end, and it works! __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter and RequestDispatcher.forward()
Filters are only run once for the incoming request. See the archives for more information. -Tim Karl Kraft wrote: I've written a Filter to get applied to all page requests so that I can perform some access control and logging. However, when a servlet redirects using the forward() method of RequestDispatcher, it doesn't seem to go through the filter. If needed, I can call the Filter manually before I do the forward(), but I'm wondering if there is a more preferred way to do this. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Filter doing a redirect
Calling response.sendRedirect sets the HTTP status code to 302, and populates the 'location' response header. You almost always simply want to 'return;' from your Filter in this case (since the response is complete), rather than proceed with doFilterChain. Erik Price [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I wrote a filter, which performs a redirect *before* calling doFilterChain(). It is mapped to /main.jsp. I was hoping that this would cause the redirect to occur *before* calling main.jsp, but that appears not to be the case. Does the redirect occur afterward even though I have not yet called doFilterChain() in my filter when I call the redirect? Thanks, Erik -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Filter shows blank page in 4.1.18
On Sat, 18 Jan 2003, Affan Qureshi wrote: Date: Sat, 18 Jan 2003 16:35:19 +0500 From: Affan Qureshi [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: tomcat-user [EMAIL PROTECTED] Subject: Filter shows blank page in 4.1.18 I had filters configured for my webapp which worked in Tomcat 4.1.12 but now when I have installed 4.1.18 I get a blank page for *some* of my pages which do *not* contain images. The ones that contain images look fine and the filter works on them too. Strange problem. What must I be doing wrong? Most likely your filter is throwing an exception. Check the log files in $CATALINA_HOME/logs for details. Also can I map filters based on content-type instead of urls? In the deployment descriptor, you can filter on either servlet name or URL pattern. However, it's pretty easy to set up your own filtering on content type along the following lines: * Map your filter to /*. * Create a response wrapper that lets you get the content type from the response (see my post yesterday with example code), and/or add this ability to your own response wrapper. * In your doFilter() method, retrieve the content type and do the right thing for the right content types. Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: filter jsp:include servletPath?
Aaron, I am interested in doing the same thing. Can you post the filter and taglib? Thanks, STeve -Original Message- From: AAron nAAs [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 28, 2002 11:45 AM To: [EMAIL PROTECTED] Subject: Re: filter jsp:include servletPath? Due to the complexity of the question and probably vendor specific-ness of the answer, I've altered course and solved the problem. I wrote my own small taglib to implement the jsp:include functionality. I just need to change the jsp:include page=/include.html/ tags into mylib:include page=/include.html/ I'm still interested in knowing if a jsp:include intercept is possible, but I'm not waiting for the answer anymore. If there are any die hard coders/detail-ists out there, let me know if it's even possible without modifying Tomcat itself. -AAron From: AAron nAAs [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter jsp:include servletPath? Date: Wed, 27 Nov 2002 22:43:28 -0500 Hi all, This is more clarification about my attempts to automatically intercept and modify a .jsp request's servletPath as well as all the embedded jsp:include files. Examples: http://blah.com/index.jsp would run approot/blah/index.jsp or approot/default/index.jsp based on which was first found to exist. jsp:include page=/include.html/ would use approot/blah/include.html or approot/default/include.html based on which was first found to exist. I'm choosing a directory for the requested .jsp file based on the hostname specified in the request. I've gotten that to work perfectly by adding a filter to my web.xml file, and wrapping the request object before passing on to the next doFilter(). By overriding the request getServletPath() I can change the servlet or JSP file that gets invoked. Now I want the jsp:include files to also use an alternate directory. So refering to /myfile.jsp in the include would be intercepted and changed to another directory based on the hostname in the original request. Another view is that I'm creating a path to search through to find the requested (or included) file. If the requested file isn't found in the alternate expected directory, it checks in the default directory which will always have the file for request (or include). The code shows that once the request is filtered, all the jsp:include's are not. Private method ApplicationDispatcher.invoke() says: * IMPLEMENTATION NOTE: This implementation assumes * that no filters are applied to a forwarded or included resource, * because they were already done for the original request. Anyway, I'll let you read my original post below for more details on what I've found. BTW, I've searched long and hard for anyone doing this sort of thing. But, I'm certainly open to the embarassment of Oh, just do this if I've missed the obvious :-) Thanks, -AAron My original post: I'm trying to intercept a jsp:include so that I can adjust the requested file (ie: /include.html) to a different directory/file (ie: /otherdir/otherfile.html). If there is an easy way (Filter, Valve, Listener, ...) just let me know. NOTE: I've already created and installed a request filter in my web.xml to filter the initial request, but this doesn't get invoked for jsp:include references. Current idea: I want to change the javax.servlet.include.servlet_path request attribute so the DefaultServlet.getRelativePath() finds the new file. I can see that the ApplicationDispatcher fires off a list of InstanceEvent's before the DefaultServlet.service() is called. After days of exploration, I can't figure out how to add to get my InstanceEvent into the InstanceSupport's list (ie: cause a call to the support.addInstanceListener). Is there a configuration that will add my class to my application Context? Thanks, -AAron ([EMAIL PROTECTED]) _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- 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: filter jsp:include servletPath?
no, filters are only applied on the original request. Charlie -Original Message- From: AAron nAAs [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 28, 2002 12:45 PM To: [EMAIL PROTECTED] Subject: Re: filter jsp:include servletPath? Due to the complexity of the question and probably vendor specific-ness of the answer, I've altered course and solved the problem. I wrote my own small taglib to implement the jsp:include functionality. I just need to change the jsp:include page=/include.html/ tags into mylib:include page=/include.html/ I'm still interested in knowing if a jsp:include intercept is possible, but I'm not waiting for the answer anymore. If there are any die hard coders/detail-ists out there, let me know if it's even possible without modifying Tomcat itself. -AAron From: AAron nAAs [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter jsp:include servletPath? Date: Wed, 27 Nov 2002 22:43:28 -0500 Hi all, This is more clarification about my attempts to automatically intercept and modify a .jsp request's servletPath as well as all the embedded jsp:include files. Examples: http://blah.com/index.jsp would run approot/blah/index.jsp or approot/default/index.jsp based on which was first found to exist. jsp:include page=/include.html/ would use approot/blah/include.html or approot/default/include.html based on which was first found to exist. I'm choosing a directory for the requested .jsp file based on the hostname specified in the request. I've gotten that to work perfectly by adding a filter to my web.xml file, and wrapping the request object before passing on to the next doFilter(). By overriding the request getServletPath() I can change the servlet or JSP file that gets invoked. Now I want the jsp:include files to also use an alternate directory. So refering to /myfile.jsp in the include would be intercepted and changed to another directory based on the hostname in the original request. Another view is that I'm creating a path to search through to find the requested (or included) file. If the requested file isn't found in the alternate expected directory, it checks in the default directory which will always have the file for request (or include). The code shows that once the request is filtered, all the jsp:include's are not. Private method ApplicationDispatcher.invoke() says: * IMPLEMENTATION NOTE: This implementation assumes * that no filters are applied to a forwarded or included resource, * because they were already done for the original request. Anyway, I'll let you read my original post below for more details on what I've found. BTW, I've searched long and hard for anyone doing this sort of thing. But, I'm certainly open to the embarassment of Oh, just do this if I've missed the obvious :-) Thanks, -AAron My original post: I'm trying to intercept a jsp:include so that I can adjust the requested file (ie: /include.html) to a different directory/file (ie: /otherdir/otherfile.html). If there is an easy way (Filter, Valve, Listener, ...) just let me know. NOTE: I've already created and installed a request filter in my web.xml to filter the initial request, but this doesn't get invoked for jsp:include references. Current idea: I want to change the javax.servlet.include.servlet_path request attribute so the DefaultServlet.getRelativePath() finds the new file. I can see that the ApplicationDispatcher fires off a list of InstanceEvent's before the DefaultServlet.service() is called. After days of exploration, I can't figure out how to add to get my InstanceEvent into the InstanceSupport's list (ie: cause a call to the support.addInstanceListener). Is there a configuration that will add my class to my application Context? Thanks, -AAron ([EMAIL PROTECTED]) _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- 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: filter jsp:include servletPath?
FYI, through more digging in google groups, I found out that the Java Server spec is vague on this issue. The new Java Server spec is going to explicitly allow two options. The default option will be that only the initial request is filtered. The other option will filter includes and forwards as well. -AAron From: Cox, Charlie [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: RE: filter jsp:include servletPath? Date: Mon, 2 Dec 2002 07:50:48 -0500 no, filters are only applied on the original request. Charlie -Original Message- From: AAron nAAs [mailto:[EMAIL PROTECTED]] Sent: Thursday, November 28, 2002 12:45 PM To: [EMAIL PROTECTED] Subject: Re: filter jsp:include servletPath? Due to the complexity of the question and probably vendor specific-ness of the answer, I've altered course and solved the problem. I wrote my own small taglib to implement the jsp:include functionality. I just need to change the jsp:include page=/include.html/ tags into mylib:include page=/include.html/ I'm still interested in knowing if a jsp:include intercept is possible, but I'm not waiting for the answer anymore. If there are any die hard coders/detail-ists out there, let me know if it's even possible without modifying Tomcat itself. -AAron From: AAron nAAs [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter jsp:include servletPath? Date: Wed, 27 Nov 2002 22:43:28 -0500 Hi all, This is more clarification about my attempts to automatically intercept and modify a .jsp request's servletPath as well as all the embedded jsp:include files. Examples: http://blah.com/index.jsp would run approot/blah/index.jsp or approot/default/index.jsp based on which was first found to exist. jsp:include page=/include.html/ would use approot/blah/include.html or approot/default/include.html based on which was first found to exist. I'm choosing a directory for the requested .jsp file based on the hostname specified in the request. I've gotten that to work perfectly by adding a filter to my web.xml file, and wrapping the request object before passing on to the next doFilter(). By overriding the request getServletPath() I can change the servlet or JSP file that gets invoked. Now I want the jsp:include files to also use an alternate directory. So refering to /myfile.jsp in the include would be intercepted and changed to another directory based on the hostname in the original request. Another view is that I'm creating a path to search through to find the requested (or included) file. If the requested file isn't found in the alternate expected directory, it checks in the default directory which will always have the file for request (or include). The code shows that once the request is filtered, all the jsp:include's are not. Private method ApplicationDispatcher.invoke() says: * IMPLEMENTATION NOTE: This implementation assumes * that no filters are applied to a forwarded or included resource, * because they were already done for the original request. Anyway, I'll let you read my original post below for more details on what I've found. BTW, I've searched long and hard for anyone doing this sort of thing. But, I'm certainly open to the embarassment of Oh, just do this if I've missed the obvious :-) Thanks, -AAron My original post: I'm trying to intercept a jsp:include so that I can adjust the requested file (ie: /include.html) to a different directory/file (ie: /otherdir/otherfile.html). If there is an easy way (Filter, Valve, Listener, ...) just let me know. NOTE: I've already created and installed a request filter in my web.xml to filter the initial request, but this doesn't get invoked for jsp:include references. Current idea: I want to change the javax.servlet.include.servlet_path request attribute so the DefaultServlet.getRelativePath() finds the new file. I can see that the ApplicationDispatcher fires off a list of InstanceEvent's before the DefaultServlet.service() is called. After days of exploration, I can't figure out how to add to get my InstanceEvent into the InstanceSupport's list (ie: cause a call to the support.addInstanceListener). Is there a configuration that will add my class to my application Context? Thanks, -AAron ([EMAIL PROTECTED]) _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional
Re: Filter in Tomcat 3.3.1
Please do not cross-post questions on both the DEV and USER lists. In particular, this is a USER list sort of question. On Thu, 28 Nov 2002, Laxmikanth M.S. wrote: Date: Thu, 28 Nov 2002 17:49:09 +0530 From: Laxmikanth M.S. [EMAIL PROTECTED] Reply-To: Tomcat Developers List [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Filter in Tomcat 3.3.1 Hi all, can filter be applied in Tomcat 3.3.1. If you're speaking of javax.servlet.Filter, you cannot -- Tomcat 3.3 implements the Servlet 2.2 specification, and filters were not added until Servlet 2.3. did anyone try filters in tomcat3.3.1 if so please tell me the sequnce... thanks in advance Regards Laxmikanth M S Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: filter jsp:include servletPath?
Due to the complexity of the question and probably vendor specific-ness of the answer, I've altered course and solved the problem. I wrote my own small taglib to implement the jsp:include functionality. I just need to change the jsp:include page=/include.html/ tags into mylib:include page=/include.html/ I'm still interested in knowing if a jsp:include intercept is possible, but I'm not waiting for the answer anymore. If there are any die hard coders/detail-ists out there, let me know if it's even possible without modifying Tomcat itself. -AAron From: AAron nAAs [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter jsp:include servletPath? Date: Wed, 27 Nov 2002 22:43:28 -0500 Hi all, This is more clarification about my attempts to automatically intercept and modify a .jsp request's servletPath as well as all the embedded jsp:include files. Examples: http://blah.com/index.jsp would run approot/blah/index.jsp or approot/default/index.jsp based on which was first found to exist. jsp:include page=/include.html/ would use approot/blah/include.html or approot/default/include.html based on which was first found to exist. I'm choosing a directory for the requested .jsp file based on the hostname specified in the request. I've gotten that to work perfectly by adding a filter to my web.xml file, and wrapping the request object before passing on to the next doFilter(). By overriding the request getServletPath() I can change the servlet or JSP file that gets invoked. Now I want the jsp:include files to also use an alternate directory. So refering to /myfile.jsp in the include would be intercepted and changed to another directory based on the hostname in the original request. Another view is that I'm creating a path to search through to find the requested (or included) file. If the requested file isn't found in the alternate expected directory, it checks in the default directory which will always have the file for request (or include). The code shows that once the request is filtered, all the jsp:include's are not. Private method ApplicationDispatcher.invoke() says: * IMPLEMENTATION NOTE: This implementation assumes * that no filters are applied to a forwarded or included resource, * because they were already done for the original request. Anyway, I'll let you read my original post below for more details on what I've found. BTW, I've searched long and hard for anyone doing this sort of thing. But, I'm certainly open to the embarassment of Oh, just do this if I've missed the obvious :-) Thanks, -AAron My original post: I'm trying to intercept a jsp:include so that I can adjust the requested file (ie: /include.html) to a different directory/file (ie: /otherdir/otherfile.html). If there is an easy way (Filter, Valve, Listener, ...) just let me know. NOTE: I've already created and installed a request filter in my web.xml to filter the initial request, but this doesn't get invoked for jsp:include references. Current idea: I want to change the javax.servlet.include.servlet_path request attribute so the DefaultServlet.getRelativePath() finds the new file. I can see that the ApplicationDispatcher fires off a list of InstanceEvent's before the DefaultServlet.service() is called. After days of exploration, I can't figure out how to add to get my InstanceEvent into the InstanceSupport's list (ie: cause a call to the support.addInstanceListener). Is there a configuration that will add my class to my application Context? Thanks, -AAron ([EMAIL PROTECTED]) _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] _ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: filter doesn't work at Tomcat4.1.12!?
if your filter is not being called, then the mapping is probably not correct. Please provide the relevant portions of your web.xml. Also provide the url that your are using for testing. You can change names to protect the innocent. did you look in the logs to see if there are any messages? Charlie -Original Message- From: Johnny Cui [mailto:johnny_lucky2000;yahoo.com] Sent: Tuesday, November 12, 2002 4:09 AM To: Tomcat Users List Subject: filter doesn't work at Tomcat4.1.12!? Hi all, I have check every possible error according to some friends suggestion, however, my own filter still doesn't work.It is just a authenticater filter. the weird things is, I can see the print out lines in the filter.init() methods, this means the container has create a instance for my filters, but the doFilter() seem not to be called, because I add a print line in the very beginning of the code for doFilter(). I think the server.xml and web.xml is fine because the sample filter can work now, I just put the filter element for authenticater filter behind the sample working filter, and the filter-mapping is all the same for the two fitler, so I assume in the filterchain should be like this: sample filter -- authenticater filter. could anybody help me to solve this problem. Johnny -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Re: filter doesn't work at Tomcat4.1.12!?
Hi Johnny, Based on the limited info you provided, I can't point to your exact problem, but there are a few general things to check to make sure you have configured properly. Make sure that you have your filter defined and provide a mapping for it such as this: filter filter-nameMy Filter/filter-name filter-classorg.mypackage.MyFilter/filter-class /filter filter-mapping filter-nameMy Filter/filter-name url-pattern/*/url-pattern /filter-mapping Also, remember that the web.xml is order specific. For instance, your filter and filter-mapping elements must come before your servlet and servlet-mapping elements and so on If you have this done properly, the next thing to do is to set up a logger in your filter (or use a remote debugger) to make sure your filter is actually running. Other than that, is your application getting deployed and running properly otherwise? If so, that would limit your search to the above recommendations. Otherwise, you should try to get your app running properly and then try the above recommendations. Jake At 01:30 AM 11/12/2002 -0500, you wrote: Hi all, I am trying to deploy a filter to my application in Tomcat 4.1.12, since the code for filter is a sample code from reference book and I do exactly to the web.xml for my application, however , the filter did not work. Does anyone had experience in deploy filters on Tomcat4.1.12? Does Tomcat 4.1.12 support filters?or it need some special configuration? thanks for your attention. Johnny -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Re: filter doesn't work at Tomcat4.1.12!?
Does your web.xml read like this ? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN http://java.sun.com/dtd/web-app_2_3.dtd; Or like ? !DOCTYPE web-app PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.2//EN http://java.sun.com/dtd/web-app_2_2.dtd; Must read like the top line or Tomcat won't understand that filter tags are a part of the web.xml Med venlig hilsen Kleth -- Kristian A. Leth. Systemsdeveloper, Maersk Data A/S. -- Professionals are predictable; the world is full of dangerous amateurs. -- |-+ | || | | Johnny Cui | | | johnny_lucky20| | | [EMAIL PROTECTED] | | || | | 12-11-2002 | | | 07:30 | | | Please respond | | | to Tomcat | | | Users List| | || | || |-+ --| | | | To: Tomcat Users List [EMAIL PROTECTED] | | cc: | | Subject: filter doesn't work at Tomcat4.1.12!? | --| Hi all, I am trying to deploy a filter to my application in Tomcat 4.1.12, since the code for filter is a sample code from reference book and I do exactly to the web.xml for my application, however , the filter did not work. Does anyone had experience in deploy filters on Tomcat4.1.12? Does Tomcat 4.1.12 support filters?or it need some special configuration? thanks for your attention. Johnny -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
RE: filter-mapping,process /* except /x?
there is no way. you will have to do that in your filter. you could apply your filter to subdirectories individually instead of /* and leave your login page in the root or in an unmapped directory. Charlie -Original Message- From: [EMAIL PROTECTED] [mailto:rhodespc;telerama.com] Sent: Monday, October 28, 2002 2:02 PM To: Tomcat Users List Subject: filter-mapping,process /* except /x? Is there a way to have a filter not run on a specific mapping? For example, if you have a filter-mapping of /* this will be invoked for every single resource in the container. How can you prevent the filter from running against one particular servlet (besides doing skip logic in the filter code)? BTW, what I am trying to do is to implement security using a filter. However, I want the login page to be displayed (not run through the filter). Thanks! -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Re: filter-mapping,process /* except /x?
On Mon, 28 Oct 2002 [EMAIL PROTECTED] wrote: Date: Mon, 28 Oct 2002 14:02:29 -0500 (EST) From: [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: filter-mapping,process /* except /x? Is there a way to have a filter not run on a specific mapping? For example, if you have a filter-mapping of /* this will be invoked for every single resource in the container. The legal syntax for a filter URL pattern is the same as for a servlet mapping: * Exact match (/foo). * Path match (/foo/*). * Extension match (*.foo). * Default servlet (/). How can you prevent the filter from running against one particular servlet (besides doing skip logic in the filter code)? Skip logic is it. BTW, what I am trying to do is to implement security using a filter. However, I want the login page to be displayed (not run through the filter). Tomcat has a similar problem with the form login page when you have a security constraint mapped to /*. The solution was the same as what you need to do -- specific logic to exempt your login page from the restrictions that your filter imposes. Thanks! Craig -- To unsubscribe, e-mail: mailto:tomcat-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:tomcat-user-help;jakarta.apache.org
Re: filter to change jsessionid cookie almost done, but need little help
The Tomcat sso solution only allows sso between applications in a single container. My sso solution allows sso across multiple jvm's in different hosts in the same domain, as well as the SSO for the single JVM. The SSO for tomcat is quite limited. I agree that the jsessionid is part of the spec, we agree with all specs, right? But we can have cookie name collisions if you try to raise the scope/domain of the jsessionid cookie. My original problem is that I am not able to intercept the setting of the jsessionid cookie in my filter. Can you provide any guidance on how I may intercept this event? Thanks! Phillip On Sun, 29 Sep 2002, Craig R. McClanahan wrote: On Sat, 28 Sep 2002, Phillip Rhodes wrote: Date: Sat, 28 Sep 2002 13:51:18 -0400 From: Phillip Rhodes [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter to change jsessionid cookie almost done, but need little help I am writing a package that will facilitate sso between java based applications that will be released open source and free. You might also consider just using the single sign on support provided by your container. For Tomcat 4, see the documentation at: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/host.html and scroll down to the section entitled Single Sign On. Part of the problem is that the tomcat cookie name is NOT at all configurable. When jsessionid is set, the host of the domain is present, the scope is set to the webapp, etc... The cookie name is standardized by the servlet spec -- there is no reason to make it configurable. I wrote a filter that reads the jsessionid and change the scope and domain that it can be read by any application in that domain. My problem is that in the first request in my filter (and to the app), the cookie may not be set. No problem (or so i thought!) . I created a HttpResponseWrapper and HttpRequestWrapper and pass that onto the filter chain. When someone calls addCookie on the response (my wrapper) , I put in in my requestwrapper, so I can read cookies that are set in the present request/response. After I do the filter.doChain method, I again check for the jsessionid cookie. It's not set in the HttpRequestWrapper that I passed onto the chain, but I DO know it's being set by the time my browser gets it. IMHO, you are following the wrong strategy. It's perfectly reasonable to support single sign on across apps that have independent sessions (and even apps that don't involve sessions at all). The Tomcat implementation accomplishes SSO with a separate cookie. Craig -- 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: filter to change jsessionid cookie almost done, but need littlehelp
On Mon, 30 Sep 2002 [EMAIL PROTECTED] wrote: Date: Mon, 30 Sep 2002 12:53:54 -0400 (EDT) From: [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Re: filter to change jsessionid cookie almost done, but need little help The Tomcat sso solution only allows sso between applications in a single container. My sso solution allows sso across multiple jvm's in different hosts in the same domain, as well as the SSO for the single JVM. The SSO for tomcat is quite limited. I agree that the jsessionid is part of the spec, we agree with all specs, right? But we can have cookie name collisions if you try to raise the scope/domain of the jsessionid cookie. That's why the container deliberately sets the jsessionid properties the way that it does. My original problem is that I am not able to intercept the setting of the jsessionid cookie in my filter. Can you provide any guidance on how I may intercept this event? You cannot intercept this in a filter, because it is being done by the container. At best, you'd have to write a Valve to do it inside Tomcat, or otherwise modify the Tomcat source code. Obviously, you become container dependent at this point, but that's going to be true of any solution that actually modifies how container managed security works. My primary advice still stands -- do NOT try to mess with the jsesssionid cookie at all when implementing SSO type solutions. Use a separate cookie instead. Thanks! Phillip Craig On Sun, 29 Sep 2002, Craig R. McClanahan wrote: On Sat, 28 Sep 2002, Phillip Rhodes wrote: Date: Sat, 28 Sep 2002 13:51:18 -0400 From: Phillip Rhodes [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter to change jsessionid cookie almost done, but need little help I am writing a package that will facilitate sso between java based applications that will be released open source and free. You might also consider just using the single sign on support provided by your container. For Tomcat 4, see the documentation at: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/host.html and scroll down to the section entitled Single Sign On. Part of the problem is that the tomcat cookie name is NOT at all configurable. When jsessionid is set, the host of the domain is present, the scope is set to the webapp, etc... The cookie name is standardized by the servlet spec -- there is no reason to make it configurable. I wrote a filter that reads the jsessionid and change the scope and domain that it can be read by any application in that domain. My problem is that in the first request in my filter (and to the app), the cookie may not be set. No problem (or so i thought!) . I created a HttpResponseWrapper and HttpRequestWrapper and pass that onto the filter chain. When someone calls addCookie on the response (my wrapper) , I put in in my requestwrapper, so I can read cookies that are set in the present request/response. After I do the filter.doChain method, I again check for the jsessionid cookie. It's not set in the HttpRequestWrapper that I passed onto the chain, but I DO know it's being set by the time my browser gets it. IMHO, you are following the wrong strategy. It's perfectly reasonable to support single sign on across apps that have independent sessions (and even apps that don't involve sessions at all). The Tomcat implementation accomplishes SSO with a separate cookie. Craig -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: filter to change jsessionid cookie almost done, but need littlehelp
On Sat, 28 Sep 2002, Phillip Rhodes wrote: Date: Sat, 28 Sep 2002 13:51:18 -0400 From: Phillip Rhodes [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: filter to change jsessionid cookie almost done, but need little help I am writing a package that will facilitate sso between java based applications that will be released open source and free. You might also consider just using the single sign on support provided by your container. For Tomcat 4, see the documentation at: http://jakarta.apache.org/tomcat/tomcat-4.1-doc/config/host.html and scroll down to the section entitled Single Sign On. Part of the problem is that the tomcat cookie name is NOT at all configurable. When jsessionid is set, the host of the domain is present, the scope is set to the webapp, etc... The cookie name is standardized by the servlet spec -- there is no reason to make it configurable. I wrote a filter that reads the jsessionid and change the scope and domain that it can be read by any application in that domain. My problem is that in the first request in my filter (and to the app), the cookie may not be set. No problem (or so i thought!) . I created a HttpResponseWrapper and HttpRequestWrapper and pass that onto the filter chain. When someone calls addCookie on the response (my wrapper) , I put in in my requestwrapper, so I can read cookies that are set in the present request/response. After I do the filter.doChain method, I again check for the jsessionid cookie. It's not set in the HttpRequestWrapper that I passed onto the chain, but I DO know it's being set by the time my browser gets it. IMHO, you are following the wrong strategy. It's perfectly reasonable to support single sign on across apps that have independent sessions (and even apps that don't involve sessions at all). The Tomcat implementation accomplishes SSO with a separate cookie. Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: filter
Hi, do you have the elements in the correct order as specified by the web.xml's DTD? Refer to section 13.3 of the Servlet (2.3) spec. At 10:21 AM 14/08/2002 -0300, you wrote: I'm using Tomcat 4.0.4 I'm trying to declare a filter in web.xml file, but it refuses to work. Here is what I wrote: filter filter-nametestFilter/filter-name filter-classcom.test.FilterTest/filter-name /filter When I start Tomcat it says my XML is invalid. What I'm doing wrong? -- Felipe Schnack Analista de Sistemas [EMAIL PROTECTED] Cel.: (51)91287530 Linux Counter #281893 Faculdade Ritter dos Reis www.ritterdosreis.br [EMAIL PROTECTED] Fone/Fax.: (51)32303328 -- 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: filter
filter-classcom.test.FilterTest/filter-name ^^^ // should be /filter-class Failing that, i'd have to see the error but my guess is that you have the order of things in your web.xml wrong. filter tags should appear after context-param and before listener tags. See your dtd for more details. I use http://java.sun.com/web-app_2_3.dtd - Original Message - From: Felipe Schnack [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 2:21 PM Subject: filter I'm using Tomcat 4.0.4 I'm trying to declare a filter in web.xml file, but it refuses to work. Here is what I wrote: filter filter-nametestFilter/filter-name filter-classcom.test.FilterTest/filter-name /filter When I start Tomcat it says my XML is invalid. What I'm doing wrong? -- Felipe Schnack Analista de Sistemas [EMAIL PROTECTED] Cel.: (51)91287530 Linux Counter #281893 Faculdade Ritter dos Reis www.ritterdosreis.br [EMAIL PROTECTED] Fone/Fax.: (51)32303328 -- 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: filter
filter-classcom.test.FilterTest/filter-name Your end tag dosen't fit your start tag. change it to : filter-classcom.test.FilterTest/filter-class regards, Cédric - Original Message - From: Felipe Schnack [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 3:21 PM Subject: filter I'm using Tomcat 4.0.4 I'm trying to declare a filter in web.xml file, but it refuses to work. Here is what I wrote: filter filter-nametestFilter/filter-name filter-classcom.test.FilterTest/filter-name /filter When I start Tomcat it says my XML is invalid. What I'm doing wrong? -- Felipe Schnack Analista de Sistemas [EMAIL PROTECTED] Cel.: (51)91287530 Linux Counter #281893 Faculdade Ritter dos Reis www.ritterdosreis.br [EMAIL PROTECTED] Fone/Fax.: (51)32303328 -- 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: filter
Yes, the order of mostly everything was wrong, thank you very much :-) Anyway, the tag thing was an typo. On Wed, 2002-08-14 at 10:24, Mark O'Driscoll wrote: filter-classcom.test.FilterTest/filter-name ^^^ // should be /filter-class Failing that, i'd have to see the error but my guess is that you have the order of things in your web.xml wrong. filter tags should appear after context-param and before listener tags. See your dtd for more details. I use http://java.sun.com/web-app_2_3.dtd - Original Message - From: Felipe Schnack [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, August 14, 2002 2:21 PM Subject: filter I'm using Tomcat 4.0.4 I'm trying to declare a filter in web.xml file, but it refuses to work. Here is what I wrote: filter filter-nametestFilter/filter-name filter-classcom.test.FilterTest/filter-name /filter When I start Tomcat it says my XML is invalid. What I'm doing wrong? -- Felipe Schnack Analista de Sistemas [EMAIL PROTECTED] Cel.: (51)91287530 Linux Counter #281893 Faculdade Ritter dos Reis www.ritterdosreis.br [EMAIL PROTECTED] Fone/Fax.: (51)32303328 -- 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] -- Felipe Schnack Analista de Sistemas [EMAIL PROTECTED] Cel.: (51)91287530 Linux Counter #281893 Faculdade Ritter dos Reis www.ritterdosreis.br [EMAIL PROTECTED] Fone/Fax.: (51)32303328 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Filter order of operation
On Tue, 23 Jul 2002, Jacob Hookom wrote: Date: Tue, 23 Jul 2002 12:54:52 -0500 From: Jacob Hookom [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Filter order of operation I know that a single request can come through multiple Filters in a chain, I'm wondering if there's any reliable way to ensure precedence in the chain of operation? Browse to http://java.sun.com/products/servlet/download.html. Download the Servlet 2.3 specification. Read Chapter 6 -- in particular 6.2.4. Jacob Hookom Comprehensive Computer Science University of Wisconsin, Eau Claire Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Filter order of operation
Cheers, I did a search previously on sun's site but everything seemed to only skim the surface. Jacob Hookom Comprehensive Computer Science University of Wisconsin, Eau Claire -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 1:13 PM To: Tomcat Users List Subject: Re: Filter order of operation On Tue, 23 Jul 2002, Jacob Hookom wrote: Date: Tue, 23 Jul 2002 12:54:52 -0500 From: Jacob Hookom [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Filter order of operation I know that a single request can come through multiple Filters in a chain, I'm wondering if there's any reliable way to ensure precedence in the chain of operation? Browse to http://java.sun.com/products/servlet/download.html. Download the Servlet 2.3 specification. Read Chapter 6 -- in particular 6.2.4. Jacob Hookom Comprehensive Computer Science University of Wisconsin, Eau Claire Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.375 / Virus Database: 210 - Release Date: 7/10/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.375 / Virus Database: 210 - Release Date: 7/10/2002 -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Filter order of operation
As Craig said, look at the Specification. To quote 6.2.4, page 48: quote The order the container uses in building the chain of filters to be applied for a particular request URI is 1. The url-pattern matching filter-mappings in the same order that these ele-ments appear in the deployment descriptor, and then 2. The servlet-name matching filter-mappings in the same order that these ele-ments appear in the deployment descriptor. /quote Regards, Will Hartung ([EMAIL PROTECTED]) - Original Message - From: Jacob Hookom [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Sent: Tuesday, July 23, 2002 11:35 AM Subject: RE: Filter order of operation Cheers, I did a search previously on sun's site but everything seemed to only skim the surface. Jacob Hookom Comprehensive Computer Science University of Wisconsin, Eau Claire -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 23, 2002 1:13 PM To: Tomcat Users List Subject: Re: Filter order of operation On Tue, 23 Jul 2002, Jacob Hookom wrote: Date: Tue, 23 Jul 2002 12:54:52 -0500 From: Jacob Hookom [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Filter order of operation I know that a single request can come through multiple Filters in a chain, I'm wondering if there's any reliable way to ensure precedence in the chain of operation? Browse to http://java.sun.com/products/servlet/download.html. Download the Servlet 2.3 specification. Read Chapter 6 -- in particular 6.2.4. Jacob Hookom Comprehensive Computer Science University of Wisconsin, Eau Claire Craig -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.375 / Virus Database: 210 - Release Date: 7/10/2002 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.375 / Virus Database: 210 - Release Date: 7/10/2002 -- 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: filter to set content type
you need a wrapper for the response object. Sorry, I can't understand how it works yet :-( Anyway, I wrote wrapper: import javax.servlet.http.*; public class MyResponseWrapper extends HttpServletResponseWrapper { public MyResponseWrapper(HttpServletResponse response) { super(response); } private String saveContentType = null; public String getContentType() { return (this.saveContentType); } public void setContentType(String contentType) { super.setContentType(contentType); this.saveContentType = contentType; } } Then I try to use it: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { MyResponseWrapper wresponse = new MyResponseWrapper((HttpServletResponse) response); chain.doFilter(request, wresponse); wresponse.setContentType(text/xml;charset=windows-1251); } This works for html pages, but doesn't work for jsp! I don't know why, but jsps still have type text/html :-( Could you help me? see this post in the archives: http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg41615.html Charlie -Original Message- From: Dmitry Melekhov [mailto:[EMAIL PROTECTED]] Sent: Friday, July 19, 2002 1:48 AM To: [EMAIL PROTECTED] Subject: filter to set content type Hello! I need to filter jsp output to set encoding in content type. I tryied several variants I can write ;-) with no success :-( Could somebody send me an example? Thank you! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: filter to set content type
You are trying to set the content type on the real response after it's been flushed (if the response is bigger than the output buffer), which won't do any good because the HTTP headers are long gone. Try changing the setContentType() method in your wrapper to something like this: public void setContentType(String contentType) { super.setContentType(contentType + ;charset=windows-1251); } to set the encoding on the real response as soon as the servlet or JSP page tries to set it on what it thinks the response is (i.e. the wraper that you've created). In a production-quality implementation, you would want to add niceties like: * Checking for a null argument * Checking for cases where the character set was already included (i.e. a JSP page had %@ page contentType=text/html;charset=xxx %) * Overriding setHeader() and addHeader() as well, in case the app tries something like: response.setHeader(Content-Type, text/html); Craig On Tue, 23 Jul 2002, Dmitry Melekhov wrote: Date: Tue, 23 Jul 2002 09:13:56 +0500 From: Dmitry Melekhov [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: tomcat-user [EMAIL PROTECTED] Subject: RE: filter to set content type you need a wrapper for the response object. Sorry, I can't understand how it works yet :-( Anyway, I wrote wrapper: import javax.servlet.http.*; public class MyResponseWrapper extends HttpServletResponseWrapper { public MyResponseWrapper(HttpServletResponse response) { super(response); } private String saveContentType = null; public String getContentType() { return (this.saveContentType); } public void setContentType(String contentType) { super.setContentType(contentType); this.saveContentType = contentType; } } Then I try to use it: public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { MyResponseWrapper wresponse = new MyResponseWrapper((HttpServletResponse) response); chain.doFilter(request, wresponse); wresponse.setContentType(text/xml;charset=windows-1251); } This works for html pages, but doesn't work for jsp! I don't know why, but jsps still have type text/html :-( Could you help me? see this post in the archives: http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg41615.html Charlie -Original Message- From: Dmitry Melekhov [mailto:[EMAIL PROTECTED]] Sent: Friday, July 19, 2002 1:48 AM To: [EMAIL PROTECTED] Subject: filter to set content type Hello! I need to filter jsp output to set encoding in content type. I tryied several variants I can write ;-) with no success :-( Could somebody send me an example? Thank you! -- 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: filter to set content type
Craig R. McClanahan wrote: You are trying to set the content type on the real response after it's been flushed (if the response is bigger than the output buffer), which won't do any good because the HTTP headers are long gone. Try changing the setContentType() method in your wrapper to something like this: public void setContentType(String contentType) { super.setContentType(contentType + ;charset=windows-1251); } to set the encoding on the real response as soon as the servlet or JSP page tries to set it on what it thinks the response is (i.e. the wraper that you've created). [skip] Thank you! Now I have it working! -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: filter questions
I have read in the spec and tried a filter myself, and I have a few questions: 1. Where the spec(pg 45) says: Only one instance per filter declaration in the deployment descriptor is instantiated per Java virtual machine of the container. I read this as it works similar to a servlet, one instance per virtual host(not jvm) with many threads. Is this correct? Yes, that's right. The same thread safety issues apply. that's good...it keeps it simple and we like simple :) 4. How much more efficient is handling a request in filter than handling it in a servlet if the handling code is the same. I noticed that when I converted the ServletRequest to an HttpServletRequest that not all the functions were available(getPathInfo() was the one that I noticed), so I assume that there is some processing going on between the filter and the servlet - but I could be wrong. By converted, you mean casting don't you? public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest hrequest = (HttpServletRequest) request; String pathInfo = hrequest.getPathInfo(); ... yes, that's what I meant. The getPathInfo() always returned null in my filter. As I revisit the docs on getPathInfo(): a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information To me this should always return the filename requested. The file that my filter is wrapping is actually handled by the DefaultServlet, not my own servlet. In this case should getPathInfo() be returning the filename(or the same as getRequetsURI())? I think it should as the servlet path should be null, but I've never really dealt with the default servlet other than to let it do its thing. I worked around this by using getRequestURI(). } This will either work or throw a ClassCastException if the request isn't really an HTTP one -- but that won't happen to you in a standard Tomcat installation because they are all HTTP requests. I used instanceOf just in case :) I'm really liking these filters since I share servlets between virtual hosts, and now I see that filters can really help cleanup the customized processing in my servlets for each virtual host. That's a pretty good use case. The other thing I really like about filters is that you can divide your processing into lots of little filters, and then mix and match the ones you need for a particular purpose. I'm also using filters to enforce login(jdbcrealm doesn't agree with my jdbc driver and I haven't taken the time to extend it to fix the problem) and agreement to terms/conditions before receiving a file on the filesystem through the DefaultServlet. Before using filters, I was manually reading the file and serving it from my servlet to get this functionality which was painful and I didn't support all the features(Range requests) which Tomcat does through the defaulservlet. All it took was one instance of a download manager blowing up my servlet for me to look for a better solution :) Charlie -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: filter questions
On Tue, 8 Jan 2002, Cox, Charlie wrote: Date: Tue, 8 Jan 2002 16:16:44 -0500 From: Cox, Charlie [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: 'Tomcat Users List' [EMAIL PROTECTED] Subject: filter questions I have read in the spec and tried a filter myself, and I have a few questions: 1. Where the spec(pg 45) says: Only one instance per filter declaration in the deployment descriptor is instantiated per Java virtual machine of the container. I read this as it works similar to a servlet, one instance per virtual host(not jvm) with many threads. Is this correct? Yes, that's right. The same thread safety issues apply. 2. I have a filter on a downloadable file(50MB) and I have noticed that when the user clicks 'cancel' on the browser, that it throws an IOException, which I can trap in my filter ['try' around doChain()]. If I rethrow this exception(after my processing), it is like I never touched it and it writes an error in the log about 'socket write error'. If I do not rethrow this exception is there any processing or cleanup, that will not get done correctly? Or can I just return without rethrowing? I would really like to cut down on the 'socket write errors' in the logs. Again, the same principles apply here as would apply in the servlet that creates the output in the first place. You can indeed swallow the exception, if you would do so in the servlet itself. 3. How can I check the status(200,404,etc) on the response object after the doChain() has returned? I don't need to wrap the request/response, I am just interested in knowing when a 404 occurs(only within this filter if possible). I tried converting it to a HttpServletResponse object, but I don't see how to *read* the status. You *do* need a wrapper to make this information available - an example might look like this: public class MyResponseWrapper extends HttpServletResponseWrapper { protected int saveStatus = 0; public MyResponseWrapper(HttpServletResponse response) { super(response); } // Override Servlet API methods to save the status value public void sendError(int sc) { saveStatus = sc; super.sendError(sc); } public void sendError(int sc, String message) { saveStatus = sc; super.sendError(sc, message); } // ... all the other HttpServletResponse methods are delegated // ... to the superclass automatically // Extra public method to retrieve the status value public int getStatus() { return (saveStatus); } } Then, after chain.doFilter() returns, you can call the getStatus() method to see what the response status was: MyResponseWrapper wresponse = new MyResponseWrapper((HttpServletResponse) response); chain.doFilter(request, wresponse); int status = wresponse.getStatus(); if (status == HttpServletResponse.SC_NOT_FOUND) { ... } 4. How much more efficient is handling a request in filter than handling it in a servlet if the handling code is the same. I noticed that when I converted the ServletRequest to an HttpServletRequest that not all the functions were available(getPathInfo() was the one that I noticed), so I assume that there is some processing going on between the filter and the servlet - but I could be wrong. By converted, you mean casting don't you? public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest hrequest = (HttpServletRequest) request; String pathInfo = hrequest.getPathInfo(); ... } This will either work or throw a ClassCastException if the request isn't really an HTTP one -- but that won't happen to you in a standard Tomcat installation because they are all HTTP requests. Filtering actually does impose a small performance penalty (minimally, an extra method call for each request, plus whatever overhead it takes to set up the filter chain), but IMHO it's very much worth it for the cleaner code design that is enabled. I'm really liking these filters since I share servlets between virtual hosts, and now I see that filters can really help cleanup the customized processing in my servlets for each virtual host. That's a pretty good use case. The other thing I really like about filters is that you can divide your processing into lots of little filters, and then mix and match the ones you need for a particular purpose. Charlie -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED] -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]
Re: Filter mapping question
On Fri, 28 Dec 2001, Yoav Shapira wrote: Date: Fri, 28 Dec 2001 15:37:23 -0500 From: Yoav Shapira [EMAIL PROTECTED] Reply-To: Tomcat Users List [EMAIL PROTECTED] To: Tomcat Users List [EMAIL PROTECTED] Subject: Filter mapping question Hi, I have a servlet and a filter I want to be run when that servlet is accessed. However, the servlet is never accessed directly via the browser. Rather, it's embedded in a frameset and launched using something like this: a href=javascript:void(0); onClick=thatframe.src='http://myhost/mycontext/myservlet'; return true; click here /a So in my web.xml, I have: filter filter-namemyFilter/filter-name filter-classmyFilterClass/filter-class /filter-name filter-mapping filter-namemyFilter/filter-name servlet-namemyServlet/servlet-name /filter-mapping servlet servlet-namemyServlet/servlet-name servlet-classmyServletClass/servlet-class /servlet I assume you also have a servlet mapping, right? It would need to look like this: servlet-mapping servlet-namemyServlet/servlet-name url-pattern/myservlet/url-pattern /servlet-mapping The problem is, tomcat never calls doFilter() for my filter when that servlet is called. The filter gets initialized appropriately (I have logging comments on the filter's init(), doFilter(), destroy() methods). If I go to http://myhost/mycontext/myservlet myself, the filter does get called, so I know it has to do with the calling mechanism, filter-mapping, or something along these lines. Thanks in advance, and sorry for the long post, Tomcat has no way to know whether the request came from the location line of the browser or via JavaScript -- so that's not the cause of the problem. You can look at the access log (in the logs directory) to see what URI is really being requested when you do it manually, and when the Javascript function calls it, to ensure that they are really identical. One other thing to check is that your servlet mapping is really for /myservlet and not for /myServlet. URLs are case sensitive, so this would cause a mismatch. Yoav Shapira Millennium Pharmaceuticals, Inc. [EMAIL PROTECTED] Craig McClanahan -- To unsubscribe: mailto:[EMAIL PROTECTED] For additional commands: mailto:[EMAIL PROTECTED] Troubles with the list: mailto:[EMAIL PROTECTED]