Re: Warning response header
On Tue, Mar 8, 2016 at 10:58 AM, Mark Eggerswrote: > Chris, > > On 3/8/2016 7:52 AM, Christopher Schultz wrote: > > 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 > >>> 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... > > CorsFilter > org.apache.catalina.filters.CorsFilter > > > > > cors.exposed.headers > Warning > CorsFilter > /* > > 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 ** > >>> > >>> 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;> > >>> 4.0.0 > >>> > >>> test tcTest > >>> war 1.0-SNAPSHOT > >>> > >>> tcTest Maven Webapp > >>> http://maven.apache.org > >>> > >>> org.glassfish > >>> javax.servlet 3.1.1 > >>> org.jboss.resteasy > >>> resteasy-client > >>> 3.0.11.Final > >>> > >>> ROOT > >>> > >>> > >>> ** web.xml ** > >>> > >>> > >>> >>> Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd; > > >>> > >>> Archetype Created Web > >>> Application > >>> > >>> One > >>> pkg.ServletOne > >>> > >>> One > >>> /one/* > >>> > >>> Two > >>> pkg.ServletTwo > >>> > >>> Two > >>> /two/* > >>> > >>> > >>> ** index.html ** > >>> > >>> > >>> Hello World! > >>> > >>> > >>> ** 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() } } > >>> > > > >> >> Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd; > > > > >> Should probably be: > > > >> http://xmlns.jcp.org/xml/ns/javaee; > >>
Re: Warning response header
Chris, On 3/8/2016 7:52 AM, Christopher Schultz wrote: > 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 >>>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... CorsFilter org.apache.catalina.filters.CorsFilter > cors.exposed.headers Warning CorsFilter /* 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 ** >>> >>> 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;> >>> 4.0.0 >>> >>> test tcTest >>> war 1.0-SNAPSHOT >>> >>> tcTest Maven Webapp >>> http://maven.apache.org >>> >>> org.glassfish >>> javax.servlet 3.1.1 >>> org.jboss.resteasy >>> resteasy-client >>> 3.0.11.Final >>> >>> ROOT >>> >>> >>> ** web.xml ** >>> >>> >>> >> Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd; > >>> >>> Archetype Created Web >>> Application >>> >>> One >>> pkg.ServletOne >>> >>> One >>> /one/* >>> >>> Two >>> pkg.ServletTwo >>> >>> Two >>> /two/* >>> >>> >>> ** index.html ** >>> >>> >>> Hello World! >>> >>> >>> ** 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() } } >>> > >> > Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd; > > >> Should probably be: > >> 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
Re: Warning response header
-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 >>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... >>> >>> CorsFilter >>> org.apache.catalina.filters.CorsFilter >>> >>> >>> cors.exposed.headers >>> Warning >>> CorsFilter >>> /* >>> >>> 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 ** >> >> 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;> >> 4.0.0 >> >> test tcTest >> war 1.0-SNAPSHOT >> >> tcTest Maven Webapp >> http://maven.apache.org >> >> org.glassfish >> javax.servlet 3.1.1 >> org.jboss.resteasy >> resteasy-client >> 3.0.11.Final >> >> ROOT >> >> >> ** web.xml ** >> >> >> > Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd; > >> >> Archetype Created Web >> Application >> >> One >> pkg.ServletOne >> >> One >> /one/* >> >> Two >> pkg.ServletTwo >> >> Two >> /two/* >> >> >> ** index.html ** >> >> >> Hello World! >> >> >> ** 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() } } >> > > Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd; > > > Should probably be: > > 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
Re: Warning response header
On Mon, Mar 7, 2016 at 5:48 PM, Sean Dawsonwrote: > > > On Mon, Mar 7, 2016 at 5:44 PM, David Kerber wrote: > >> On 3/7/2016 5:11 PM, Sean Dawson wrote: >> >>> On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawson >>> 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... CorsFilter org.apache.catalina.filters.CorsFilter cors.exposed.headers Warning CorsFilter /* 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/apache-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 ** >>> >>> 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;> >>> 4.0.0 >>> >>> test >>> tcTest >>> war >>> 1.0-SNAPSHOT >>> >>> tcTest Maven Webapp >>> http://maven.apache.org >>> >>> >>> >>> org.glassfish >>> javax.servlet >>> 3.1.1 >>> >>> >>> org.jboss.resteasy >>> resteasy-client >>> 3.0.11.Final >>> >>> >>> >> >> If you're adding Maven, Glassfish and JBoss, you're adding a LOT of >> complexity to your "simple" reproducible! I've never used any of them, so >> would have no hope of reproducing your issue. And there's a fair chance >> that it has nothing to do with Tomcat anyway, given all the other stuff >> around it... >> >> > I could remove JBoss from the equation - and maven, although I'm pretty > sure that's not adding much complexity. If I run it on jetty instead of > tomcat, it works fine. So I'm leaning toward Tomcat (or something extra I > need to do for Tomcat) as the issue. > > Ok using httpclient instead of RestEasy shows the header. Strange that RestEasy passes headers in the Jetty case but not the Tomcat one. But I'll see if I can get help from them. Thanks. >> >> >>> >>> ROOT >>> >>> >>> >>> >>> ** web.xml ** >>> >>> >>> >> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" >>> "http://java.sun.com/dtd/web-app_2_3.dtd; > >>> >>> >>> Archetype Created Web Application >>> >>> >>> One >>> pkg.ServletOne >>> >>> >>> >>> One >>> /one/* >>> >>> >>> >>> Two >>> pkg.ServletTwo >>> >>> >>> >>> Two >>> /two/* >>> >>> >>> >>> >>> ** index.html ** >>> >>> >>> >>> >>> Hello World! >>> >>> >>> >>> >>> ** 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
Re: Warning response header
On Mon, Mar 7, 2016 at 5:44 PM, David Kerberwrote: > On 3/7/2016 5:11 PM, Sean Dawson wrote: > >> On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawson >> 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... >>> >>> >>> CorsFilter >>> >>> org.apache.catalina.filters.CorsFilter >>> >>> cors.exposed.headers >>> Warning >>> >>> >>> >>> CorsFilter >>> /* >>> >>> >>> 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/apache-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 ** >> >> 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;> >> 4.0.0 >> >> test >> tcTest >> war >> 1.0-SNAPSHOT >> >> tcTest Maven Webapp >> http://maven.apache.org >> >> >> >> org.glassfish >> javax.servlet >> 3.1.1 >> >> >> org.jboss.resteasy >> resteasy-client >> 3.0.11.Final >> >> >> > > If you're adding Maven, Glassfish and JBoss, you're adding a LOT of > complexity to your "simple" reproducible! I've never used any of them, so > would have no hope of reproducing your issue. And there's a fair chance > that it has nothing to do with Tomcat anyway, given all the other stuff > around it... > > I could remove JBoss from the equation - and maven, although I'm pretty sure that's not adding much complexity. If I run it on jetty instead of tomcat, it works fine. So I'm leaning toward Tomcat (or something extra I need to do for Tomcat) as the issue. > > >> >> ROOT >> >> >> >> >> ** web.xml ** >> >> >> > "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" >> "http://java.sun.com/dtd/web-app_2_3.dtd; > >> >> >> Archetype Created Web Application >> >> >> One >> pkg.ServletOne >> >> >> >> One >> /one/* >> >> >> >> Two >> pkg.ServletTwo >> >> >> >> Two >> /two/* >> >> >> >> >> ** index.html ** >> >> >> >> >> Hello World! >> >> >> >> >> ** 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
Re: Warning response header
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> 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... >> >> >> CorsFilter >> org.apache.catalina.filters.CorsFilter >> >> cors.exposed.headers >> Warning >> >> >> >> CorsFilter >> /* >> >> >> 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/apache-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 ** > > 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;> > 4.0.0 > > test > tcTest > war > 1.0-SNAPSHOT > > tcTest Maven Webapp > http://maven.apache.org > > > > org.glassfish > javax.servlet > 3.1.1 > > > org.jboss.resteasy > resteasy-client > 3.0.11.Final > > > > > ROOT > > > > > ** web.xml ** > > > "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd; > > > > Archetype Created Web Application > > > One > pkg.ServletOne > > > > One > /one/* > > > > Two > pkg.ServletTwo > > > > Two > /two/* > > > > > ** index.html ** > > > > > Hello World! > > > > > ** 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() > } > } > http://java.sun.com/dtd/web-app_2_3.dtd; > Should probably be: 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. . . .
Re: Warning response header
ublic 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() > > } > > } > > > > > org.glassfish > javax.servlet > 3.1.1 > > > This is wrong and will include the servlet API in your WAR file. > > Thanks for your reply Mark. Minor oversight. I added provided to the servlet dependency and tried it again - same result (ie. no Warning response header). These are all I see: 1. HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Length: 6 Date: Mon, 07 Mar 2016 22:43:00 GMT I didn't use cors in this example, but it's the same result as the larger app with cors in the web.xml for both tomcat and the webapp. You at least need: > > > org.glassfish > javax.servlet > 3.1.1 > provided > > > I actually use the following in my Jersey applications: > > 2.22.1 > 1.7 > 3.1.0 > UTF-8 > > > > > javax.servlet > javax.servlet-api > ${version.servlet.api} > provided > > > javax.servlet.jsp > javax.servlet.jsp-api > 2.3.0 > provided > > > > javax.servlet.jsp.jstl > javax.servlet.jsp.jstl-api > 1.2.1 > > > > javax.servlet > servlet-api > > > javax.servlet.jsp > jsp-api > > > > > > org.apache.taglibs > taglibs-standard-impl > 1.2.5 > > > > I don't know if this will help solve your problem, but getting the > servlet api out of your WAR file is a good start. > > . . . just my two cents > /mde/ > >
Re: Warning response header
On 3/7/2016 5:11 PM, Sean Dawson wrote: On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawsonwrote: 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... CorsFilter org.apache.catalina.filters.CorsFilter cors.exposed.headers Warning CorsFilter /* 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/apache-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 ** 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;> 4.0.0 test tcTest war 1.0-SNAPSHOT tcTest Maven Webapp http://maven.apache.org org.glassfish javax.servlet 3.1.1 org.jboss.resteasy resteasy-client 3.0.11.Final If you're adding Maven, Glassfish and JBoss, you're adding a LOT of complexity to your "simple" reproducible! I've never used any of them, so would have no hope of reproducing your issue. And there's a fair chance that it has nothing to do with Tomcat anyway, given all the other stuff around it... ROOT ** web.xml ** http://java.sun.com/dtd/web-app_2_3.dtd; > Archetype Created Web Application One pkg.ServletOne One /one/* Two pkg.ServletTwo Two /two/* ** index.html ** Hello World! ** 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() } } - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Warning response header
Sean, See comment at the end. On 3/7/2016 2:11 PM, Sean Dawson wrote: > On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawson> 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... >> >> >> CorsFilter >> org.apache.catalina.filters.CorsFilter >> >> cors.exposed.headers >> Warning >> >> >> >> CorsFilter >> /* >> >> >> 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/apache-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 ** > > 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;> > 4.0.0 > > test > tcTest > war > 1.0-SNAPSHOT > > tcTest Maven Webapp > http://maven.apache.org > > > > org.glassfish > javax.servlet > 3.1.1 > > > org.jboss.resteasy > resteasy-client > 3.0.11.Final > > > > > ROOT > > > > > ** web.xml ** > > > "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" > "http://java.sun.com/dtd/web-app_2_3.dtd; > > > > Archetype Created Web Application > > > One > pkg.ServletOne > > > > One > /one/* > > > > Two > pkg.ServletTwo > > > > Two > /two/* > > > > > ** index.html ** > > > > > Hello World! > > > > > ** 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() > } > } > org.glassfish javax.servlet 3.1.1 This is wrong and will include the servlet API in your WAR file. You at least need: org.glassfish javax.servlet 3.1.1 provided I actually use the following in my Jersey applications: 2.22.1 1.7 3.1.0 UTF-8 javax.servlet javax.servlet-api ${version.servlet.api} provided
Re: Warning response header
On Sun, Mar 6, 2016 at 12:48 PM, Sean Dawsonwrote: > > 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... > > > CorsFilter > org.apache.catalina.filters.CorsFilter > > cors.exposed.headers > Warning > > > > CorsFilter > /* > > > 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/apache-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 ** 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;> 4.0.0 test tcTest war 1.0-SNAPSHOT tcTest Maven Webapp http://maven.apache.org org.glassfish javax.servlet 3.1.1 org.jboss.resteasy resteasy-client 3.0.11.Final ROOT ** web.xml ** http://java.sun.com/dtd/web-app_2_3.dtd; > Archetype Created Web Application One pkg.ServletOne One /one/* Two pkg.ServletTwo Two /two/* ** index.html ** Hello World! ** 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() } }
Warning response header
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... CorsFilter org.apache.catalina.filters.CorsFilter cors.exposed.headers Warning CorsFilter /* Also tried cors.allowed.headers. Any pointers?