Re: How to write an HTTP header (to detect cookie disablement)?
Hi Martin, Many thanks for your explanation and tip! Regards, Ian Martin Grigorov-4 wrote Hi, Headers are not cookies. By setting a header in the response you should not expect that it will come in the next request. A request header is set by the client (the browser in this case). You can use UrlConnection or Apache HttpClient to set header request which will be available thru WebRequest.getHeader(). Cookies work as you want - set it once in the response and then it will travel around in the next requests/responses until expire. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4413526.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to write an HTTP header (to detect cookie disablement)?
Hi Martin, COOKIES --- I'm fine for this. My cookie code actually works. (But if the user's browser disables cookies, then I want to use HTTP headers to be able to say The user is on his/her second page, and still no cookie, so cookies are definitely disabled (I cannot tell this on the first page).) HTTP HEADERS Many thanks for your tip about FireBug! Grand. (I had never thought about that.) All my web pages are descended from my PageBase class, which in turn descends from Wicket's WebPage. I set my HTTP header in code in my PageBase constructor using org.apache.wicket.request.http.WebResponse.addHeader(...); In the first call to the app (which shows the home page), I can see this header in the response headers using FireBug under GET PageHome?0. Sadly, I cannot detect this in my PageBase constructor using import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.http.WebRequest; RequestCycle rcRequestCycle = getRequestCycle(); WebRequest wreqRequest = (WebRequest)rcRequestCycle.getRequest(); String sHeaderValue = wreqRequest.getHeader(X-MyApp-NotFirstPageBase-1); since I get sHeaderValue to be null. Also, I cannot see this header in the request headers using FireBug. After clicking the link on my home page to the About us page, I can see this header in the response headers using FireBug under GET PageAbout?1, but nowhere else (including request headers even though I believe that I add this to each web request unconditionally). If I add org.apache.wicket.request.http.WebResponse.addHeader(...); to my PageHome's form's onSubmit() method, then after form submission I do see this header, but in the response only in POST page?1-1.IFormSubmitListener-frmForm of http://localhost:8080/wicket/page?1-1.IFormSubmitListener-frmForm (I am running locally). Am I looking in the wrong place in my code (and thus in the request cycle) to find my header in a request? Martin Grigorov-4 wrote Hi Ian, If you add/set a header in the HttpServletResponse (even thru Wicket's WebResponse) then it will be written to the browser. You can verify that by investigating the request in Firebug's Net panel. If you want to send a cookie you should either use #addCookie() or set/addHeader(Set-Cookie). Check in google for more info. So you set the cookie in the current response and if not expired it should be available in the next *request* (HttpServletRequest or Wicket's WebRequest). -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4411061.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to write an HTTP header (to detect cookie disablement)?
Hi, Headers are not cookies. By setting a header in the response you should not expect that it will come in the next request. A request header is set by the client (the browser in this case). You can use UrlConnection or Apache HttpClient to set header request which will be available thru WebRequest.getHeader(). Cookies work as you want - set it once in the response and then it will travel around in the next requests/responses until expire. On Wed, Feb 22, 2012 at 6:09 PM, Ian Marshall ianmarshall...@gmail.com wrote: Hi Martin, COOKIES --- I'm fine for this. My cookie code actually works. (But if the user's browser disables cookies, then I want to use HTTP headers to be able to say The user is on his/her second page, and still no cookie, so cookies are definitely disabled (I cannot tell this on the first page).) HTTP HEADERS Many thanks for your tip about FireBug! Grand. (I had never thought about that.) All my web pages are descended from my PageBase class, which in turn descends from Wicket's WebPage. I set my HTTP header in code in my PageBase constructor using org.apache.wicket.request.http.WebResponse.addHeader(...); In the first call to the app (which shows the home page), I can see this header in the response headers using FireBug under GET PageHome?0. Sadly, I cannot detect this in my PageBase constructor using import org.apache.wicket.request.cycle.RequestCycle; import org.apache.wicket.request.http.WebRequest; RequestCycle rcRequestCycle = getRequestCycle(); WebRequest wreqRequest = (WebRequest)rcRequestCycle.getRequest(); String sHeaderValue = wreqRequest.getHeader(X-MyApp-NotFirstPageBase-1); since I get sHeaderValue to be null. Also, I cannot see this header in the request headers using FireBug. After clicking the link on my home page to the About us page, I can see this header in the response headers using FireBug under GET PageAbout?1, but nowhere else (including request headers even though I believe that I add this to each web request unconditionally). If I add org.apache.wicket.request.http.WebResponse.addHeader(...); to my PageHome's form's onSubmit() method, then after form submission I do see this header, but in the response only in POST page?1-1.IFormSubmitListener-frmForm of http://localhost:8080/wicket/page?1-1.IFormSubmitListener-frmForm (I am running locally). Am I looking in the wrong place in my code (and thus in the request cycle) to find my header in a request? Martin Grigorov-4 wrote Hi Ian, If you add/set a header in the HttpServletResponse (even thru Wicket's WebResponse) then it will be written to the browser. You can verify that by investigating the request in Firebug's Net panel. If you want to send a cookie you should either use #addCookie() or set/addHeader(Set-Cookie). Check in google for more info. So you set the cookie in the current response and if not expired it should be available in the next *request* (HttpServletRequest or Wicket's WebRequest). -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4411061.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to write an HTTP header (to detect cookie disablement)?
Hello Jeff, Thanks for the tip. I have tried to detect my header in the HTTP response headers using, in my web application class: @Override protected WebResponse MyWebApplicationnewWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse) { ServletWebResponse swrResponse = new ServletWebResponse( (ServletWebRequest)webRequest, httpServletResponse) { private static final long serialVersionUID = 1L; ... } String sHeaderValue = webRequest.getHeader(X-MyApp-NotFirstPageBase-1); // Show sHeaderValue in the logger return swrResponse; } but sadly with no header detected. (I know little about the details of request and response, which is one reason why I selected Wicket for my application.) Thanks anyway for your input, Ian Jeff Schneller wrote The header won't appear in the browser's page source but will be in the http response header. Sent from my iPhone On Feb 17, 2012, at 12:01 PM, Ian Marshall lt;IanMarshall.UK@gt; wrote: I am having trouble with JSessionIDs in my URLs (my post at http://apache-wicket.1842946.n4.nabble.com/Link-URLs-with-JSessionID-truncated-tp4381881p4381881.html refers). So my plan is to detect the case where a web browser has disabled (session) cookies and react accordingly (for example: show a page to ask for cookie enablement). I plan to detect cookie disablement by writing a cookie during each client request from my common page PageBase (almost all of my web pages are sub-classed from PageBase, which in turn is sub-classed from org.apache.wicket.markup.html.WebPage). If any server response after the first does not have this cookie then I know that cookies are disabled. But how to know that a client request is not the first? I want to explore adding/setting an HTML header to each server response. I can use this to know whether or not this is the client's first request. In my application class, which is a sub-class of org.apache.wicket.protocol.http.WebApplication, I override newWebResponse(...) like this: @Override protected WebResponse newWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse) { httpServletResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); httpServletResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); return super.newWebResponse(webRequest, httpServletResponse); } No such headers appear in the browser's page source. I tried the following code in my About us page. public PageAbout() { super(); Form frmForm = new Form(frmForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { setResponsePage(PageHome.class); WebResponse wrResponse = (WebResponse)getResponse(); wrResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); wrResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); } }; add(frmForm); ... } Again no such header appeared. Can anyone see what I am doing wrong? Regards, Ian Marshall -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4397827.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscribe@.apache For additional commands, e-mail: users-help@.apache - To unsubscribe, e-mail: users-unsubscribe@.apache For additional commands, e-mail: users-help@.apache -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4407998.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to write an HTTP header (to detect cookie disablement)?
Hi Ian, If you add/set a header in the HttpServletResponse (even thru Wicket's WebResponse) then it will be written to the browser. You can verify that by investigating the request in Firebug's Net panel. If you want to send a cookie you should either use #addCookie() or set/addHeader(Set-Cookie). Check in google for more info. So you set the cookie in the current response and if not expired it should be available in the next *request* (HttpServletRequest or Wicket's WebRequest). On Tue, Feb 21, 2012 at 8:18 PM, Ian Marshall ianmarshall...@gmail.com wrote: Hello Jeff, Thanks for the tip. I have tried to detect my header in the HTTP response headers using, in my web application class: @Override protected WebResponse MyWebApplicationnewWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse) { ServletWebResponse swrResponse = new ServletWebResponse( (ServletWebRequest)webRequest, httpServletResponse) { private static final long serialVersionUID = 1L; ... } String sHeaderValue = webRequest.getHeader(X-MyApp-NotFirstPageBase-1); // Show sHeaderValue in the logger return swrResponse; } but sadly with no header detected. (I know little about the details of request and response, which is one reason why I selected Wicket for my application.) Thanks anyway for your input, Ian Jeff Schneller wrote The header won't appear in the browser's page source but will be in the http response header. Sent from my iPhone On Feb 17, 2012, at 12:01 PM, Ian Marshall lt;IanMarshall.UK@gt; wrote: I am having trouble with JSessionIDs in my URLs (my post at http://apache-wicket.1842946.n4.nabble.com/Link-URLs-with-JSessionID-truncated-tp4381881p4381881.html refers). So my plan is to detect the case where a web browser has disabled (session) cookies and react accordingly (for example: show a page to ask for cookie enablement). I plan to detect cookie disablement by writing a cookie during each client request from my common page PageBase (almost all of my web pages are sub-classed from PageBase, which in turn is sub-classed from org.apache.wicket.markup.html.WebPage). If any server response after the first does not have this cookie then I know that cookies are disabled. But how to know that a client request is not the first? I want to explore adding/setting an HTML header to each server response. I can use this to know whether or not this is the client's first request. In my application class, which is a sub-class of org.apache.wicket.protocol.http.WebApplication, I override newWebResponse(...) like this: @Override protected WebResponse newWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse) { httpServletResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); httpServletResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); return super.newWebResponse(webRequest, httpServletResponse); } No such headers appear in the browser's page source. I tried the following code in my About us page. public PageAbout() { super(); Form frmForm = new Form(frmForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { setResponsePage(PageHome.class); WebResponse wrResponse = (WebResponse)getResponse(); wrResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); wrResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); } }; add(frmForm); ... } Again no such header appeared. Can anyone see what I am doing wrong? Regards, Ian Marshall -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4397827.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscribe@.apache For additional commands, e-mail: users-help@.apache - To unsubscribe, e-mail: users-unsubscribe@.apache For additional commands, e-mail: users-help@.apache -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4407998.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands,
How to write an HTTP header (to detect cookie disablement)?
I am having trouble with JSessionIDs in my URLs (my post at http://apache-wicket.1842946.n4.nabble.com/Link-URLs-with-JSessionID-truncated-tp4381881p4381881.html refers). So my plan is to detect the case where a web browser has disabled (session) cookies and react accordingly (for example: show a page to ask for cookie enablement). I plan to detect cookie disablement by writing a cookie during each client request from my common page PageBase (almost all of my web pages are sub-classed from PageBase, which in turn is sub-classed from org.apache.wicket.markup.html.WebPage). If any server response after the first does not have this cookie then I know that cookies are disabled. But how to know that a client request is not the first? I want to explore adding/setting an HTML header to each server response. I can use this to know whether or not this is the client's first request. In my application class, which is a sub-class of org.apache.wicket.protocol.http.WebApplication, I override newWebResponse(...) like this: @Override protected WebResponse newWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse) { httpServletResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); httpServletResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); return super.newWebResponse(webRequest, httpServletResponse); } No such headers appear in the browser's page source. I tried the following code in my About us page. public PageAbout() { super(); Form frmForm = new Form(frmForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { setResponsePage(PageHome.class); WebResponse wrResponse = (WebResponse)getResponse(); wrResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); wrResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); } }; add(frmForm); ... } Again no such header appeared. Can anyone see what I am doing wrong? Regards, Ian Marshall -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4397827.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: How to write an HTTP header (to detect cookie disablement)?
The header won't appear in the browser's page source but will be in the http response header. Sent from my iPhone On Feb 17, 2012, at 12:01 PM, Ian Marshall ianmarshall...@gmail.com wrote: I am having trouble with JSessionIDs in my URLs (my post at http://apache-wicket.1842946.n4.nabble.com/Link-URLs-with-JSessionID-truncated-tp4381881p4381881.html refers). So my plan is to detect the case where a web browser has disabled (session) cookies and react accordingly (for example: show a page to ask for cookie enablement). I plan to detect cookie disablement by writing a cookie during each client request from my common page PageBase (almost all of my web pages are sub-classed from PageBase, which in turn is sub-classed from org.apache.wicket.markup.html.WebPage). If any server response after the first does not have this cookie then I know that cookies are disabled. But how to know that a client request is not the first? I want to explore adding/setting an HTML header to each server response. I can use this to know whether or not this is the client's first request. In my application class, which is a sub-class of org.apache.wicket.protocol.http.WebApplication, I override newWebResponse(...) like this: @Override protected WebResponse newWebResponse(final WebRequest webRequest, final HttpServletResponse httpServletResponse) { httpServletResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); httpServletResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); return super.newWebResponse(webRequest, httpServletResponse); } No such headers appear in the browser's page source. I tried the following code in my About us page. public PageAbout() { super(); Form frmForm = new Form(frmForm) { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { setResponsePage(PageHome.class); WebResponse wrResponse = (WebResponse)getResponse(); wrResponse.addHeader(X-MyApp-NotFirstPageBase-1, true); wrResponse.setHeader(X-MyApp-NotFirstPageBase-2, true); } }; add(frmForm); ... } Again no such header appeared. Can anyone see what I am doing wrong? Regards, Ian Marshall -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-write-an-HTTP-header-to-detect-cookie-disablement-tp4397827p4397827.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org