BizTalk Utilities CV ,   Jobs ,   Code library  
 
 
Page 6 of 8

 

Previous Page Table Of Contents Next Page

Creating a Dynamic WAP Application

Cookie Support on WAP Devices

At the time of writing, WAP 1.1 devices have very limited support for cookies. If you're planning to make use of ASP's Session object, you have to be aware of this and make appropriate allowances.

The Session Object and Cookies

The ASP Session object requires the use of cookies in order to work correctly. Provided that's the case, using it is straightforward. This is the sample file Session.asp:

 

<% Response.ContentType = "text/vnd.wap.wml" %>

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"

                     "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

   <card id="card1" title="Session">

      <p>

         <%

         Session("TimeLogon") = now

         Response.Write "You are logged on at " & _

                        Session("TimeLogon")

         %>

      </p>

   </card>

</wml>

 

 

Here, this statement,

 

         Session("TimeLogon") = now

 

saves the date and time into a Session object named TimeLogon, and subsequent WML decks can then use this Session object to check the logon time of the user. That's all well and good, but since WAP 1.1 devices have limited support for cookies, how can we maintain state without using the Session object?

Maintaining State without Cookie Support

Let's see now how we can solve the previous problem without using the Session object. This is Nosession.asp:

 

<% Response.ContentType = "text/vnd.wap.wml" %>

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"

                     "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

   <card id="card1" title="Card 1">

      <p>

         <% TimeLogon = now %>

         Welcome!

         <do type="accept" label="Card 2">

            <go href="#card2" method="get">

               <postfield name="TimeLogon"

                          value="<% =TimeLogon %>" />

            </go>

         </do>

      </p>

   </card>

 

   <card id="card2" title="Card 2">

      <p>

         You have logged on at

         <% =Request.QueryString("TimeLogon") %>

      </p>

   </card>

</wml>

 

Here, I'm passing values from one card to another using the <postfield> element. The downside to this using this approach is that it is inconvenient to pass values from one card to another, especially if the number of items to pass increases.

Detecting WAP Devices

To detect what WAP browser the user is using, you can use the Request.ServerVariables collection, as I do in Useragent.asp:

 

<% Response.ContentType = "text/vnd.wap.wml" %>

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"

                     "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

   <card id="card1" title="Type">

      <p>

         Browser Type :

         <% =Request.ServerVariables("HTTP_USER_AGENT") %>

      </p>

   </card>

</wml>

 

 

It's up to the developer to decide on the level of compatibility that they want to achieve for a particular application. For a list of user agents, point your browser at http://amaro.g-art.nl/useragent/. The following example illustrates how to detect whether a user is using a web browser or a WAP browser to view a page:

 

<%

   If InStr(Request.ServerVariables("HTTP_USER_AGENT"), _

            "Mozilla") Then

      Response.Redirect "Error.html"

   End If

%>

<% Response.ContentType = "text/vnd.wap.wml" %>

<?xml version="1.0"?>

<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"

                     "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>

   <!-- First Card -->

   <card id="card1" title="Welcome">

      <p>

         Welcome...

      </p>

   </card>

</wml>

 

If the user agent contains the word "Mozilla", then the user is using a web browser and I need to redirect them to another HTML page using the Response.Redirect() method.

 

Page 6 of 8

 

Previous Page Table Of Contents Next Page
 

Recent Jobs

Software Developers Needed in Charl
Sr. Software Engineer - Analytics
Immediate Mainframe openings for Ch
Immediate TANDEM-TAL openings for C
Immediate ASP.NET/C# Openings for C

View all Jobs (Add yours)
View all CV (Add yours)



it help desk
swimming pool contractor
international conference call
water softener
Teleconference
Host Department NOLIMIT Web Hosting
MSN
sunglasses


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP