i need to know what brand is the pocket pc that is using my website in order to show them a page accordingly.

do you have any ideas?

I don't see much point in doing redirects after the wrong page is loaded to the minibrowser, If you do it on the server before the page is loaded the minibrowsers wont waste time loading a heap of pages then reloading
browsers send their user_agent in http request, this works in php, Caveat that many browsers spoof their headers and pretend to be something else

<?php $mobile = "http://mobi.mysite.com/";
if(preg_match('/Windows CE/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/Blackberry/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/PalmOS/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/PalmSource/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/SymbianOS/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/Opera Mini/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/Nokia/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/Samsung/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/vodaphone/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/Jphone/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/AvantGo/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/DoCoMo/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
elseif(preg_match('/DDIPOCKET/i',$_SERVER['HTTP_USER_AGENT'])) { header("location: $mobile");}
// redirect to pda page else continue
if ($frame) { header("location: http://www.mysite.com$frame");}
ob_start("ob_gzhandler"); ?>
<!-- assorted html -->
<?php ob_flush(); ?>

or a switch / case combination

A proportion of pocket browsers dont do javascript.
A tutorial in Javascript is here http://www.web-wise-wizard.com/javascript-tutorials/javascript-jscript-get-user-information.html
the examples are pretty trivial, but I guess make a foundation for your own code

thanks bob, i will try this and this will be my first php trial, i also need jsp version of this because at this point i work on AIX with jsp enabled, but when we deploy the application probably it is going to be tomcat server

Actually this is not i am looking for, i created the asp.net equivalent of what you did as follows :

Default.aspx :

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>

Default.aspx.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(Request.ServerVariables["HTTP_USER_AGENT"]);
    }
}

the output from the page is :

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)

this information are about software, i need manufacturer and model information like : hp pavillion dv7-1025nr...

i will continue to search it, i will post the solution if i find as usual.

here is the jsp version of the same thing :

<html>
<head>
    <title>Enumeration Scriplet</title>
</head>
<body>
    <h2>
        Enumerations</h2>
    <p>
    </p>
    <p>
    </p>
    <h2>
        Enumerate through HTTP Header</h2>
    <h4>
        HTTP Header (Not in order)</h4>
    <p>
        <% 
  java.util.Enumeration e = request.getHeaderNames();
   while (e.hasMoreElements()){ 
       String name = (String) e.nextElement();
       out.print("<b>" + name + ": </b>"); 
         out.print(request.getHeader(name) + "<br>");
      } 
        %>
    </p>
</body>
</html>

output from my pc :

Enumerations
Enumerate through HTTP Header
HTTP Header (Not in order)
host: localhost:26357
accept: */*
accept-language: en-us
ua-os: Windows CE (Pocket PC) - Version 5.1
ua-color: color16
ua-pixels: 240x240
ua-cpu: x86
x-wap-profile: "http://www.hp.com/ipaqcarrier/hpipaqhw6900v10.xml"
ua-voice: TRUE
accept-encoding: gzip,deflate
user-agent: HPiPAQhw6900/1.0/Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x240)
cookie: JSESSIONID=F9E26C29F14E1B1EBBE2CD88CB46FFA4
max-forwards:....
x-forwarded-for: ......x-forwarded-host: ....
x-forwarded-server: .....

i was able to retrieve device model information, which is what i was looking for.

and to retrieve that information using javascript :

<html>
<body>
<script type="text/javascript">

document.write( navigator.userAgent);
</script>
</body>
</html>

the output is :

HPiPAQhw6900/1.0/Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x240)

Still serverside, in asp php

in order to show them a page accordingly.

is better and costs the user less resources
javascript if you just want to document.write something trivial to the page, based on machine model.
but javascript

in order to show them a page accordingly.

is poor practice,
a non-javascript microbrowser stalls,
and if it runs- still requires a page just to redirect,
microbrowsers are slow, and the user pays ber KB.

In php or asp the request header used in the javascript is available
echo $_server[] array, (equivalent ASP (10c + what_I_know_of_ASP = 10c))

and choose the element content to redirect on
I search for substring(s) in $_SERVER['HTTP_USER_AGENT']; because that substring identifies Browser I need to redirect, to less image intense pages,

Fingers X, If it works, use it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.