Ok, the verdict is out. It works. :) Basically the logic in the action controller decides which action to forward to depending on the user-agent value. After that, it all depends on the action forwarded to to render the correct version of the site. Code snippet:
String UserAgent = "";
java.util.Enumeration e = req.getHeaderNames();
while(e.hasMoreElements()) {
String name = (String) e.nextElement();
String value = req.getHeader(name);
if (name.equals("user-agent")) {
UserAgent = value;
}
}
if (UserAgent.equals("Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320)"))
{
// if user agent is for Pocket PC, forward to success_pda
return mapping.findForward("success_pda");
}
// by default forward to success
return mapping.findForward("success");
Friday, September 26, 2003
I am trying to modify one of the applications written by one of my colleagues so that it will properly direct the browser to the correct jsp page (either for HTML browsers or WAP browser) based on the User-Agent HTTP variable. Struts is making it quite easy to do this. Someone has a proposed way of doing it in this post. I will try it out and see if it really works.
Subscribe to:
Posts (Atom)