tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: Valve, set/get http header attributes
Date Fri, 13 Jun 2003 14:23:01 GMT

Howdy,
Why do this in a valve (tomcat-specific) when you can do it in a Filter in a container-independent
way?

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
ServletException {
  if(req instanceof HttpServletRequest) {
    HttpServletRequest hreq = (HttpServletRequest) req;
    hreq.addHeader("test-id", "test-value");
  }

  chain.doFilter(req, res);
}

That's all you would have to do.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Oliver Wulff [mailto:oliver.wulff@zurich.ch]
>Sent: Friday, June 13, 2003 10:18 AM
>To: tomcat-user@jakarta.apache.org
>Subject: Valve, set/get http header attributes
>
>
>
>
>
>How can I read and write http header attributes in a valve. I tried the
>following inside a valve which does return false in the second call:
>
>import org.apache.catalina.HttpRequest;
>import javax.servlet.http.HttpServletRequest;
>
>...
>
>public void invoke(Request request, Response response, ValveContext
>context)
>            throws IOException, ServletException
>{
>
>      ((HttpRequest)request).addHeader("test-id", "test-value");
>      ((HttpServletRequest)request).getHeader("test-id");
>...
>}
>
>
>
>
>
>
>******************* BITTE BEACHTEN *******************
>Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
>möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
>Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
>genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
>irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter
>Ausschluss jeder Reproduktion zu zerstören und die absendende Person
>umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message