"Andr�s Aguiar" wrote:

> Does anyone know if there's a list of the return values of the 'User-Agent'
> header for different browsers?

Nope, and I'm not sure you will find one, either.  What you could do though,
assuming you had a finite list of capabilities you want to test the client
for, is start making your own database at runtime.

First of all, you need to encapsulate what is going to be different for each
user-agent  in a series of objects.  For example, assuming you had a known
number of abilities that you wanted to test for, and were interested in
grouping user-agents by particular combinations of these abilities, you could
do something like the below.

Anyway, if you follow the below idea, you will have a servlet that handles new
user-agents in a default manner, notes them down as it comes across them, and
emails you about the new ones so you can check its assumptions.  If they turn
out to be wrong, you edit a file and restart the servlet.

Regards,
David.


recipe:

Make an object called CapabilitySet.  Make it nameable with methods for
get/setting a String 'name'.  Add methods for the capabilities you are
interested in:

eg.  boolean supportsJavaRMI();
eg.  boolean supportsCascading Sylesheetes();

Make yourself a mechanism to associate names with capabilities (eg. in a
.properties file - or, if you are adventurous, by writing the CapabilitySet as
a bean).  You will have a small number of capability sets: called "text-only",
"basic-graphics", "impure-Java", "impure-Java-with-VBScript",
"impure-Java-with-JavaScript", "pure-Java", "pure-Java-with-CSS1",
"pure-Java-with-CSS2", "pure-Java-with-XML-and-XSL-and-Im-dreaming", etc.
etc., according to your lines of interest.  For each of them, set the relevant
attributes. Make sure you call one "default".

Make yourself a mechanism which will let you find a particular CapabilitySet
by name.  (eg. findCapabilitySetByName(String name))

Then make an object called UserAgentCapability.  It is a Properties object
that contains the names of known User Agents for it's key.  Against each key,
store the name of the CapabilitySet you wish to use.

1. For each service() request (or the first request of a session, if you are
using sessions), grap the 'User Agent' value.

2. Test to see if the UserAgentCapability object knows this agent, and if not
already held by it:
  a)add it, assign it to some default CapabilitySet name, save the
UserAgentCapabilities property object, and send yourself an email that "user
agent X was added with default capabilities: a, b, and c.  Please edit file
F.properties on sevlet host H and restart the serlvet S to change this."
....OR (if the user-agent name is found)
  b) get the CapabilitySet with
findCapabilitySetByName(myUserAgentCapability.get(userAgentName))

3. perform conditional processing based on calls to supportsXML() etc. on the
CapabilitySet.

Make sure your servlet uses init parameters to specify the name of the
.properties file to use, as well as the name of an smtp server, and your email
address.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to