Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Strange problem detecting User-Agent - maybe due to caching?  RSS feed

 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya all,

My servlet takes the User-Agent identifiers of the clients (mobile phones) that access it and stores them in a database. The servlet contains the following lines of code:

String usersPhoneType = request.getHeader("User-Agent");
String usersPhoneNum = request.getParameter("pn");
String statementString = "UPDATE users SET phone_type_from_wap_profile = '" + usersPhoneType + "' WHERE phonenum = '" + usersPhoneNum + "' LIMIT 1";
etc...

When a user accesses this servlet from their mobile the first time, all is fine and I'll get a nice "Nokia6600/..." (or something like that) stored in the database.

But, sometimes, at some point in the future (I think when a user does a subsequent request), then a rogue "Mozilla/4.0 (compatible; Cerberian Drtrs Version-3.1-Build-16)" User-Agent can be stored instead - which means I no longer know what phones certain users have got...

I'm not sure where this new User-Agent is coming from. I'm thinking maybe it could be due to some caching somewhere, but not sure where though or how...

Can anyone help me?

Thanks,
James
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds more like an unreliable client to me. Like the client software in the handset uses an unreliable handling of the user-agent field.

I can't imagine that a part of the caching mechanisms would change this part of the request.

Can you get your hands on one of the devices that causes the problem, so you can test with the mobile handset in your hand ?

J.
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya Jeffrey,

Thanks for the reply.

One of the users handsets it has happened with is the SE K750i. I have tried it on my own K750i but cannot get it to replicate the problem...
 
James Hodgkiss
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I've found the problem now: All the affected rows in my database were Vodafone users. Seems like Vodafone have some kind of content filtering / censorship thing that checks out all accessed url's.

I suppose I could confirm this by detecting the requesting IP addresses, but I think I will just deny access to any User-Agent starting with "Mozilla" (which isn't a problem for me, as the servlet is only to be accessed by mobiles anyway).

Cheers,
James
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!