-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mark,

On 3/7/16 5:47 PM, Mark Eggers wrote:
> Sean,
> 
> I just noticed something else:
> 
> On 3/7/2016 2:11 PM, Sean Dawson wrote:
>> On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawson
>> <seandawson2...@gmail.com> wrote:
>> 
>>> 
>>> Tomcat 8_32 Windows 7 Java 8_51 RestEasy 3.0.11.Final GWT 2.7.0
>>> (Jetty jetty-9.3.5.v20151012)
>>> 
>>> Servlet code makes a RestEasy call to another servlet (same
>>> container) - second servlet sets the 'Warning' HTTP header on
>>> response.  Would like to access that in first servlet but when
>>> running in Tomcat, that header is not included.
>>> 
>>> Code to get header in first servlet:
>>> 
>>> Object headers = ((ClientResponseFailure) 
>>> e).getResponse().getResponseHeaders().get("Warning");
>>> 
>>> Also tried: getHeaders(), getStringHeaders(), and
>>> getHeaderString().
>>> 
>>> When running GWT in superdev mode in IntelliJ (15.0.4) using
>>> Jetty, the above returns a List with one item that contains the
>>> warning string.  When remote debugging Tomcat, that call
>>> returns null.
>>> 
>>> Added this to web app xml, and also tried Tomcat
>>> conf/web.xml...
>>> 
>>> <filter> <filter-name>CorsFilter</filter-name> 
>>> <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
>>>
>>> 
<init-param>
>>> <param-name>cors.exposed.headers</param-name> 
>>> <param-value>Warning</param-value> </init-param> </filter> 
>>> <filter-mapping> <filter-name>CorsFilter</filter-name> 
>>> <url-pattern>/*</url-pattern> </filter-mapping>
>>> 
>>> Also tried cors.allowed.headers.
>>> 
>>> Any pointers?
>>> 
>>> 
>> 
>> Alright, lets try this again.  Simple reproducible testcase...
>> 
>> - download latest Tomcat 8 for Windows 64-bit zip 
>> http://mirrors.ocf.berkeley.edu/apache/tomcat/tomcat-8/v8.0.32/bin/ap
ache-tomcat-8.0.32-windows-x64.zip
>>
>> 
- - extract somewhere
>> - delete everything in webapps folder - build project below, put
>> in webapps folder - go to: http://localhost:8080/one - check
>> response headers... no Warning header
>> 
>> ** pom.xml **
>> 
>> <project xmlns="http://maven.apache.org/POM/4.0.0"; 
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
>> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
>> http://maven.apache.org/maven-v4_0_0.xsd";> 
>> <modelVersion>4.0.0</modelVersion>
>> 
>> <groupId>test</groupId> <artifactId>tcTest</artifactId> 
>> <packaging>war</packaging> <version>1.0-SNAPSHOT</version>
>> 
>> <name>tcTest Maven Webapp</name> 
>> <url>http://maven.apache.org</url>
>> 
>> <dependencies> <dependency> <groupId>org.glassfish</groupId> 
>> <artifactId>javax.servlet</artifactId> <version>3.1.1</version> 
>> </dependency> <dependency> <groupId>org.jboss.resteasy</groupId> 
>> <artifactId>resteasy-client</artifactId> 
>> <version>3.0.11.Final</version> </dependency> </dependencies>
>> 
>> <build> <finalName>ROOT</finalName> </build> </project>
>> 
>> 
>> ** web.xml **
>> 
>> 
>> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
>> Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"; >
>> 
>> <web-app> <display-name>Archetype Created Web
>> Application</display-name>
>> 
>> <servlet> <servlet-name>One</servlet-name> 
>> <servlet-class>pkg.ServletOne</servlet-class> </servlet>
>> 
>> <servlet-mapping> <servlet-name>One</servlet-name> 
>> <url-pattern>/one/*</url-pattern> </servlet-mapping>
>> 
>> <servlet> <servlet-name>Two</servlet-name> 
>> <servlet-class>pkg.ServletTwo</servlet-class> </servlet>
>> 
>> <servlet-mapping> <servlet-name>Two</servlet-name> 
>> <url-pattern>/two/*</url-pattern> </servlet-mapping> </web-app>
>> 
>> 
>> ** index.html **
>> 
>> 
>> <html> <body> <h2>Hello World!</h2> </body> </html>
>> 
>> 
>> ** Caller interface **
>> 
>> 
>> package pkg;
>> 
>> import javax.ws.rs.GET; import javax.ws.rs.Path;
>> 
>> public interface Caller { @GET @Path("two") String makeCall(); }
>> 
>> 
>> 
>> ** Servlet one **
>> 
>> 
>> package pkg;
>> 
>> import java.io.IOException;
>> 
>> import javax.servlet.ServletException; import
>> javax.servlet.http.HttpServlet; import
>> javax.servlet.http.HttpServletRequest; import
>> javax.servlet.http.HttpServletResponse; import
>> javax.ws.rs.core.MediaType;
>> 
>> import org.jboss.resteasy.client.ProxyBuilder;
>> 
>> public class ServletOne extends HttpServlet { Caller caller;
>> 
>> @Override public void init() throws ServletException { caller =
>> ProxyBuilder.build(Caller.class, "http://localhost:8080";).now(); 
>> }
>> 
>> @Override protected void doGet(HttpServletRequest request, 
>> HttpServletResponse response) throws ServletException,
>> IOException { String result = caller.makeCall(); 
>> response.getWriter().println(result); } }
>> 
>> 
>> ** Servlet two **
>> 
>> 
>> package pkg;
>> 
>> import java.io.IOException;
>> 
>> import javax.servlet.ServletException; import
>> javax.servlet.http.HttpServlet; import
>> javax.servlet.http.HttpServletRequest; import
>> javax.servlet.http.HttpServletResponse;
>> 
>> public class ServletTwo extends HttpServlet { @Override protected
>> void doGet(HttpServletRequest request, HttpServletResponse
>> response) throws ServletException, IOException { 
>> addHeader(response); response.getWriter().println("Ok"); }
>> 
>> void addHeader(HttpServletResponse response) { 
>> response.setHeader("Warning", "This is a warning"); // also tried
>> addHeader() } }
>> 
> 
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
> Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"; >
> 
> Should probably be:
> 
> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
> http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"; version="3.1">
> 
> (sorry for the word wrapping).
> 
> I normally don't use web.xml in my 3.1 applications. I end up
> using annotations instead.

It probably doesn't matter, since the servlet EG clarified that a
container needs to behave the same regardless of the spec-version
stated in the web.xml file. (Which I think is a very stupid position
to take.)

The behavior is supposed to be whatever the highest spec-compliance
version the container supports (presumably). For example, you can use
servlet async along with a 2.3-version web.xml. More specifically, a
2.3-version web.xml will still have its classes and libraries scanned
for annotations. :(

- -chris
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlbe9VYACgkQ9CaO5/Lv0PBMCwCeJfCbp3iYB7pJkKMoCxxr1Mdc
ALMAoLPxOt/wGNhWN0KJ3mtsbm92+G1j
=mX9k
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to