filter: How to set browser encoding?

2005-10-12 Thread Mark
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]



Re: filter: How to set browser encoding?

2005-10-12 Thread Frank W. Zammetti
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]



issue with Filter

2005-09-09 Thread Mark
Hi,
I have implemented the filter to add expire date (now + 1 day) on
image.
by dooing

resp.setHeader(Cache-Control, max-age=86400);

For some reason expire date set to system time ( It work yesterday,
but not today very strange!) I didn't restart tomcat 5.0.28
(redaht 9)

How can I check that a filter was executed and the proper value has
been set.

Thanks a lot,
Mark.

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: injecting a new request within a filter

2005-07-28 Thread Marten Lehmann

Hello,


1) You need to be running tomcat 5
2) See SRV.6.2.5 Filters and the RequestDispatcher in the servlet spec - 
it discusses exactly what you need to do.


thanks, it works as I expected it to work now.

Regards
Marten

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



injecting a new request within a filter

2005-07-27 Thread Marten Lehmann

Hello,

from within a filter, I'm trying to do the following:

request.getRequestDispatcher(req.getServletPath() + 
index.faces).forward(request, response);


This works generally fine. The problem is, that attached filters simply 
aren't processed for this request. I have two filters in series, the 
first filter is doing the above forward-request on a conditionally basis 
and the second filter is never called in this case. How can I re-inject 
the request, so that either both filters are passed again, or at least 
the second filter (and maybe others following) is processed?


Regards
Marten

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: injecting a new request within a filter

2005-07-27 Thread Tim Funk

1) You need to be running tomcat 5
2) See SRV.6.2.5 Filters and the RequestDispatcher in the servlet spec - it 
discusses exactly what you need to do.


-Tim

Marten Lehmann wrote:


Hello,

from within a filter, I'm trying to do the following:

request.getRequestDispatcher(req.getServletPath() + 
index.faces).forward(request, response);


This works generally fine. The problem is, that attached filters simply 
aren't processed for this request. I have two filters in series, the 
first filter is doing the above forward-request on a conditionally basis 
and the second filter is never called in this case. How can I re-inject 
the request, so that either both filters are passed again, or at least 
the second filter (and maybe others following) is processed?
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Tomcat filter to overwrite the requestURL of incoming httprequest object

2005-07-25 Thread Jaynika Barot
hi all,

I want to write a filter which will overwrite the request URL in
incoming httprequest.

if incoming request's URI contains *./myservletName/extra1/extra2.*

I want to reset it to *./myservletName?param1=extra1param2=extra2 and
pass this request object to subsequent processing (filter chain).

Is it possible to do?? If so how?

thx,
Jaynika

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat filter to overwrite the requestURL of incoming httprequest object

2005-07-25 Thread Martin Bromley

You have to wrap the HttpServletRequest with a class that overrides the methods 
relating to the URI.  I've attached an abstract class that I wrote to make this 
a bit easier.

You will have to implement the rewriteURL method to do the necessary String 
parsing.

Then in your filter doFilter:

chain.doFilter(new WrappedRequest(request), response);

(assuming you've written WrappedRequest - that extends the abstract class I've 
attached).

Good luck.
Martin

PS You're question actually has nothing to do with Tomcat specifically...

Jaynika Barot wrote:

hi all,

I want to write a filter which will overwrite the request URL in
incoming httprequest.

if incoming request's URI contains *./myservletName/extra1/extra2.*

I want to reset it to *./myservletName?param1=extra1param2=extra2 and
pass this request object to subsequent processing (filter chain).

Is it possible to do?? If so how?

thx,
Jaynika

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


package com.mbromley.util.servlet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

/** This enables the URLs in an HttpServletRequest to be consistently rewritten.
 * This needs to be extended for it to do anything useful.  At least one of the
 * rewriteURL methods needs to be overridden.
 */
public abstract class URLRewritingRequestWrapper 
extends HttpServletRequestWrapper {

public URLRewritingRequestWrapper(
final HttpServletRequest request) {
super(request);
}

@Override
public final String getPathInfo() {
return getPossiblyNull(super.getPathInfo());
}

@Override
public final String getPathTranslated() {
return getPossiblyNull(super.getPathTranslated());
}

@Override
public final String getRequestURI() {
return rewriteURL(super.getRequestURI());
}

@Override
public final StringBuffer getRequestURL() {
return rewriteURL(super.getRequestURL());
}

@Override
public final String getServletPath() {
return rewriteURL(super.getServletPath());
}

private String getPossiblyNull(final String s) {
if (s == null) {
return null;
}
return rewriteURL(s);
}

/** Subclasses can override this if they can improve efficiency by 
rewriting
 * a StringBuffer.  By default this calls the other method and creates 
a new
 * StringBuffer from the result.
 */
protected StringBuffer rewriteURL(final StringBuffer sB) {
return new StringBuffer(rewriteURL(sB.toString()));
}

protected abstract String rewriteURL(final String url);

@Override
public String toString() {
return super.toString() +  wrapping  + 
getRequest().toString();
}

}
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Caching static content - Bug in Filter implementation?

2005-07-07 Thread juergen . dufner
Hello

I do some further analysis in this problem and got following result:

Precondition: The filter manipulates the HTTP header when returning a
static resource (e.g. image).

HTTP 200
In case of a HTTP 200 (OK) result the header is not added when the doFilter
method is like following:

filterChain.doFilter(request, response);
response.setHeader(name, value);


In contrast to it works when the code is like following:

response.setHeader(name, value);
filterChain.doFilter(request, response);


In other words: When returning a HTTP 200 (OK) I must set the header before
forwarding the request to the next filter.

HTTP 304
In this case it doesn't mention whether setting the header is before or
after forwarding the request.

Any comments?

Jürgen Dufner


-
Diese E-Mail enthaelt vertrauliche oder rechtlich geschuetzte
Informationen.
Wenn Sie nicht der beabsichtigte Empfaenger sind, informieren Sie bitte
sofort den Absender und loeschen Sie diese E-Mail. Das unbefugte
Kopieren
dieser E-Mail oder die unbefugte Weitergabe der enthaltenen
Informationen
ist nicht gestattet.

The information contained in this message is confidential or protected
by
law. If you are not the intended recipient, please contact the sender
and
delete this message. Any unauthorised copying of this message or 
unauthorised distribution of the information contained herein is
prohibited.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Caching static content - Bug in Filter implementation?

2005-07-07 Thread Jon Wingfield
I think that's expected behaviour: You can't set headers after the 
response has been committed (more body data has been written to the 
outputstream than the buffer size).


In the case of the 200 response code the call to 
filterChain.doFilter(...) actually serves the content. Setting of the 
header after this is too late.


Jon

[EMAIL PROTECTED] wrote:

Hello

I do some further analysis in this problem and got following result:

Precondition: The filter manipulates the HTTP header when returning a
static resource (e.g. image).

HTTP 200
In case of a HTTP 200 (OK) result the header is not added when the doFilter
method is like following:

filterChain.doFilter(request, response);
response.setHeader(name, value);


In contrast to it works when the code is like following:

response.setHeader(name, value);
filterChain.doFilter(request, response);


In other words: When returning a HTTP 200 (OK) I must set the header before
forwarding the request to the next filter.

HTTP 304
In this case it doesn't mention whether setting the header is before or
after forwarding the request.

Any comments?

Jürgen Dufner


-
Diese E-Mail enthaelt vertrauliche oder rechtlich geschuetzte
Informationen.
Wenn Sie nicht der beabsichtigte Empfaenger sind, informieren Sie bitte
sofort den Absender und loeschen Sie diese E-Mail. Das unbefugte
Kopieren
dieser E-Mail oder die unbefugte Weitergabe der enthaltenen
Informationen
ist nicht gestattet.

The information contained in this message is confidential or protected
by
law. If you are not the intended recipient, please contact the sender
and
delete this message. Any unauthorised copying of this message or 
unauthorised distribution of the information contained herein is

prohibited.


-
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]



Filter problem

2005-06-23 Thread Jack Lauman
I have the following code for an access filter.  If I log in with the 
role of admin everything works as expected.  If I try to log in with 
the role of user I immediately get a permissions error that denies access.


I've added ${sessionScope.USER} to the jsp pages as well as adding 
entries for PWD and ROLE.  The correct information is in the session 
variables.


I'd appreciate any help in finding the error and fixing it.

Thanks,

Jack

public class AccessControlFilter
implements Filter
{
  public static final String NO_ACCESS_PAGE = no-access-page;
  public static final String NO_AUTH_PAGE = no-auth-page;
  private FilterConfig fc;
  private String noAccessPage;
  private String notLoggedInPage;
  public AccessControlFilter()
{
  fc = null;
}

/**
 * Destroy the Access Control Filter
 */
public void destroy()
{
  fc = null;
}

/**
 * Initialize the Access Control Filter
 */
public void init(FilterConfig config)
  throws ServletException
{
  fc = config;
  noAccessPage = fc.getInitParameter(no-access-page);
  if(noAccessPage == null)
noAccessPage = noaccess.jsp;

  notLoggedInPage = fc.getInitParameter(no-auth-page);
if(notLoggedInPage == null)
notLoggedInPage = notloggedin.jsp;
}

public void doFilter(ServletRequest req,
 ServletResponse resp,
 FilterChain chain)
  throws IOException, ServletException
{
  HttpServletRequest httpReq = (HttpServletRequest)req;
  HttpServletResponse httpResp = (HttpServletResponse)resp;

  String servletPath = httpReq.getServletPath();

  String username = (String)httpReq.getSession().getAttribute(USER);
  if(username == null)
  {
httpResp.sendRedirect(notLoggedInPage);
return;
  }
String role = (String)httpReq.getSession().getAttribute(ROLE);
if(role == null)
{
  httpResp.sendRedirect(notLoggedInPage);
  return;
}
if(role.equals(admin))
{
  chain.doFilter(req, resp);
  return;
}
if(role.equals(user))
{
  if(servletPath.startsWith(/secure/updateDb/add) ||
servletPath.startsWith(/secure/updateDb/delete) ||
servletPath.startsWith(/secure/updateDb/update) ||
servletPath.startsWith(/secure/updateDb/move) ||
servletPath.equals(/secure/updateDb/sectionAdd) ||
servletPath.equals(/secure/updateDb/sectionDelete)) 
   {

Integer id = new Integer(httpReq.getParameter(company));
if(id.equals(getAuthToken(username)))
{
  chain.doFilter(req, resp);
  return;
}
} else
  if(servletPath.equals(/secure/updateDb/changePassword))
{
  if(username.equals(httpReq.getParameter(userName)))
{
  chain.doFilter(req, resp);
  return;
}
  } else
if(servletPath.equals(/secure/index.jsp))
  {
  ServletContext servletcontext = fc.getServletContext();
  RequestDispatcher requestdispatcher = 
servletcontext.getRequestDispatcher(/secure/ControlPanel.jsp?company= 
+ getAuthToken(username));

  if(requestdispatcher == null)
  httpResp.sendError(500, Ccontrol panel doesn't exist.);
  requestdispatcher.forward(req, resp);
  return;
}
} else {
httpResp.sendRedirect(notLoggedInPage);
return;
}
httpResp.sendRedirect(noAccessPage);
}

private Integer getAuthToken(String servletPath)
{
Integer id = new Integer(-1);
try
{
Context ctx = null;
DataSource ds = null;
Connection conn = null;
Result result = null;
SQLCommandBean sql = new SQLCommandBean();
try {
  String envBase = java:comp/env/;
  ctx = new InitialContext();
  String dataSourceName = (String)ctx.lookup(envBase + 
dataSource);

  ds = (DataSource) ctx.lookup(envBase + dataSourceName);

  } catch (Exception e) {
System.out.println(DataSource context lookup failed:  + e);
  }

  try {
conn = ds.getConnection();
} catch (SQLException se) {
  System.out.println(DataSource getConnection failed:  + se);
  se.printStackTrace();
}

  try {
sql.setConnection(conn);

  } catch (Exception e) {
System.out.println(DataSource setConnection failed:  + e);
  }

  sql.setSqlValue(SELECT CompanyID FROM Company WHERE UserID = 
?);

  ArrayList arraylist = new ArrayList();
  arraylist.add(servletPath);
  sql.setValues(arraylist);
  result

looking for java filter to block systematic downloading

2005-06-20 Thread Jose Blanco
I'm looking for a Java filter, designed to be used with 
Tomcat, to identify an IP address that appears to be rapidly downloading 
according to heuristics that I can setup, and block. There is a module like
this for Apache that I am working with called mod_bwshare.  Is there one for
tomcat?


Thank you!

Jose


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



newbie: invoking singlesignon from servlet filter

2005-05-30 Thread che
hi all!

is it possible to invoke a singlesignon from a servlet filter?


i'm using tomcat 4.1.24, the sso valve is up and running (successfully 
tested).

but within a special usecase i can't use security constraints in web.xml, 
as the main servlet needs to be freely accessible.
only certain parts of the application (identified by url-params) need 
authentication.

example:

if 

http://www.foobar.com/app?service=one

is requested -- no authentication required

if 

http://www.foobar.com/app?service=two

is requested -- i need to perform a singlesignon programmatically from a 
servlet filter

can someone provide some hints / code examples?

thanks,

chris


How to write a request decompressing input filter?

2005-05-18 Thread Jochen Wiedmann

Hi,

while writing an input filter, that decompresses its input, I have
encountered a problem. My filter (see complete source below) contains
roughly the following code:

  private HttpServletRequest
  getServletRequest(final HttpServletRequest pRequest) {
  String contentEncoding =
  pRequest.getHeader(Content-Encoding);
  if (!isUsingGzipEncoding(contentEncoding)) {
  return pRequest;
  }
  return new HttpServletRequestWrapper(pRequest) {
  public ServletInputStream getInputStream()
  throws IOException {
  final InputStream rin = pRequest.getInputStream();
  final InputStream in = new GZIPInputStream(rin);
  return new ServletInputStream(){
  public int read() throws IOException {
  return in.read();
  }
  public void close() throws IOException {
  in.close();
  }
  };
 }
 public BufferedReader getReader() throws IOException {
final String enc = getCharacterEncoding();
final InputStream istream = getInputStream();
final Reader r = new InputStreamReader(istream, enc);
return new BufferedReader(istream);
 }
  };
  }

This works fine in most cases, with one important exception: If the
request is using the POST method with a content type
x-www-form-urlencoded, then the following occurs:

* My Servlet invokes getParameterNames() on my request wrapper.
* The request wrapper invokes getParameterNames() on the RequestFacade.
* The request facade invokes getParameterNames() on the Request object.
* Which finally invokes getInputStream(), but not on my request wrapper,
  but on the Request object. In other words, the compressed input stream
  is read.


Any suggestions for a possible workaround?


Regards,

Jochen



package de.sag.dms.common.servlet;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;


/** pThe codeGzipFilter/code is a servlet filter, that enables use of
 * gzip compression for both incoming and outgoing data./p
 * pServlet filters can be added to arbitrary servlets. Whether they are
 * active or not, is a matter of configuration in the codeweb.xml/code
 * file. For example, to activate the gzip filter for the URI /DSIServlet,
 * you would add the following lines to web.xml:/p
 * pre
 *   lt;filtergt;
 * lt;filter-namegt;GZIPFilterlt;/filter-namegt;
 *
lt;filter-classgt;de.sag.dms.common.servlet.GzipFilterlt;/filter-classgt;
 *   lt;/filtergt;
 *
 *   lt;filter-mappinggt;
 * lt;filter-namegt;GZIPFilterlt;/filter-namegt;
 * lt;url-patterngt;/DSIServletlt;/url-patterngt;
 *   lt;/filter-mappinggt;
 * /pre
 * pNote, that the context name will always be prepended to the URI.
 * In other words, if your web application is accessible below
 * /DSI, then the actual URI for the above mapping would be
 * /DSI/DSIServlet./p
 * pIf a client wants to send compressed data, then it should
 * behave according to section 14.11 of RFC 2616: The client emmust/em
 * compress the whole body and it emmust/em set the
 * emrequest header/em * Content-Encoding to a proper value,
 * typically gzip. See
 * a href=http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html;
 * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html/a for details
 * on RFC 2616./p
 * pIf a client wants the server to reply with compressed data, then
 * it should again follow RFC 2616 and set the emrequest header/em
 * Accept-Encoding. The value will typically be a comma separated list
 * of words. The word gzip indicates, that the client would like to
 * accept gzip compressed data. For example, browsers will typically
 * send gzip, deflate./p
 * pIf the server detects, that the client wants a compressed response,
 * then it will reply by setting the emresponse header/em
 * Content-Encoding to the value gzip. Consequently, the
 * whole response body will be compressed using gzip./p
 * pTo verify, whether the filter works, do the following: Create a
 * request file /tmp/request.txt, for example like this:/p
 * pre
 * -21
 * Content

Realm and Filter question

2005-05-12 Thread Brett Parsons
Hi All,
I've implemented a custom realm and a custom servlet filter for my webapp.  
The idea
is, I want the filter to handle incoming requests for ALL resources within
the webapp while the realm is only going to handle several resources within
the webapp.

The problem is, I need the filter to be called before the realm, but this
doesn't seem to be happening.  Is there anyway to specify whether the realm
or the filter gets hit first?
For instance, right now, my request is following this order:
Realm - Filter
But I want it to follow this order:
Filter - Realm
I appreciate any help you can provide !!!
Thanks,
Brett P

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Images CSS not loaded after the request passes through a Servlet Filter

2005-04-28 Thread Roberto
Hi,

I have a small java application, in which a servlet processes the request 
and then
calls a JSP to present the data. Everything is OK with that configuration. 
Then, I decided
to create a servlet filter, to redirect every request to that application, 
to a login page first.

The code of that filter is the following:

**
public final class ApplicationFilter implements Filter {
private FilterConfig _fc = null;

public void init(FilterConfig filterConfig)
throws ServletException {
this._fc = filterConfig;
}

public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws IOException,
ServletException {

try {
RequestDispatcher rd = 
_fc.getServletContext().getRequestDispatcher(/login);
rd.forward(request, response);
} catch (Exception e) {
System.out.println(Exception:  + e.getMessage());
e.printStackTrace();
}
}

-- (the rest was intentionally omitted) --
***


The redirection works great, BUT all images and CSS referenced in the JSP 
file are not
loaded after the request passes through the filter. The application runs 
perfectly, and takes
the user to the login screen, and after that, to the application. The 
application does some
database queries and returns the data correctly. BUT, everything without 
images or the
styles defined in the CSS file. 

Just to make a test, I put the CSS file contents directly inside the JSP 
file, and it
worked great. In this case, images were not loaded also...

The process flows like this:

Request -- Filter -- login (a servlet) -- login.jsp -- queryDB (a 
servlet) -- queryDB.jsp

When I disable the filter, in the web.xml file, everything works as would be 
expected.

The configuration in web.xml is OK: all servlets are set, as is the filter 
itself.

I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and 
kernel
2.6.9. The hardware is a P IV HT 3.2 Ghz.

I also checked the archives of this list, but was unable to find any 
reference to a problem
like this one. Does anyone know what is happening ?

Regards,
Roberto


Re: Images CSS not loaded after the request passes through a Servlet Filter

2005-04-28 Thread Frank W. Zammetti
Question: are the requests for images and CSS files also going through the
filter?  I'm wondering if those requests are getting forarded to the logon
page too, which obviously wouldn't work.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Thu, April 28, 2005 1:25 pm, Roberto said:
 Hi,

 I have a small java application, in which a servlet processes the request
 and then
 calls a JSP to present the data. Everything is OK with that configuration.
 Then, I decided
 to create a servlet filter, to redirect every request to that application,
 to a login page first.

 The code of that filter is the following:

 **
 public final class ApplicationFilter implements Filter {
 private FilterConfig _fc = null;

 public void init(FilterConfig filterConfig)
 throws ServletException {
 this._fc = filterConfig;
 }

 public void doFilter(ServletRequest request,
 ServletResponse response,
 FilterChain chain)
 throws IOException,
 ServletException {

 try {
 RequestDispatcher rd =
 _fc.getServletContext().getRequestDispatcher(/login);
 rd.forward(request, response);
 } catch (Exception e) {
 System.out.println(Exception:  + e.getMessage());
 e.printStackTrace();
 }
 }

 -- (the rest was intentionally omitted) --
 ***


 The redirection works great, BUT all images and CSS referenced in the JSP
 file are not
 loaded after the request passes through the filter. The application runs
 perfectly, and takes
 the user to the login screen, and after that, to the application. The
 application does some
 database queries and returns the data correctly. BUT, everything without
 images or the
 styles defined in the CSS file.

 Just to make a test, I put the CSS file contents directly inside the JSP
 file, and it
 worked great. In this case, images were not loaded also...

 The process flows like this:

 Request -- Filter -- login (a servlet) -- login.jsp -- queryDB (a
 servlet) -- queryDB.jsp

 When I disable the filter, in the web.xml file, everything works as would
 be
 expected.

 The configuration in web.xml is OK: all servlets are set, as is the filter
 itself.

 I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and
 kernel
 2.6.9. The hardware is a P IV HT 3.2 Ghz.

 I also checked the archives of this list, but was unable to find any
 reference to a problem
 like this one. Does anyone know what is happening ?

 Regards,
 Roberto



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Images CSS not loaded after the request passes through a Servlet Filter

2005-04-28 Thread Roberto
Frank,

You got it. The filter configuration, in the web.xml file, was
intercepting ALL requests (url-pattern/*/url-pattern). I really
thought that the filter would intercept only requests for Servlets,
not all HTTP requests...

Thanks ! This problem was really pissing me off... :)

Regards
Roberto

On 4/28/05, Frank W. Zammetti [EMAIL PROTECTED] wrote:
 
 Question: are the requests for images and CSS files also going through the
 filter? I'm wondering if those requests are getting forarded to the logon
 page too, which obviously wouldn't work.
 
 --
 Frank W. Zammetti
 Founder and Chief Software Architect
 Omnytex Technologies
 http://www.omnytex.com
 
 On Thu, April 28, 2005 1:25 pm, Roberto said:
  Hi,
 
  I have a small java application, in which a servlet processes the 
 request
  and then
  calls a JSP to present the data. Everything is OK with that 
 configuration.
  Then, I decided
  to create a servlet filter, to redirect every request to that 
 application,
  to a login page first.
 
  The code of that filter is the following:
 
  **
  public final class ApplicationFilter implements Filter {
  private FilterConfig _fc = null;
 
  public void init(FilterConfig filterConfig)
  throws ServletException {
  this._fc = filterConfig;
  }
 
  public void doFilter(ServletRequest request,
  ServletResponse response,
  FilterChain chain)
  throws IOException,
  ServletException {
 
  try {
  RequestDispatcher rd =
  _fc.getServletContext().getRequestDispatcher(/login);
  rd.forward(request, response);
  } catch (Exception e) {
  System.out.println(Exception:  + e.getMessage());
  e.printStackTrace();
  }
  }
 
  -- (the rest was intentionally omitted) --
  ***
 
 
  The redirection works great, BUT all images and CSS referenced in the 
 JSP
  file are not
  loaded after the request passes through the filter. The application runs
  perfectly, and takes
  the user to the login screen, and after that, to the application. The
  application does some
  database queries and returns the data correctly. BUT, everything without
  images or the
  styles defined in the CSS file.
 
  Just to make a test, I put the CSS file contents directly inside the JSP
  file, and it
  worked great. In this case, images were not loaded also...
 
  The process flows like this:
 
  Request -- Filter -- login (a servlet) -- login.jsp -- queryDB (a
  servlet) -- queryDB.jsp
 
  When I disable the filter, in the web.xml file, everything works as 
 would
  be
  expected.
 
  The configuration in web.xml is OK: all servlets are set, as is the 
 filter
  itself.
 
  I'm using Tomcat 5.0.28 on a Gentoo Linux system, with POSIX threads and
  kernel
  2.6.9. The hardware is a P IV HT 3.2 Ghz.
 
  I also checked the archives of this list, but was unable to find any
  reference to a problem
  like this one. Does anyone know what is happening ?
 
  Regards,
  Roberto
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: IIS 6.0 with isapi_redirect.dll (jk 1.2.10) filter does not log page requests

2005-04-22 Thread Mladen Turk
Haris Papadopoulos wrote:
IIS logs do not contain any information about the page that Tomcat serves.
Instead, the following line:
2005-04-21 14:58:12 192.168.1.59 GET /jakarta/isapi_redirect.dll - 80 -
192.168.1.11
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.7.5)+Gecko/20041107+Firefox/1.0 

Like said for your bugizilla entry on that subject:
This is not a bug, but rather enchantment request.
Neither JK nor JK2 never made any attempt to log a client
request inside IIS, so this can not be a bug.
I'll see if some sort of logging can be made, but no promises :)
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


IIS 6.0 with isapi_redirect.dll (jk 1.2.10) filter does not log page requests

2005-04-22 Thread Haris Papadopoulos
IIS logs do not contain any information about the page that Tomcat serves.
Instead, the following line:
2005-04-21 14:58:12 192.168.1.59 GET /jakarta/isapi_redirect.dll - 80 -
192.168.1.11
Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.7.5)+Gecko/20041107+Firefox/1.0
- 200 0 0
appears each time a redirection occurs.
I consider it a bug since one can not obtain useful Web statistics from 
IIS logs or from Tomcat logs (static content gets logged by IIS while 
dynamic gets logged by Tomcat).
I also submitted a bug in bugzilla with ID 34577
If anyone knows a resolution or a workaround, please reply.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: ssl-forwarding filter not working in IE 6

2005-04-17 Thread sudip shrestha
Actually, I fixed the code by adding encodeRedirectURL method. 
Strange thing is Firefox does not seem to care about proper url
encoding, where as IE does.

On 4/15/05, Sng Wee Jim [EMAIL PROTECTED] wrote:
 
 Try setting the following 2 response header
 
response.setHeader(Pragma, public);
response.setHeader(Cache-Control, max-age=0);
 
 - Jim
 
 -Original Message-
 From: sudip shrestha [mailto:[EMAIL PROTECTED]
 Sent: Friday, April 15, 2005 9:54 PM
 To: Struts Users Mailing List; Tomcat Users List
 Subject: ssl-forwarding filter not working in IE 6
 
 Hi : I have following code for automatic ssl-forwarding filter:
 
 public void doFilter(ServletRequest servletrequest, ServletResponse
 servletresponse, FilterChain filterchain)
throws IOException, ServletException
{
String s = servletrequest.getScheme();
if( !s.equalsIgnoreCase(http) )
{
//System.out.println( Normal filter Operation );
filterchain.doFilter(servletrequest, servletresponse);
}
else
{
HttpServletResponse response =
 (HttpServletResponse)servletresponse;
HttpServletRequest request =
 (HttpServletRequest)servletrequest;
 
//System.out.println( currPort: +request.getServerPort()
 );
String url = https://; + request.getServerName();
//System.out.println( currUrl: +url );
url = url + : + PORT;
//System.out.println( currUrl: +url );
url = url + request.getRequestURI();
//System.out.println( currUrl: +url );
String queryStr = request.getQueryString();
if( queryStr!=null )
url = url + ? + queryStr;
//System.out.println( currUrl: +url );
response.sendRedirect(url);
return;
}
}
 
 This works perfectly in Firefox.  However, IE just sits there till it
 throws me a page cannot be displayed.  If I directly type secure
 url, e.g., https://domain.com/siteAdd, it works in IE as well, but IE
 just cannot seem to forward it to the secure url from the plain url.
 Any suggestions?
 
 
 The information in this email is confidential and is intended solely
 for the addressee(s).
 Access to this email by anyone else is unauthorized. If you are not
 an intended recipient, please notify the sender of this email
 immediately. You should not copy, use or disseminate the
 information contained in the email.
 Any views expressed in this message are those of the individual
 sender, except where the sender specifically states them to be
 the views of Capco.
 
 http://www.capco.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]



ssl-forwarding filter not working in IE 6

2005-04-15 Thread sudip shrestha
Hi : I have following code for automatic ssl-forwarding filter:

public void doFilter(ServletRequest servletrequest, ServletResponse
servletresponse, FilterChain filterchain)
throws IOException, ServletException
{
String s = servletrequest.getScheme();
if( !s.equalsIgnoreCase(http) )
{
//System.out.println( Normal filter Operation );
filterchain.doFilter(servletrequest, servletresponse);
}
else
{
HttpServletResponse response = (HttpServletResponse)servletresponse;
HttpServletRequest request = (HttpServletRequest)servletrequest;

//System.out.println( currPort: +request.getServerPort() );
String url = https://; + request.getServerName();
//System.out.println( currUrl: +url );
url = url + : + PORT;
//System.out.println( currUrl: +url );
url = url + request.getRequestURI();
//System.out.println( currUrl: +url );
String queryStr = request.getQueryString();
if( queryStr!=null )
url = url + ? + queryStr;
//System.out.println( currUrl: +url );
response.sendRedirect(url);
return;
}
}

This works perfectly in Firefox.  However, IE just sits there till it
throws me a page cannot be displayed.  If I directly type secure
url, e.g., https://domain.com/siteAdd, it works in IE as well, but IE
just cannot seem to forward it to the secure url from the plain url.
Any suggestions?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ssl-forwarding filter not working in IE 6

2005-04-15 Thread Jason Bainbridge
On 4/15/05, sudip shrestha [EMAIL PROTECTED] wrote:
 Hi : I have following code for automatic ssl-forwarding filter:

Why do it that way? Why not just add transport-guarantee's in your
web.xml and setup a redirect port for your http connector in your
server.xml?

eg. http://www.jguru.com/faq/view.jsp?EID=748030

Regards,
-- 
Jason Bainbridge
http://kde.org - [EMAIL PROTECTED]
Personal Site - http://jasonbainbridge.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ssl-forwarding filter not working in IE 6

2005-04-15 Thread sudip shrestha
Actually,
I have apache serving static pages with jk-connector integrating
services with Tomcat 5, and I did not show the full script, but I
would like to redirect to secure url to only those requests coming
from outside the company intranet.

On 4/15/05, Jason Bainbridge [EMAIL PROTECTED] wrote:
 On 4/15/05, sudip shrestha [EMAIL PROTECTED] wrote:
  Hi : I have following code for automatic ssl-forwarding filter:
 
 Why do it that way? Why not just add transport-guarantee's in your
 web.xml and setup a redirect port for your http connector in your
 server.xml?
 
 eg. http://www.jguru.com/faq/view.jsp?EID=748030
 
 Regards,
 --
 Jason Bainbridge
 http://kde.org - [EMAIL PROTECTED]
 Personal Site - http://jasonbainbridge.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ssl-forwarding filter not working in IE 6

2005-04-15 Thread sudip shrestha
But still the question remains is this some sort of bug in IE?

On 4/15/05, sudip shrestha [EMAIL PROTECTED] wrote:
 Actually,
 I have apache serving static pages with jk-connector integrating
 services with Tomcat 5, and I did not show the full script, but I
 would like to redirect to secure url to only those requests coming
 from outside the company intranet.
 
 On 4/15/05, Jason Bainbridge [EMAIL PROTECTED] wrote:
  On 4/15/05, sudip shrestha [EMAIL PROTECTED] wrote:
   Hi : I have following code for automatic ssl-forwarding filter:
 
  Why do it that way? Why not just add transport-guarantee's in your
  web.xml and setup a redirect port for your http connector in your
  server.xml?
 
  eg. http://www.jguru.com/faq/view.jsp?EID=748030
 
  Regards,
  --
  Jason Bainbridge
  http://kde.org - [EMAIL PROTECTED]
  Personal Site - http://jasonbainbridge.com
 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: ssl-forwarding filter not working in IE 6

2005-04-15 Thread sudip shrestha
I  disabled my filter and have tried this way, once again works with
Firefox but not with IE, exact same results.

On 4/15/05, Jason Bainbridge [EMAIL PROTECTED] wrote:
 On 4/15/05, sudip shrestha [EMAIL PROTECTED] wrote:
  Hi : I have following code for automatic ssl-forwarding filter:
 
 Why do it that way? Why not just add transport-guarantee's in your
 web.xml and setup a redirect port for your http connector in your
 server.xml?
 
 eg. http://www.jguru.com/faq/view.jsp?EID=748030
 
 Regards,
 --
 Jason Bainbridge
 http://kde.org - [EMAIL PROTECTED]
 Personal Site - http://jasonbainbridge.com


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: ssl-forwarding filter not working in IE 6

2005-04-15 Thread Sng Wee Jim

Try setting the following 2 response header

response.setHeader(Pragma, public);
response.setHeader(Cache-Control, max-age=0);

- Jim

-Original Message-
From: sudip shrestha [mailto:[EMAIL PROTECTED]
Sent: Friday, April 15, 2005 9:54 PM
To: Struts Users Mailing List; Tomcat Users List
Subject: ssl-forwarding filter not working in IE 6

Hi : I have following code for automatic ssl-forwarding filter:

public void doFilter(ServletRequest servletrequest, ServletResponse
servletresponse, FilterChain filterchain)
throws IOException, ServletException
{
String s = servletrequest.getScheme();
if( !s.equalsIgnoreCase(http) )
{
//System.out.println( Normal filter Operation );
filterchain.doFilter(servletrequest, servletresponse);
}
else
{
HttpServletResponse response =
(HttpServletResponse)servletresponse;
HttpServletRequest request =
(HttpServletRequest)servletrequest;
   
//System.out.println( currPort: +request.getServerPort()
);
String url = https://; + request.getServerName();
//System.out.println( currUrl: +url );
url = url + : + PORT;
//System.out.println( currUrl: +url );
url = url + request.getRequestURI();
//System.out.println( currUrl: +url );
String queryStr = request.getQueryString();
if( queryStr!=null )
url = url + ? + queryStr;
//System.out.println( currUrl: +url );
response.sendRedirect(url);
return;
}
}

This works perfectly in Firefox.  However, IE just sits there till it
throws me a page cannot be displayed.  If I directly type secure
url, e.g., https://domain.com/siteAdd, it works in IE as well, but IE
just cannot seem to forward it to the secure url from the plain url.
Any suggestions?



The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorized. If you are not
an intended recipient, please notify the sender of this email
immediately. You should not copy, use or disseminate the
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com/



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



filter mapping

2005-04-06 Thread Faine, Mark
Sorry this may be a little off-topic but is there a way to get the mapping
for a filter.  I'd like to determine what mapping set off the filter to use
it to rewrite a URL.  I know I can get the same information from the servlet
request but then I'd have to parse it and that complicates things.
 
Thanks,
-Mark
 
 

_ 

Mark Faine 
Computer Programmer III 
Administrator, Marshall Technical Reports Server 
http://trs.nis.nasa.gov http://trs.nis.nasa.gov/ 
UNITeS
256-961-1295 

This message is intended only for the use of the person(s) to whom it is
addressed. It may contain information which is privileged and confidential.
If you are not the intended recipient, please contact the sender as soon as
possible. The views expressed in this communication may not be the views
held by UNITeS or NASA. No responsibility is accepted by UNITeS or NASA for
personal emails, or emails unconnected with the company's business.

 


Filter-mapping

2005-03-24 Thread Steve Farmer
Please accept my apology for my previous inappropriately formatted
message. (At least I hope that's the reason it was ignored.) If I'm
in the wrong forum, please accept my additional apologies and direct
me to an appropriate forum. If I need to RTFM, please tell me
which FM I need to R 'cause I've studied multiple books and the
Java Servlet Spec 2.4, and I still don't understand this behavior. A
search of the web turned up some other folks who may have observed
the same behavior, but as far as I can tell they're just as confused
about it as I am.
I'm experimenting with filters in Tomcat 5.0.28 to test my
understanding. In one test I have the following
filter-mapping ...
   dispatcherERROR/dispatcher
... /filter-mapping
and I try to stimulate it with the following JSP
%@ page errorPage=/filtex-dummy.do %
${10%0} %-- throw exception --%
The servlet runs and receives the request attributes that an error
handler expects, but the filter does not run. However, if I change
ERROR to FORWARD, then both the filter and the servlet run.
JSS 2.4 seems to indicate that the filter-mapping must use
url-pattern when dispatcher has a value of ERROR, but I tried
both servlet-name and url-pattern with no apparent difference
in behavior.
My questions are
* Is this standard behavior or is it peculiar to Tomcat?
* In either case, is it possible to trigger the filter when
  dispatcher = ERROR? If so, how?
Thanks in advance and best regards,
Steve Farmer
[EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Filter-mapping

2005-03-23 Thread Steve Farmer
I've created a toy filter and servlet to experiment with filters in 
Tomcat 5.0.28. If I map the filter to the servlet like this

filter-mapping ...
 dispatcherERROR/dispatcher
... /filter-mapping
and invoke the following JSP
%@ page errorPage=/filtex-dummy.do %
${10%0} %-- throw exception --%
then the servlet executes but the filter does not. If I change the 
mapping to

filter-mapping ...
 dispatcherFORWARD/dispatcher
... /filter-mapping
then both the filter and the servlet execute.
A lengthy search seems to indicate that other folks have encountered 
this, but I can't determine whether it's a bug or just a 
misunderstanding of the standard. If it's my misunderstanding, please 
point me to an explanation of when

dispatcherERROR/dispatcher
will cause the filter to execute.
Note: the v2.4 servlet spec seems to indicate that the filter-mapping 
must use url-pattern when dispatcher has a value of ERROR, but I 
tried both servlet-name and url-pattern with no apparent difference 
in behavior.

Thanks in advance and best regards,
Steve Farmer
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


5.5.7 Filter Issue

2005-03-02 Thread Peter Johnson
Hi all,
I am including another context's servlet output however the filter that 
should be applied isn't.

e.g. seems to be doing
  context1 context2
  |--|   |--|
-- Filter -- Servlet -- Servlet |
--|
rather than
  context1 context2
  |--|   |--|
-- Filter -- Servlet -- Servlet |
---Filter -- Servlet |
Any ideas?
PJ


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: 5.5.7 Filter Issue

2005-03-02 Thread Peter Johnson
Correction it is doing
 context1 context2
 |--|   |--|
-- Filter -- Servlet -- Servlet |
-- Servlet |
Peter Johnson wrote:
Hi all,
I am including another context's servlet output however the filter 
that should be applied isn't.

e.g. seems to be doing
  context1 context2
  |--|   |--|
-- Filter -- Servlet -- Servlet |
--|
rather than
  context1 context2
  |--|   |--|
-- Filter -- Servlet -- Servlet |
---Filter -- Servlet |
Any ideas?
PJ
   
-
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: 5.5.7 Filter Issue

2005-03-02 Thread Peter Johnson
After some further logging within the filter it would appear that the 
following is happening

context1 context2
|--|   |--|
-- Filter -- Servlet -- Servlet |
 |---Filter -- Servlet ---|
 |-Filter -- Servlet -- Servlet ---|
--- Filter -- Servlet ---|
However, after the response if filtered the first time it isn't applied 
again on the second round so hence it would appear not to be being applied.

Can't see why it is doing a second round though.
Peter Johnson wrote:
Correction it is doing
 context1 context2
 |--|   |--|
-- Filter -- Servlet -- Servlet |
-- Servlet |
Peter Johnson wrote:
Hi all,
I am including another context's servlet output however the filter 
that should be applied isn't.

e.g. seems to be doing
  context1 context2
  |--|   |--|
-- Filter -- Servlet -- Servlet |
--|
rather than
  context1 context2
  |--|   |--|
-- Filter -- Servlet -- Servlet |
---Filter -- Servlet |
Any ideas?
PJ
   
-
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]


[OT] LogWatch filter for Tomcat

2005-03-01 Thread Cindy Ballreich
Has anyone written a Tomcat filter for the LogWatch log analysys tool?
http://www2.logwatch.org:81/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


AW: filter question

2005-02-24 Thread Michael Südkamp
If you need an example how to modify the response, see
http://java.sun.com/developer/EJTechTips/2002/tt0919.html#1.
If you need a good lib that let you modify your HTML, e.g. inserting a
hidden field into a form, see http://freshmeat.net/projects/jerichohtml/.

Michael


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



filter question

2005-02-23 Thread Scott Purcell
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


Re: filter question

2005-02-23 Thread Peter Davison
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

2005-02-23 Thread Andre Van Klaveren
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: Does from a filter setCharacterEncoding work for tc-5.0.27?

2005-02-03 Thread Zsolt Koppany
Thank you, but we cannot move to 5.5.4. How can I do the same with
tc-5.0.27?

Zsolt

 -Original Message-
 From: A jie [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 03, 2005 2:44 AM
 To: tomcat-user@jakarta.apache.org
 Subject: RE: Does from a filter setCharacterEncoding work for tc-5.0.27?
 
 
 
 
 
 --
  MSN:[EMAIL PROTECTED]
  QQ:29967409
 -
 
 
 
 
 From: Zsolt Koppany [EMAIL PROTECTED]
 Reply-To: Tomcat Users List tomcat-user@jakarta.apache.org
 To: 'Tomcat Users List' tomcat-user@jakarta.apache.org
 Subject: Does from a filter setCharacterEncoding work for tc-5.0.27?
 Date: Wed, 2 Feb 2005 15:33:07 +0100
 
 Hi,
 
 Does setCharacterEncoding work under tc-5.0.27 with java-1.4.2-06? To get
 UTF-8 request parameter I need to do:
 
 String par = request.getParameter(filename);
 String filename = new String(par.getBytes(ISO8859-1), UTF-8);
 
 request.setCharacterEncoding(UTF-8) doesn't seem to help from a filter.
 
 Is it my mistake?
 
 
 Zsolt Koppany
 Phone: +49-711-722 1874
 --
 Intland Software GmbH, Schulze-Delitzsch-Strasse 16
 D-70565 Stuttgart, Germany
 Phone: +49-711-722 1873, e-mail:[EMAIL PROTECTED]
 Fax: +49-711-722 1835
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 it works success under tomcat5.5.4.you should conf a web.xml
 
 _
  MSN Messenger:  http://messenger.msn.com/cn
 
 
 -
 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: Does from a filter setCharacterEncoding work for tc-5.0.27?

2005-02-03 Thread Guy Katz
i used TC 5.0.19,0.25,0.27 0.30 with a UTF-8 encoding filter (setting request 
and response encoding) and i never had any problems :) (and of course i use a 
language that cannot be represented with latin-1).

-Original Message-
From: Zsolt Koppany [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 03, 2005 11:07 AM
To: 'Tomcat Users List'
Subject: RE: Does from a filter setCharacterEncoding work for tc-5.0.27?


Thank you, but we cannot move to 5.5.4. How can I do the same with
tc-5.0.27?

Zsolt

 -Original Message-
 From: A jie [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 03, 2005 2:44 AM
 To: tomcat-user@jakarta.apache.org
 Subject: RE: Does from a filter setCharacterEncoding work for tc-5.0.27?
 
 
 
 
 
 --
  MSN:[EMAIL PROTECTED]
  QQ:29967409
 -
 
 
 
 
 From: Zsolt Koppany [EMAIL PROTECTED]
 Reply-To: Tomcat Users List tomcat-user@jakarta.apache.org
 To: 'Tomcat Users List' tomcat-user@jakarta.apache.org
 Subject: Does from a filter setCharacterEncoding work for tc-5.0.27?
 Date: Wed, 2 Feb 2005 15:33:07 +0100
 
 Hi,
 
 Does setCharacterEncoding work under tc-5.0.27 with java-1.4.2-06? To get
 UTF-8 request parameter I need to do:
 
 String par = request.getParameter(filename);
 String filename = new String(par.getBytes(ISO8859-1), UTF-8);
 
 request.setCharacterEncoding(UTF-8) doesn't seem to help from a filter.
 
 Is it my mistake?
 
 
 Zsolt Koppany
 Phone: +49-711-722 1874
 --
 Intland Software GmbH, Schulze-Delitzsch-Strasse 16
 D-70565 Stuttgart, Germany
 Phone: +49-711-722 1873, e-mail:[EMAIL PROTECTED]
 Fax: +49-711-722 1835
 
 
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 it works success under tomcat5.5.4.you should conf a web.xml
 
 _
  MSN Messenger:  http://messenger.msn.com/cn
 
 
 -
 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]



Login filter

2005-02-03 Thread Ben Bookey
Dear List,

I would like to perform an action after the user logs in to our app.
We are using the tomcat Realm security model, with an Oracle database.
So therefoer I am trying to implement a filter in Tomcat 4.1.27, which
checks for all requests on the url /j_security_check

I know my filter is initialised because I do a out.println
to a logfile. But for some reason when I do a successful login
it doesnt perform the doFilter() method, so I suspect its something
to with the mapping below.

Any hints?

regards

'===

Here is the entry to the web.xml
  filter
filter-nameLoginFilter/filter-name
descriptionPerforms pre-login and post-login 
operation/description

filter-classcom.myorg.myapp.filter.LoginFilter/filter-class
  /filter
  filter-mapping
filter-nameLoginFilter/filter-name
url-pattern/j_security_check/url-pattern
  /filter-mapping
'===
==


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Does from a filter setCharacterEncoding work for tc-5.0.27?

2005-02-03 Thread Zsolt Koppany

Here is my code. It doesn't matter what the variable encoding contains. I
didn't write it in my previous email but I don't have problems with forms (I
use struts) but with links that contain parameters encoded in UTF8.


public void doFilter(ServletRequest request,
ServletResponse response, FilterChain chain)
throws IOException,ServletException
{
dump(request, response);
   }

protected void dump(ServletRequest request, ServletResponse
response)
{
try
{
String encoding = ISO8859-1;
encoding = UTF8;
request.setCharacterEncoding(encoding);
response.setCharacterEncoding(encoding);
}
catch (UnsupportedEncodingException e)
{
log.error(e);
}
for (Enumeration en = request.getParameterNames();
 en.hasMoreElements(); )
{
String pn = (String)en.nextElement();
String pv = request.getParameter(pn);
log.debug(Parameter  + pn +  value:  + pv +
);
}
}

 -Original Message-
 From: Guy Katz [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 03, 2005 10:17 AM
 To: Tomcat Users List
 Subject: RE: Does from a filter setCharacterEncoding work for tc-5.0.27?
 
 i used TC 5.0.19,0.25,0.27 0.30 with a UTF-8 encoding filter (setting
 request and response encoding) and i never had any problems :) (and of
 course i use a language that cannot be represented with latin-1).
 
 -Original Message-
 From: Zsolt Koppany [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 03, 2005 11:07 AM
 To: 'Tomcat Users List'
 Subject: RE: Does from a filter setCharacterEncoding work for tc-5.0.27?
 
 
 Thank you, but we cannot move to 5.5.4. How can I do the same with
 tc-5.0.27?
 
 Zsolt
 
  -Original Message-
  From: A jie [mailto:[EMAIL PROTECTED]
  Sent: Thursday, February 03, 2005 2:44 AM
  To: tomcat-user@jakarta.apache.org
  Subject: RE: Does from a filter setCharacterEncoding work for tc-5.0.27?
 
 
 
 
 
  --
   MSN:[EMAIL PROTECTED]
   QQ:29967409
  -
 
 
 
 
  From: Zsolt Koppany [EMAIL PROTECTED]
  Reply-To: Tomcat Users List tomcat-user@jakarta.apache.org
  To: 'Tomcat Users List' tomcat-user@jakarta.apache.org
  Subject: Does from a filter setCharacterEncoding work for tc-5.0.27?
  Date: Wed, 2 Feb 2005 15:33:07 +0100
  
  Hi,
  
  Does setCharacterEncoding work under tc-5.0.27 with java-1.4.2-06? To
 get
  UTF-8 request parameter I need to do:
  
  String par = request.getParameter(filename);
  String filename = new String(par.getBytes(ISO8859-1), UTF-8);
  
  request.setCharacterEncoding(UTF-8) doesn't seem to help from a
 filter.
  
  Is it my mistake?
  
  
  Zsolt Koppany
  Phone: +49-711-722 1874
  --
  Intland Software GmbH, Schulze-Delitzsch-Strasse 16
  D-70565 Stuttgart, Germany
  Phone: +49-711-722 1873, e-mail:[EMAIL PROTECTED]
  Fax: +49-711-722 1835
  
  
  
  
  
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
 
  it works success under tomcat5.5.4.you should conf a web.xml
 
  _
   MSN Messenger:  http://messenger.msn.com/cn
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Login filter

2005-02-03 Thread Tim Funk
Filters cannot be run on j_security_check.
-Tim
Ben Bookey wrote:
Dear List,
I would like to perform an action after the user logs in to our app.
We are using the tomcat Realm security model, with an Oracle database.
So therefoer I am trying to implement a filter in Tomcat 4.1.27, which
checks for all requests on the url /j_security_check
I know my filter is initialised because I do a out.println
to a logfile. But for some reason when I do a successful login
it doesnt perform the doFilter() method, so I suspect its something
to with the mapping below.
Any hints?
regards
'===

Here is the entry to the web.xml
  filter
filter-nameLoginFilter/filter-name
descriptionPerforms pre-login and post-login 
operation/description

filter-classcom.myorg.myapp.filter.LoginFilter/filter-class
  /filter
  filter-mapping
filter-nameLoginFilter/filter-name
url-pattern/j_security_check/url-pattern
  /filter-mapping
'===
==

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


AW: Login filter

2005-02-03 Thread Ben Bookey
Hi Tim,

Apologies for hassling you again with this.

Any idea without getting inside of the TC source, how I can
write some code just b4 and after the user login validation into the webapp
with using the TC Realm
and j_security_check ?? or must I go inside of the source :-(

regards
Ben
p.s. I got this idea from a ibm websphere help doc, where it is possible !


-Ursprungliche Nachricht-
Von: Tim Funk [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 3. Februar 2005 12:41
An: Tomcat Users List
Betreff: Re: Login filter


Filters cannot be run on j_security_check.

-Tim

Ben Bookey wrote:

 Dear List,

 I would like to perform an action after the user logs in to our app.
 We are using the tomcat Realm security model, with an Oracle database.
 So therefoer I am trying to implement a filter in Tomcat 4.1.27, which
 checks for all requests on the url /j_security_check

 I know my filter is initialised because I do a out.println
 to a logfile. But for some reason when I do a successful login
 it doesnt perform the doFilter() method, so I suspect its something
 to with the mapping below.

 Any hints?

 regards


'===
 
 Here is the entry to the web.xml
   filter
   filter-nameLoginFilter/filter-name
   descriptionPerforms pre-login and post-login 
 operation/description
   
 filter-classcom.myorg.myapp.filter.LoginFilter/filter-class
   /filter
   filter-mapping
   filter-nameLoginFilter/filter-name
   url-pattern/j_security_check/url-pattern
   /filter-mapping

'===
 ==



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: AW: Login filter

2005-02-03 Thread Tim Funk
Your only recourse is to sse a Valve. (Which is just like a filter but tomcat 
specific)

-Tim
Ben Bookey wrote:
Hi Tim,
Apologies for hassling you again with this.
Any idea without getting inside of the TC source, how I can
write some code just b4 and after the user login validation into the webapp
with using the TC Realm
and j_security_check ?? or must I go inside of the source :-(
regards
Ben
p.s. I got this idea from a ibm websphere help doc, where it is possible !
-Ursprungliche Nachricht-
Von: Tim Funk [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 3. Februar 2005 12:41
An: Tomcat Users List
Betreff: Re: Login filter
Filters cannot be run on j_security_check.
-Tim
Ben Bookey wrote:

Dear List,
I would like to perform an action after the user logs in to our app.
We are using the tomcat Realm security model, with an Oracle database.
So therefoer I am trying to implement a filter in Tomcat 4.1.27, which
checks for all requests on the url /j_security_check
I know my filter is initialised because I do a out.println
to a logfile. But for some reason when I do a successful login
it doesnt perform the doFilter() method, so I suspect its something
to with the mapping below.
Any hints?
regards

'===

Here is the entry to the web.xml
 filter
filter-nameLoginFilter/filter-name
descriptionPerforms pre-login and post-login 
operation/description

filter-classcom.myorg.myapp.filter.LoginFilter/filter-class
 /filter
 filter-mapping
filter-nameLoginFilter/filter-name
url-pattern/j_security_check/url-pattern
 /filter-mapping
'===
==


-
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: AW: Login filter

2005-02-03 Thread Mario Winterer
Hi Ben!
You cannot hook in the login validation process without touching tomcat 
code.
But usually, this is not necessary. Just write a filter and map it to 
/ - every request will be directed to your filter - except requests to 
j_security_check. But this should not bother you, because your filter 
will be invoked right after a successful login process.
Inside your filter code, check if a certain session-attribute is set. If 
not, it is the first time after session creation that your filter is 
called. If this is the case, do whatever you intend to do and set the 
session-attribute to ensure that your code is only run once.

In pseudo-code (inside your filter's doFilter()-method):
if (request.getRemoteUser() == null) {
   // user is not logged in: clear session attribute if set
   session.removeAttribute(login);
} else if (session.getAttribute(login) == null) {
   // user is logged in but this filter has not been called since
   put your special code here
   // set the session attribute to avoid that the special code above 
is called twice:
   session.setAttribute(login, true);
}

Best regards,
 Tex
Hi Tim,
Apologies for hassling you again with this.
Any idea without getting inside of the TC source, how I can
write some code just b4 and after the user login validation into the webapp
with using the TC Realm
and j_security_check ?? or must I go inside of the source :-(
regards
Ben
p.s. I got this idea from a ibm websphere help doc, where it is possible !
-Ursprungliche Nachricht-
Von: Tim Funk [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 3. Februar 2005 12:41
An: Tomcat Users List
Betreff: Re: Login filter
Filters cannot be run on j_security_check.
-Tim
Ben Bookey wrote:
 

Dear List,
I would like to perform an action after the user logs in to our app.
We are using the tomcat Realm security model, with an Oracle database.
So therefoer I am trying to implement a filter in Tomcat 4.1.27, which
checks for all requests on the url /j_security_check
I know my filter is initialised because I do a out.println
to a logfile. But for some reason when I do a successful login
it doesnt perform the doFilter() method, so I suspect its something
to with the mapping below.
Any hints?
regards
   

'===
 


Here is the entry to the web.xml
 filter
filter-nameLoginFilter/filter-name
descriptionPerforms pre-login and post-login 
operation/description

filter-classcom.myorg.myapp.filter.LoginFilter/filter-class
 /filter
 filter-mapping
filter-nameLoginFilter/filter-name
url-pattern/j_security_check/url-pattern
 /filter-mapping
   

'===
 

==
   


-
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]


Does from a filter setCharacterEncoding work for tc-5.0.27?

2005-02-02 Thread Zsolt Koppany
Hi,

Does setCharacterEncoding work under tc-5.0.27 with java-1.4.2-06? To get
UTF-8 request parameter I need to do:

String par = request.getParameter(filename);
String filename = new String(par.getBytes(ISO8859-1), UTF-8);

request.setCharacterEncoding(UTF-8) doesn't seem to help from a filter.

Is it my mistake?


Zsolt Koppany
Phone: +49-711-722 1874
--
Intland Software GmbH, Schulze-Delitzsch-Strasse 16
D-70565 Stuttgart, Germany
Phone: +49-711-722 1873, e-mail:[EMAIL PROTECTED]
Fax: +49-711-722 1835

 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Does from a filter setCharacterEncoding work for tc-5.0.27?

2005-02-02 Thread A jie


--
MSN:[EMAIL PROTECTED]
QQ:29967409
-


From: Zsolt Koppany [EMAIL PROTECTED]
Reply-To: Tomcat Users List tomcat-user@jakarta.apache.org
To: 'Tomcat Users List' tomcat-user@jakarta.apache.org
Subject: Does from a filter setCharacterEncoding work for tc-5.0.27?
Date: Wed, 2 Feb 2005 15:33:07 +0100
Hi,
Does setCharacterEncoding work under tc-5.0.27 with java-1.4.2-06? To get
UTF-8 request parameter I need to do:
String par = request.getParameter(filename);
String filename = new String(par.getBytes(ISO8859-1), UTF-8);
request.setCharacterEncoding(UTF-8) doesn't seem to help from a filter.
Is it my mistake?
Zsolt Koppany
Phone: +49-711-722 1874
--
Intland Software GmbH, Schulze-Delitzsch-Strasse 16
D-70565 Stuttgart, Germany
Phone: +49-711-722 1873, e-mail:[EMAIL PROTECTED]
Fax: +49-711-722 1835


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
it works success under tomcat5.5.4.you should conf a web.xml
_
 MSN Messenger:  http://messenger.msn.com/cn  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: IIS 5.0 + ISAPI filter + tomcat

2005-01-24 Thread Warron French
Ramien, I have checked and found that there was a virtual directory called 
tomcat (which is what the ISAPI filter is configured with.
 
In the Vritual directory I have the following files:
isapi_redirect_1.2.5.dll
jboss-connector.reg
uriworkermap.properties
workers.properties
 
 
Here is the content of jboss-connector.reg ==
Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi 
Redirector]
 
[HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Jakarta Isapi 
Redirector\1.0]
extension_uri=/tomcat/isapi_redirect_1.2.5.dll
worker_file=C:\\jboss-3.2.3\\server\\default\\conf\\workers.properties
worker_mount_file=C:\\jboss-3.2.3\\server\\default\\conf\\uriworkermap.properties
log_file=C:\\jboss-3.2.3\\server\\default\\log\\jk_iis.log
log_level=INFO

 
 
Here is the content for uriworkermap.properties ==
/*=testWorker
/*.jsp=testWorker
/www.nticonference.org/*.jsp=testWorker
 
Here is the content of workers.properties ==
worker.list=testWorker
worker.testWorker.port=8009
worker.testWorker.host=localhost
worker.testWorker.type=ajp13
 
 
 
Thanks for your help, I really need it.
 
 
Warron French 
Sr. Network Engineer 
Xtria, LLC 
8045 Leesburg Pike #400 
Vienna, VA 22182 
Desk: 703-821-6110 
Main: 703-821-6000 
Fax:  703-827-0374 

-Original Message-
From: Ramien E. Rosillo G. [mailto:[EMAIL PROTECTED]
Sent: Monday, January 24, 2005 8:51 AM
To: Warron French
Subject: Re: IIS 5.0 + ISAPI filter + tomcat



Hi warron, did u check the for the isapi_redirect.dll in your jakarta (virtual 
site in the IIS) ?, after that you have to set up the wrokers.properties file 
in the Tomcat directory and the uriworkermap.properties.

Tell me if you have  done this, if not I can give you a paper that I found on 
the Internet with the instructions for right configuration of the IIS 
redirection.

Good luck.
Ramien Rosillo.-





[EMAIL PROTECTED]
IIS 5.0 + ISAPI filter + tomcat
Is this an appropriate list to send my questions for IIS 5.0 ISAPI filters and

 tomcat?  Running on a Windows 2000 Terminal Server?



I am having problems with controlling the redirection of a website.



http://www.acf.hhs.gov/programs/core/hsrc/



However, I was asked to change this the headstart website to redirect to this

 site instead, 

http://www.acf.hhs.gov/programs/opre/hsrc/



Well, I went into IIS and looked up the site's configuration, clicked on the

 Home Directory tab and set the radial option from Directory on this system to

 URL redirection because I thought this was the correct way.



http://www.acf.hhs.gov/programs/opre/hsrc/ that

 link BACK to the headstartresearchconf.net... but as you would expect since I

 chose the radial option URL redirection the site simply loops back.



http://www.acf.hhs.gov/programs/opre/hsrc/ 
http://www.acf.hhs.gov/programs/core/hsrc/. 
http://www.acf.hhs.gov/programs/core/hsrc/ 



http://www.acf.hhs.gov/programs/opre/hsrc/, but then the links on that site

 can't make it to the headstartresearchconf.net references they are trying to

 reach... because I removed the ISAPI filter named tomcat.



I really need to fix this mess, because it is a heavily used site.









http://www.acf.hhs.gov/programs/core/hsrc/  with the ISAPI filter in place, but

 I don't know what is generating the URL redirection.  Could it be a jsp, I

 honestly don't know because I am not a java developer.





If anyone could help me or guide me through this process it would be greatly

 appreciated.





Warron French

Sr. Network Engineer

Xtria, LLC





-

To unsubscribe, e-mail: [EMAIL PROTECTED]

For additional commands, e-mail: [EMAIL PROTECTED]
  _  

Walla! Mail - get your free 1G mail  http://www.walla.com today



Re: RE: IIS 5.0 + ISAPI filter + tomcat

2005-01-24 Thread bounce
Geachte relatie,

Het door u gebruikte e-mailadres is niet meer actief. U kunt uw e-mailbericht 
sturen naar [EMAIL PROTECTED] of dit bericht beantwoorden.

Bedankt voor uw medewerking,

Met vriendelijke groet,

ATP Hypotheken
Het Spoor 40
3994 AK Houten

Tel. 030 750 25 33
Fax. 030 750 25 88
[EMAIL PROTECTED]

 -- DIT IS EEN AUTOMATISCH GEGENEREERD E-MAILBERICHT --



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: RE: IIS 5.0 + ISAPI filter + tomcat

2005-01-24 Thread Warron French
Sorry, I dont remember Dutch anymore.  Please reply in English.


Warron French
Sr. Network Engineer
Xtria, LLC
8045 Leesburg Pike #400
Vienna, VA 22182
Desk: 703-821-6110
Main: 703-821-6000
Fax:  703-827-0374


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, January 24, 2005 10:25 AM
To: tomcat-user@jakarta.apache.org
Subject: Re: RE: IIS 5.0 + ISAPI filter + tomcat


Geachte relatie,

Het door u gebruikte e-mailadres is niet meer actief. U kunt uw e-mailbericht 
sturen naar [EMAIL PROTECTED] of dit bericht beantwoorden.

Bedankt voor uw medewerking,

Met vriendelijke groet,

ATP Hypotheken
Het Spoor 40
3994 AK Houten

Tel. 030 750 25 33
Fax. 030 750 25 88
[EMAIL PROTECTED]

 -- DIT IS EEN AUTOMATISCH GEGENEREERD E-MAILBERICHT --



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: RE: RE: IIS 5.0 + ISAPI filter + tomcat

2005-01-24 Thread bounce
Geachte relatie,

Het door u gebruikte e-mailadres is niet meer actief. U kunt uw e-mailbericht 
sturen naar [EMAIL PROTECTED] of dit bericht beantwoorden.

Bedankt voor uw medewerking,

Met vriendelijke groet,

ATP Hypotheken
Het Spoor 40
3994 AK Houten

Tel. 030 750 25 33
Fax. 030 750 25 88
[EMAIL PROTECTED]

 -- DIT IS EEN AUTOMATISCH GEGENEREERD E-MAILBERICHT --



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



IIS 5.0 + ISAPI filter + tomcat

2005-01-21 Thread Warron French
Is this an appropriate list to send my questions for IIS 5.0 ISAPI filters and 
tomcat?  Running on a Windows 2000 Terminal Server?

I am having problems with controlling the redirection of a website.

In the configuration that has been in place for over a year (let's say) the URL 
headstartresearchconf.net (and the www as well) redirects to this URL=  
http://www.acf.hhs.gov/programs/core/hsrc/

However, I was asked to change this the headstart website to redirect to this 
site instead, 
URL= http://www.acf.hhs.gov/programs/opre/hsrc/

Well, I went into IIS and looked up the site's configuration, clicked on the 
Home Directory tab and set the radial option from Directory on this system to 
URL redirection because I thought this was the correct way.

Well, my redirection goes to the new site as we want.  However, unbenounced to 
me there are links on the site http://www.acf.hhs.gov/programs/opre/hsrc/ that 
link BACK to the headstartresearchconf.net... but as you would expect since I 
chose the radial option URL redirection the site simply loops back.

So, if I remove the radial option and set it back to Use directory on this 
system I don't redirect to http://www.acf.hhs.gov/programs/opre/hsrc/ I 
redirect to http://www.acf.hhs.gov/programs/core/hsrc/.

When however, I remove the ISAPI filter called tomcat which is basically the 
isapi_redirect_1.2.5.dll I can get my redirection to go to the site 
http://www.acf.hhs.gov/programs/opre/hsrc/, but then the links on that site 
can't make it to the headstartresearchconf.net references they are trying to 
reach... because I removed the ISAPI filter named tomcat.

I really need to fix this mess, because it is a heavily used site.




My first thought is to change the page that is redirecting to 
http://www.acf.hhs.gov/programs/core/hsrc/  with the ISAPI filter in place, but 
I don't know what is generating the URL redirection.  Could it be a jsp, I 
honestly don't know because I am not a java developer.


If anyone could help me or guide me through this process it would be greatly 
appreciated.


Warron French
Sr. Network Engineer
Xtria, LLC


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Handling Exceptions thrown from a Filter

2005-01-18 Thread Wendy Smoak
If a ServletException is thrown from a Filter, is there a way to show a
nice error page?

I have put this in web.xml:

   error-page
  exception-typejavax.servlet.ServletException/exception-type
  location/WEB-INF/jsp/exceptionServlet.jsp/location
   /error-page

which I thought was the way to do it (I've also tried JSP's directly in the
root of the webapp in case the WEB-INF part was causing trouble) but I still
get an HTTP Status 500 and stack trace when a ServletException is thrown.

What am I doing wrong?

Thanks,
Wendy Smoak


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Handling Exceptions thrown from a Filter

2005-01-18 Thread Larry Meadors
is this before or after the call to the filter chain?


On Tue, 18 Jan 2005 15:51:01 -0700, Wendy Smoak [EMAIL PROTECTED] wrote:
 If a ServletException is thrown from a Filter, is there a way to show a
 nice error page?
 
 I have put this in web.xml:
 
error-page
   exception-typejavax.servlet.ServletException/exception-type
   location/WEB-INF/jsp/exceptionServlet.jsp/location
/error-page
 
 which I thought was the way to do it (I've also tried JSP's directly in the
 root of the webapp in case the WEB-INF part was causing trouble) but I still
 get an HTTP Status 500 and stack trace when a ServletException is thrown.
 
 What am I doing wrong?
 
 Thanks,
 Wendy Smoak
 
 -
 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: Handling Exceptions thrown from a Filter

2005-01-18 Thread Wendy Smoak
From: Larry Meadors [EMAIL PROTECTED]

 On Tue, 18 Jan 2005 15:51:01 -0700, Wendy Smoak [EMAIL PROTECTED]
wrote:
  If a ServletException is thrown from a Filter, is there a way to show a
  nice error page?

 is this before or after the call to the filter chain?

The exception is thrown before I call

chain.doFilter( request, response );

Thanks,
-- 
Wendy Smoak


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Filter/...

2004-12-06 Thread Shapira, Yoav

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]



Filter/...

2004-12-04 Thread Brij Naald
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]


RE: Filter/...

2004-12-04 Thread Freddy Villalba A.
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/...

2004-12-04 Thread Brij Naald
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/...

2004-12-04 Thread Freddy Villalba A.
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/...

2004-12-04 Thread QM
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: Q: ISAPI filter for JK 1.2.7-beta Visual C++ requirements

2004-12-01 Thread David Boyer
Thanks! That did the trick. I have the latest version of Visual Studio
.Net on another system, and it sounds like it'd be better to use to get
the full logger features.


 [EMAIL PROTECTED] 12/1/2004 1:05:19 AM 

David Boyer wrote:
 I'm attempting to build this from source, and I'm getting several
errors
 related to an undeclared identifier '__FUNCTION__'.
  
 Visual C++ 7 supports __FUNCTION__, but VC+All+ 6.0 does not.
  
 Does anyone know if this is an intended change in the build
 requirements, or am I just doing something wrong?
 

No it's not intended. I don't use VC6 for years :)

Just replace the line in jk_logger.h
from:
#if defined(__GNUC__) || defined(_MSC_VER)
with:
#if defined(__GNUC__) || (defined(_MSC_VER)  (_MSC_VER  1200))

The logger will have less features, but it'll compile.

MT.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Q: ISAPI filter for JK 1.2.7-beta Visual C++ requirements

2004-12-01 Thread Mladen Turk
David Boyer wrote:
Thanks! That did the trick. I have the latest version of Visual Studio
.Net on another system, and it sounds like it'd be better to use to get
the full logger features.
Yes.
I think that VC6 has done it's part of the job.
One tip...
You can use VC6 and download free vctoolkit from
http://msdn.microsoft.com/visualc/vctoolkit2003
It'll do the trick too.
MT.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Q: ISAPI filter for JK 1.2.7-beta Visual C++ requirements

2004-11-30 Thread David Boyer
I'm attempting to build this from source, and I'm getting several errors
related to an undeclared identifier '__FUNCTION__'.
 
Visual C++ 7 supports __FUNCTION__, but VC++ 6.0 does not.
 
Does anyone know if this is an intended change in the build
requirements, or am I just doing something wrong?


Re: Q: ISAPI filter for JK 1.2.7-beta Visual C++ requirements

2004-11-30 Thread Mladen Turk
David Boyer wrote:
I'm attempting to build this from source, and I'm getting several errors
related to an undeclared identifier '__FUNCTION__'.
 
Visual C++ 7 supports __FUNCTION__, but VC++ 6.0 does not.
 
Does anyone know if this is an intended change in the build
requirements, or am I just doing something wrong?

No it's not intended. I don't use VC6 for years :)
Just replace the line in jk_logger.h
from:
#if defined(__GNUC__) || defined(_MSC_VER)
with:
#if defined(__GNUC__) || (defined(_MSC_VER)  (_MSC_VER  1200))
The logger will have less features, but it'll compile.
MT.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


classpath of a filter

2004-11-26 Thread Brij Naald
Hi,
i'm creating a filter which needs to know if the request is an instance of 
org.apache.catalina.connector.RequestFacade.

When executing the 'if (request instanceof RequestFacade)' the program gives 
an error for that line:

java.lang.NoClassDefFoundError: org/apache/catalina/connector/RequestFacade
I guess the RequestFacade is only in the classpath of the tomcat-server, and 
not in the one of the servlet itself.

Does anyone know how I can solve this problem?
Thanks!
_
Koop geen kat in een zak. Probeer alles 14 dagen bij jou thuis. 
http://linkstat.neckermann.de/go.mb1?benl_11294

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


How to add a request filter for TC5.5.3? It was working for TC5.0.29!

2004-11-26 Thread David Lee
Dear Folks,
 
I have a test request filter on TC5.0.29. It is defined in server.xml as
follows and it works:
 
conf\server.xml:
 
 Context path= docBase=ROOT debug=0
 Valve className=com.oreilly.tomcat.valves.BadInputFilterValve
 deny=\x00,\x04,\x08,\x0a,\x0d/
 /Context
 
How do I move this context into TC5.5.3, I tried to put it into
conf\context.xml file and I saw
the errors when I started TC5.5.3. I struggle for a while and still
don't know how to do it?
 
Thanks in advance for any help
 
David Lee


Re: How to add a request filter for TC5.5.3? It was working for TC5.0.29!

2004-11-26 Thread Bill Barker
Valves (and other custom components, like Realms) written for TC 5.0.x will 
at the very least have to be re-compiled to work for TC 5.5.x.  More likely, 
there will have to be code changes to make them work.  That's just the price 
you pay for relying on TC internals ;-).

David Lee [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Dear Folks,

I have a test request filter on TC5.0.29. It is defined in server.xml as
follows and it works:

conf\server.xml:

 Context path= docBase=ROOT debug=0
 Valve className=com.oreilly.tomcat.valves.BadInputFilterValve
 deny=\x00,\x04,\x08,\x0a,\x0d/
 /Context

How do I move this context into TC5.5.3, I tried to put it into
conf\context.xml file and I saw
the errors when I started TC5.5.3. I struggle for a while and still
don't know how to do it?

Thanks in advance for any help

David Lee




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: How to add a request filter for TC5.5.3? It was working for TC5.0.29!

2004-11-26 Thread Remy Maucherat
On Fri, 26 Nov 2004 15:14:27 -0800, David Lee [EMAIL PROTECTED] wrote:
 Dear Folks,
 
 I have a test request filter on TC5.0.29. It is defined in server.xml as
 follows and it works:
 
 conf\server.xml:
 
  Context path= docBase=ROOT debug=0
  Valve className=com.oreilly.tomcat.valves.BadInputFilterValve
  deny=\x00,\x04,\x08,\x0a,\x0d/
  /Context
 
 How do I move this context into TC5.5.3, I tried to put it into
 conf\context.xml file and I saw
 the errors when I started TC5.5.3. I struggle for a while and still
 don't know how to do it?

The Valve API was slightly changed in 5.5. This is likely what causes
the errors you see.

-- 
x
Rémy Maucherat
Developer  Consultant
JBoss Group (Europe) SàRL
x

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: How to add a request filter for TC5.5.3? It was working for TC5.0.29!

2004-11-26 Thread David Lee
Yes, It has been rewritten and recompiled, the last thing is How do I
specify the context, 
I mean move the context to TC5.5.3.

Thanks

David 

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Bill Barker
Sent: Friday, November 26, 2004 3:25 PM
To: [EMAIL PROTECTED]
Subject: Re: How to add a request filter for TC5.5.3? It was working for
TC5.0.29!

Valves (and other custom components, like Realms) written for TC 5.0.x
will at the very least have to be re-compiled to work for TC 5.5.x.
More likely, there will have to be code changes to make them work.
That's just the price you pay for relying on TC internals ;-).

David Lee [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
m...
Dear Folks,

I have a test request filter on TC5.0.29. It is defined in server.xml as
follows and it works:

conf\server.xml:

 Context path= docBase=ROOT debug=0  Valve
className=com.oreilly.tomcat.valves.BadInputFilterValve
 deny=\x00,\x04,\x08,\x0a,\x0d/
 /Context

How do I move this context into TC5.5.3, I tried to put it into
conf\context.xml file and I saw the errors when I started TC5.5.3. I
struggle for a while and still don't know how to do it?

Thanks in advance for any help

David Lee




-
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: How to add a request filter for TC5.5.3? It was working for TC5.0.29!

2004-11-26 Thread David Lee
Hi! Remy,

For TC5.5.3
I put the context in conf\context.xml as follows

!-- The contents of this file will be loaded for each web application --
Context  path= docBase=ROOT debug=0

!-- Default set of monitored resources --
WatchedResourceWEB-INF/web.xml/WatchedResource
WatchedResourceMETA-INF/context.xml/WatchedResource

!-- Uncomment this to disable session persistence across Tomcat 
restarts --
!--
Manager pathname= /
--

Valve className=com.oreilly.tomcat.valves.BadInputFilterValve
deny=\x00,\x04,\x08,\x0a,\x0d/


/Context

TC5.5.3 starts no errors, but when I accessed it http://localhost:8080, a blank 
page 
Appears. If I take out the above context, I can the page, something wrong with 
how do
I move the conf\server.xml context into the TC5.5.3 file?

David 

-Original Message-
From: Remy Maucherat [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 26, 2004 3:31 PM
To: Tomcat Users List
Subject: Re: How to add a request filter for TC5.5.3? It was working for 
TC5.0.29!

On Fri, 26 Nov 2004 15:14:27 -0800, David Lee [EMAIL PROTECTED] wrote:
 Dear Folks,
 
 I have a test request filter on TC5.0.29. It is defined in server.xml 
 as follows and it works:
 
 conf\server.xml:
 
  Context path= docBase=ROOT debug=0  Valve 
 className=com.oreilly.tomcat.valves.BadInputFilterValve
  deny=\x00,\x04,\x08,\x0a,\x0d/
  /Context
 
 How do I move this context into TC5.5.3, I tried to put it into 
 conf\context.xml file and I saw the errors when I started TC5.5.3. I 
 struggle for a while and still don't know how to do it?

The Valve API was slightly changed in 5.5. This is likely what causes the 
errors you see.

--
x
Rémy Maucherat
Developer  Consultant
JBoss Group (Europe) SàRL
x

-
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: classpath of a filter

2004-11-26 Thread Tim Funk
You'd have to let your web app also be able to use the server classloader. 
You can do this by setting server=true in the Context declaration.

That being said - whatever your trying to do is probably a very bad idea.
-Tim
Brij Naald wrote:
Hi,
i'm creating a filter which needs to know if the request is an instance 
of org.apache.catalina.connector.RequestFacade.

When executing the 'if (request instanceof RequestFacade)' the program 
gives an error for that line:

java.lang.NoClassDefFoundError: org/apache/catalina/connector/RequestFacade
I guess the RequestFacade is only in the classpath of the tomcat-server, 
and not in the one of the servlet itself.

Does anyone know how I can solve this problem?
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Filter Problem

2004-11-23 Thread Jack Lauman
I have an access control filter that is supposed to grant all access to 
users wirh the role of 'admin' and limited access to those with the role 
of  'user.  Specifically a 'user' can only manipulate the data that 
belongs to them.  It uses 'contextPath.startsWith' and the users 'id' 
(int) from the database appended to it to access their records.

If I logon as an 'admin' user it works fine.  If I login using a bad 
password it forwards to the notLoggedInPage.  It I login as a 'user' 
with a correct password it forwards to the noAccessPage.

I'm not sure what's wrong here and would appreciate any help in 
resolving this matter,

TIA,
Jack

import java.io.IOException;
import java.sql.Connection;
import java.util.ArrayList;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.jstl.sql.Result;
import javax.sql.DataSource;
import com.nwc.SQLCommandBean;
/**
*  Referenced classes of package com.nwc:
* sql : SQLCommandBean
*/
/**
* @web.filter
* name=AccessControlFilter
* display-name=JAAS Access Control Filter
* @web.filter-init-param
* name=no-access-page
* value=/restaurants/noaccess.jsp
* @web.filter-init-param
* name=no-auth-page
* value=/restaurants/notloggedin.jsp
* @web.filter-mapping
* url-pattern=/secure/*
* @version 1.17 11/21/2004
*/
public class AccessControlFilter
   implements Filter
{
  
   /**
* Comment for codeNO_ACCESS_PAGE/code
* Value: [EMAIL PROTECTED] NO_ACCESS_PAGE}
*/
   public static final String NO_ACCESS_PAGE = no-access-page;
  
   /**
* Comment for codeNO_AUTH_PAGE/code
* Value: [EMAIL PROTECTED] NO_AUTH_PAGE}
*/
   public static final String NO_AUTH_PAGE = no-auth-page;
  
   /**
* Field config
*/
   private FilterConfig fc;
  
   /**
* Field noAccessPage
*/
   private String noAccessPage;
  
   /**
* Field notLoggedInPage
*/
   private String notLoggedInPage;
  
   /**
*
*/
   public AccessControlFilter()
   {
   fc = null;
   }
  
   /**
* Initialize the Access Control Filter
*
*  (non-Javadoc)
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
   public void init(FilterConfig config)
   throws ServletException
   {
   fc = config;
   noAccessPage = fc.getInitParameter(no-access-page);
   if(noAccessPage == null)
   noAccessPage = noaccess.jsp;
  
   notLoggedInPage = fc.getInitParameter(no-auth-page);
   if(notLoggedInPage == null)
   notLoggedInPage = notloggedin.jsp;
   }
  
   /**
* Destroy the Access Control Filter
*
*  (non-Javadoc)
* @see javax.servlet.Filter#destroy()
*/
   public void destroy()
   {
   fc = null;
   }
  
   /**
* Implements javx.servlet.Filter.doFilter
*
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, 
javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
   public void doFilter(ServletRequest req,
ServletResponse resp,
FilterChain chain)
   throws IOException, ServletException
   {
   HttpServletRequest httpReq = (HttpServletRequest)req;
   HttpServletResponse httpResp = (HttpServletResponse)resp;
/   
 String contextPath = httpReq.getContextPath();
/
   String username = (String)httpReq.getSession().getAttribute(USER);
   if(username == null)
   {
   httpResp.sendRedirect(notLoggedInPage);
   return;
   }
   String role = (String)httpReq.getSession().getAttribute(ROLE);
   if(role == null)
   {
   httpResp.sendRedirect(notLoggedInPage);
   return;
   }
   if(role.equals(admin))
   {
   chain.doFilter(req, resp);
   return;
   }
   if(role.equals(user))
   {
   if(contextPath.startsWith(/secure/updateDb/add) ||
   contextPath.startsWith(/secure/updateDb/delete) ||
   contextPath.startsWith(/secure/updateDb/update) ||
   contextPath.startsWith(/secure/updateDb/move) ||
   contextPath.equals(/secure/updateDb/sectionAdd) ||
   contextPath.equals(/secure/updateDb/sectionDelete) ||
   
contextPath.startsWith(/secure/updateDb/sectionMove) ||
   contextPath.equals(/secure/updateDb/validTimes) ||
   contextPath.equals(/secure/updateDb/menuDelete) ||
   contextPath.equals(/secure/updateDb/menuAdd) ||
   contextPath.startsWith(/secure/updateDb/menuMove

Re: Filter Problem

2004-11-23 Thread Tim Funk
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

2004-11-23 Thread Jack Lauman
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

2004-11-23 Thread Tim Funk
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

2004-11-23 Thread Jack Lauman
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]


Q: valve versus filter

2004-11-17 Thread David Boyer
We're using IIS 6 with the JK2 ISAPI filter (Tomcat 5.0.28).

 
I have several filters that I'm using on almost every context in
production: an authentication filter, an access-control filter, and a
compression filter. I'd be interested in implementing these things at a
more global level rather than on a per-context level.
 
Would valves be the way to do this? I recognize that valves come into
the picture at an earlier point in the chain. I'd be interested in
hearing how other people might approach filters that are being applied
on all contexts.
 
Thanks!


RE: valve versus filter

2004-11-17 Thread Shapira, Yoav

Hi,
Valves have the advantage that you can define them (once) for an entire
Host, so they apply to all the applications on the Host.  However, they
are Tomcat-specific, unlike Filters, so their portability is limited.

The Servlet Spec provides for no way to define a Filter for multiple web
apps.  So any way you choose to proceed will be non-Portable.
Therefore, you might as well stick with your current setup.

Yoav Shapira http://www.yoavshapira.com


-Original Message-
From: David Boyer [mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 12:49 PM
To: [EMAIL PROTECTED]
Subject: Q: valve versus filter

We're using IIS 6 with the JK2 ISAPI filter (Tomcat 5.0.28).


I have several filters that I'm using on almost every context in
production: an authentication filter, an access-control filter, and a
compression filter. I'd be interested in implementing these things at a
more global level rather than on a per-context level.

Would valves be the way to do this? I recognize that valves come into
the picture at an earlier point in the chain. I'd be interested in
hearing how other people might approach filters that are being applied
on all contexts.

Thanks!



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: valve versus filter

2004-11-17 Thread Filip Hanik - Dev
filter = portable standard
valve = tomcat specific
- Original Message - 
From: David Boyer [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, November 17, 2004 11:48 AM
Subject: Q: valve versus filter


We're using IIS 6 with the JK2 ISAPI filter (Tomcat 5.0.28).

 
I have several filters that I'm using on almost every context in
production: an authentication filter, an access-control filter, and a
compression filter. I'd be interested in implementing these things at a
more global level rather than on a per-context level.
 
Would valves be the way to do this? I recognize that valves come into
the picture at an earlier point in the chain. I'd be interested in
hearing how other people might approach filters that are being applied
on all contexts.
 
Thanks!


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Filter tricks in tomcat

2004-11-09 Thread Pablo Carretero
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]  

 



Re: [FIXED] jndi realm filter problem

2004-11-09 Thread Xavier Renard
Hi,
ok it's fixed i made another realm with a new mbean-descriptor bases on 
the JNDIRealm file
from version 4.1.31 and that do the trick till an update of tomcat.
However, for those runnin 4.1.30,the main difference between file is:
  * @version $Revision: 1.19 $ $Date: 2004/08/26 21:37:21 $
---
  * @version $Revision: 1.16 $ $Date: 2003/12/12 21:31:56 $
1295c1343,1344
 String filter = roleFormat.format(new String[] { 
doRFC2254Encoding(dn), username });
---
 String filter = roleFormat.format(new String[] { dn, username });
 filter = doRFC2254Encoding(filter);

so, instead of doing an new realm,just modifying this file and rebuild 
catalina.jar should do the trick
But i guess all this is nearly historical :-)

Thank for the excellent framework
Xavier
Xavier Renard wrote:
Hi,
I'm using the Debian package of tomcat (4.1.30) with ldap auth with 
the following config:

myapplication.xml
--
Context path=/myapplication docBase=/path/2/build
Realm   className=org.apache.catalina.realm.JNDIRealm debug=99
connectionURL=ldap://localhost:389;
connectionName=uid=tomcatproxy,dc=example,dc=org
connectionPassword=tomcatpwd
roleName=cn
roleBase=ou=groups,dc=example,dc=org
roleSearch=(memberUid={1})
userBase=ou=people,dc=example,dc=org
userSearch=(uid={0})
userSubtree=true/
 /Context
I have tried it with the tar.gz of tomcat-4.1.30 and tomcat-5.0.28 and 
it works perfectly well.
However,with the debian package, my filter (rolesearch) become 
(?=undefined)

sample from log
--
conn=7 op=5 SRCH base=ou=groups,dc=example,dc=org scope=1 
filter=(?=undefined)

I have to use the debian package so i can't really change that.
However, before submitting a bug report or write a mail to the 
debian-java mailing-list,
i would like to know if someone could point me in the good direction 
to fix this,ie
where to modify this behaviour if possible or override this realm by 
an other,...

Regards
Xavier

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Filter tricks in tomcat

2004-11-09 Thread Shapira, Yoav

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

2004-11-09 Thread Peter Lin
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]



jndi realm filter problem

2004-11-08 Thread Xavier Renard
Hi,
I'm using the Debian package of tomcat (4.1.30) with ldap auth with the 
following config:

myapplication.xml
--
Context path=/myapplication docBase=/path/2/build
Realm   className=org.apache.catalina.realm.JNDIRealm debug=99
connectionURL=ldap://localhost:389;
connectionName=uid=tomcatproxy,dc=example,dc=org
connectionPassword=tomcatpwd
roleName=cn
roleBase=ou=groups,dc=example,dc=org
roleSearch=(memberUid={1})
userBase=ou=people,dc=example,dc=org
userSearch=(uid={0})
userSubtree=true/
 /Context
I have tried it with the tar.gz of tomcat-4.1.30 and tomcat-5.0.28 and 
it works perfectly well.
However,with the debian package, my filter (rolesearch) become (?=undefined)

sample from log
--
conn=7 op=5 SRCH base=ou=groups,dc=example,dc=org scope=1 
filter=(?=undefined)

I have to use the debian package so i can't really change that.
However, before submitting a bug report or write a mail to the 
debian-java mailing-list,
i would like to know if someone could point me in the good direction to 
fix this,ie
where to modify this behaviour if possible or override this realm by 
an other,...

Regards
Xavier
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Filter, HttpServletResponseWrapper, ServletOutputStream PrintWriter in Tomcat 5.x

2004-10-31 Thread Giampaolo Tomassoni
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]



Filter, HttpServletResponseWrapper, ServletOutputStream PrintWriter in Tomcat 5.x

2004-10-30 Thread Giampaolo Tomassoni
Dears,

I'm having troubles in doing a page hit counter Filter wrapping 
HttpServletResponse(s) with the purpose of obtaining the count of emitted 
bytes.

In my specialization of the HttpServletResponseWrapper I basicly catch 
getOutputStream() requests wrapping the ServletOutputStream returned by the 
Tomcat 5.x implementation to a specialized version of ServletOutputStream 
(see below). getWriter() request are catched as well returning a PrintWriter 
instance over my specialized ServletOutputStream (see below, too).

The problem is that, while this works for servlets invoking getOutputStream(), 
it doesn't for servlets (or, at least, jsp) which invoke getWriter(): no 
CounterOutputStream's byte write() methods are invoked during the jsp 
processing, the output stream received by the browser is empty with a 200 
status code.

I can't find why my code is acting this way. Do you have any clue to spare?

Finally, a cultural question. I see that the ServletOutputStream specification 
is somehow a mix between an OutputStream (infact, it extends it) and, 
basicly, a PrintWriter (it has a lot of print(), println() and string-base 
write() methods which, I guess, shouldn't be there). Does anybody know why 
ServletOutputStream is so messy? Hystorical reasons?

Thank you in advance for you attentions,

Giampaolo Tomassoni


-- code --

protected static class CounterResponseWrapper
extends HttpServletResponseWrapper {
protected interface Countable {
public int getCount();
};

protected static class CounterOutputStream
extends ServletOutputStream 
implements Countable {
public ServletOutputStream sos;

public void write(byte[] b, int off, int len)
throws IOException {
sos.write(b, off, len);
nWrittenBytes += len;
}

public void write(byte[] b)
throws IOException {
sos.write(b);
nWrittenBytes += b.length;
}

public void write(int b)
throws IOException {
sos.write(b);
nWrittenBytes++;
}

public void flush()
throws IOException
{ sos.flush(); }

public void close()
throws IOException
{ sos.close(); }


public int nWrittenBytes;

public int getCount()
{ return(nWrittenBytes); }


public CounterOutputStream(ServletOutputStream sos) {
super();
this.sos = sos;
nWrittenBytes = 0;
}
}

...

public Countablecountable = null;

public int  getCount()
{ return(countable == null ? 0 : countable.getCount()); }

public ServletOutputStream getOutputStream()
throws IOException {
if(countable != null)
// This is to accomplish servlet specifications
throw new IllegalStateException();

CounterOutputStream cos = new 
CounterOutputStream(super.getOutputStream());
countable = cos;
return(cos);
}

public PrintWriter getWriter()
throws IOException {
return(
new PrintWriter(
new OutputStreamWriter(
getOutputStream(),
getCharacterEncoding()
),
true
)
);
}

...
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Resticting Access via a Request Filter

2004-10-29 Thread Acácio Furtado Costa
HI all,

 

I have only one TomCat Application Server and I need to offer some 
Applications to the Internet and deny to others. I look for some Valves and found a 
RemoteAddrValve, but looking in the documentation, it is Setup in the SERVER.XML and 
it is valid for all host and all applications.

 

Is it possible to have the same option but only for one application ?

 

Example:

 

APP1 it is offer for all world by Internet - allow to everybody

 

APP2 it is offer only for 192.168.1.2, 192.168.2.3, etc

 

Thanks 

 

Acacio Furtado Costa
Pesquisa e Tecnologia

GIA - Magnesita S/A
*  [EMAIL PROTECTED]

 



Re: Resticting Access via a Request Filter

2004-10-29 Thread Tim Funk
Inside the Context declaration you may also declare Valves.
-Tim
Acácio Furtado Costa wrote:
HI all,
 

I have only one TomCat Application Server and I need to offer some Applications to 
the Internet and deny to others. I look for some Valves and found a RemoteAddrValve, 
but looking in the documentation, it is Setup in the SERVER.XML and it is valid for all host and 
all applications.
 

Is it possible to have the same option but only for one application ?
 

Example:
 

APP1 it is offer for all world by Internet - allow to everybody
 

APP2 it is offer only for 192.168.1.2, 192.168.2.3, etc
 
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Including Zip functionality in a filter...

2004-10-22 Thread Ben Bookey
HI Tim


// Don't worry about writing a compression filter - tomcat comes with one on
its HTTP connector.
// Or if your using apache - use mod_gzip. I here the latest IIS also has
compression support.


Thanks ALOT for the suggestion.  We are just using Tomcat 4.1 and Tomcat 5,
is this still possible.  Could you send me an example how to use the HTTP
Connector.

I would be VERY grateful..

regards

Ben


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Including Zip functionality in a filter...

2004-10-22 Thread Shapira, Yoav

Hi,

// Don't worry about writing a compression filter - tomcat comes with
one
on
its HTTP connector.

Thanks ALOT for the suggestion.  We are just using Tomcat 4.1 and
Tomcat 5,
is this still possible.  Could you send me an example how to use the
HTTP
Connector.

Look at
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/http.html, the
compression attribute is covered well.

Yoav



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: Including Zip functionality in a filter...

2004-10-22 Thread Dave Been
I looked at the docs and added to my 8080 non-SSL Connector in server.xml 
(tomcat 4.1.3) the following:

 compression=force
 compressableMimeType=text/html,text/xml,*/*

and when i send Accept-Encoding: compress, gzip, I still am not getting 
compression.
java is adding this header:  Accept: text/html,   image/gif, image/jpeg, 
*; q=.2,  */*; q=.2

any suggestions .  thanks much

Dave Been




Shapira, Yoav [EMAIL PROTECTED]
10/22/2004 08:04 AM
Please respond to Tomcat Users List
 
To: Tomcat Users List [EMAIL PROTECTED]
cc: 
Subject:RE: Including Zip functionality in a filter...



Hi,

// Don't worry about writing a compression filter - tomcat comes with
one
on
its HTTP connector.

Thanks ALOT for the suggestion.  We are just using Tomcat 4.1 and
Tomcat 5,
is this still possible.  Could you send me an example how to use the
HTTP
Connector.

Look at
http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/http.html, the
compression attribute is covered well.

Yoav



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: Including Zip functionality in a filter...

2004-10-22 Thread Shapira, Yoav

Hi,

I looked at the docs and added to my 8080 non-SSL Connector in
server.xml
(tomcat 4.1.3) the following:

 compression=force
 compressableMimeType=text/html,text/xml,*/*

Look at the docs again.  The attributes for Tomcat 4.1 and 5.x are
different.  The former doesn't have a compressableMimeTypes attribute.
Yet another reason to upgrade.

Yoav



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 question in 4.1.18, can my filter get unchunked and un zipped requests?

2004-10-22 Thread Donie Kelly
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: Including Zip functionality in a filter...

2004-10-22 Thread Dave Been
right, I checked the 4.1 docs and removed the MimeTypes attribute and it 
still doesn't compress.

So i set compression=5 to have it compress any output length  5 bytes 
be compressed.   still didn't work.
any other hints?   thanks much for your replies.

Yet another reason to upgrade
Posted this problem last week:

I tried tomcat 5 (jdk142) and 5.5 (jdk15) but our servlet doesn't return 
any output (compression disabled) from a POST (content-length always 0), 
I'm assuming we have to recompile w/the new servlet-api.jar, or we are 
having some other strange runtime problem.   this production servlet works 
on a number of web servers since 2000.   The output is persisted to a 
file, so i know that much works, just not returned to the client. nothing 
in logs.
I understand this type of queston is too open ended  to get any 
response.sorry.
Dave Been




Shapira, Yoav [EMAIL PROTECTED]
10/22/2004 09:27 AM
Please respond to Tomcat Users List
 
To: Tomcat Users List [EMAIL PROTECTED]
cc: 
Subject:RE: Including Zip functionality in a filter...



Hi,

I looked at the docs and added to my 8080 non-SSL Connector in
server.xml
(tomcat 4.1.3) the following:

 compression=force
 compressableMimeType=text/html,text/xml,*/*

Look at the docs again.  The attributes for Tomcat 4.1 and 5.x are
different.  The former doesn't have a compressableMimeTypes attribute.
Yet another reason to upgrade.

Yoav



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]




Filter question in 4.1.18, can my filter get unchunked and unzipp ed requests?

2004-10-21 Thread Donie Kelly
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 

 

Many thanks

Donie

 



Re: Filter question in 4.1.18, can my filter get unchunked and unzipped requests?

2004-10-21 Thread Bill Barker

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]



Including Zip functionality in a filter...

2004-10-20 Thread Ben Bookey


Dear list,

I have seen an example of using a filter, to Zip/compress the outgoing
request.
This for me is an exciting way of speeding up the load time for my webApp.
( For those who
dont know, most internet browsers have an integrated unzip function, so a
server can send
the client a zipped html file, with the mime type set correctly and the
browser will display the page, reducing
drastically the bandwidth)

i) Is this technique recommended at all ? could this lead to a bottleneck at
the filter ?

ii) IS this limited to html pages or graphics ? etc.

Kind regards

Ben Bookey



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Including Zip functionality in a filter...

2004-10-20 Thread Tim Funk
If your traffic is going across the internet (or a corporate WAN) - then you 
probably want to zip your output.

If your traffic is all LAN based - compression will probably not make much of 
a difference.

Don't worry about writing a compression filter - tomcat comes with one on its 
HTTP connector. Or if your using apache - use mod_gzip. I here the latest IIS 
also has compression support.

-Tim
Ben Bookey wrote:
Dear list,
I have seen an example of using a filter, to Zip/compress the outgoing
request.
This for me is an exciting way of speeding up the load time for my webApp.
( For those who
dont know, most internet browsers have an integrated unzip function, so a
server can send
the client a zipped html file, with the mime type set correctly and the
browser will display the page, reducing
drastically the bandwidth)
i) Is this technique recommended at all ? could this lead to a bottleneck at
the filter ?
ii) IS this limited to html pages or graphics ? etc.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


  1   2   3   4   5   6   7   >