You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by David Oxley <da...@staffplanner.co.uk> on 2002/07/25 14:37:01 UTC

WML or HTML detection

>From a servlet how can you detect what should be output from the type of
client that sent the request. i.e. If a WAP phone accesses a servlet then it
outputs WML or if a Web Browser accesses the same servlet then HTML is
output

 

Thanks.

Dave


Re: WML or HTML detection

Posted by Arthur Veinstein <Ar...@telemessage.com>.
You should check the headers his browser sent you, you will be able to
understand which file he support, if he supports HTML then give it to him,
else is WML is supported the send the WML

if (request.getHeader("Accept").lastIndexOf ("wml") != -1)

    send WML
else
    send HTML

Arthur
----- Original Message -----
From: "David Oxley" <da...@staffplanner.co.uk>
To: "'Tomcat Users List'" <to...@jakarta.apache.org>
Sent: Thursday, July 25, 2002 2:37 PM
Subject: WML or HTML detection


> From a servlet how can you detect what should be output from the type of
> client that sent the request. i.e. If a WAP phone accesses a servlet
> then it
> outputs WML or if a Web Browser accesses the same servlet then HTML is
> output
>
>
>
> Thanks.
>
> Dave
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: WML or HTML detection

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 25 Jul 2002, David Oxley wrote:

> Date: Thu, 25 Jul 2002 13:37:01 +0100
> From: David Oxley <da...@staffplanner.co.uk>
> Reply-To: Tomcat Users List <to...@jakarta.apache.org>
> To: 'Tomcat Users List' <to...@jakarta.apache.org>
> Subject: WML or HTML detection
>
> >From a servlet how can you detect what should be output from the type of
> client that sent the request. i.e. If a WAP phone accesses a servlet then it
> outputs WML or if a Web Browser accesses the same servlet then HTML is
> output
>

String userAgent = request.getHeader("user-agent");

You can use this value to determine what the client device (or browser)
is, including the version number.

>
>
> Thanks.
>
> Dave
>
>

Craig



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>