I have a servlet that needs to verify that the browser supports cookies. If not, it should issue an error message "you must enable cookies to use this site". (You may argue with this business approach, but that's what we want... even though we know of "url rewrites").
But how can a Servelt know whether the browser supports cookies ? Are there any recommendations or ready-made APIs for it?
So far I could only think of ways to know within the *second* page (have one "welcome page" and require that other pages be accessiable only through this "welcome page". Then, I guess you can prepare a "test" cookie in the welcome page, and the browser must send it back to the 2nd page, otherwise you know cookies are disabled).
But I think I've seen some websites which manage to tell within the very first page: if my browser has disabled cookies, the "welcome page" tells me so immediately... how come ?
Thanks for this answer. Could I please ask - isn't it expected to work only on the second page? The very first time a user visits my site and arrives at the "welcome" page, he won't have any cookies to send me, will he? Or am I missing something?