Generic WebPages Using WAP by Jignesh Desai


Contributed by
Rating: 4 stars4 stars4 stars4 stars4 stars / 6
September 09, 2000
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Generic WebPages Using WAP




 

Here I will explain how to implementing WAP to work on traditional browser and Mobile devices using ASP. although I personally feel XML would be the best approach for this kind of work. Well this is my attempt to allow users to access same page from IE, NN, Nokia and UP Browsers.

Since HTML tags and WML tags are little different in syntax the only common tag I see is <A> anchor tag. you can have graphics when you are displaying on traditional browsers, but i have not done this is my example.

 

[ Jignesh.asp ]

<%
agent = Request.servervariables("http_user_agent")
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.ContentType = "text/vnd.wap.wml"
Response.write("<?xml version=""1.0""?><!DOCTYPE wml PUBLIC""-//WAPFORUM//DTD WML 1.1//EN""""http://www.wapforum.org/DTD/wml_1.1.xml"">")
Response.write("<wml><card>")
else
Response.ContentType = "text/html"
Response.write "<html><head><title>WAP (WirelessApplication Protocol)</title></head><body>"
end if

Response.write "<p align=""center"">Welcome</p>"
Response.write "<p align=""center"">Jignesh consultancy</p>"
Response.write "<p><a href=""training.asp""> Training </a></p>"
Response.write "<p><a href=""webd.asp""> Web Development </a></p>"
Response.write "<p><a href=""Home.asp""> Jignesh's Home </a></p>"
Response.write "<p>Email: codehunt@yahoo.com</p>"
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.write("</card></wml>")
else
response.write "</body></html>"
end if
%>

Things are pretty simple here Request.servervariables("http_user_agent") will return what browser "client" is using. if you run this code on Nokia toolkit it returns "Nokia-WAP-Toolkit/1.3beta" while UP. Browser returns "UPG1 UP/4.0.4g". so we well find out what is the value of 'agent' variable, if it is matching above two we will throw WML contant from asp file else assume client is a traditional browser and we will throw HTML content.

you might wonder why I am using </p> tag in every statement and not <br>. the answer is as per WML specification empty tags syntax is "<br/> which is perfectly fine for IE but not for NN (atleast ver 4.5 ). if you are planning to support all versions of browser then this is the best.

This remains same for all other remaining ".asp" files in this article. source code of other .asp files are listed below.

 

[ Training.asp ]

<%
agent = Request.servervariables("http_user_agent")
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.ContentType = "text/vnd.wap.wml"
Response.write("<?xml version=""1.0""?><!DOCTYPE wml PUBLIC""-//WAPFORUM//DTD WML 1.1//EN""""http://www.wapforum.org/DTD/wml_1.1.xml"">")
Response.write("<wml><card>")
Response.write("<do type=""accept"" label=""Go!"" optional=""false"" >")
Response.write("<prev/></do>")
else
Response.ContentType = "text/html"
Response.write "<html><head><title>WAP (WirelessApplication Protocol)</title></head><body>"
end if

Response.write "<p align=""center"">Welcome</p>"
Response.write "<p align=""center"">Jignesh consultancy</p>"
Response.write "<p>Higher End Training on Site Server, WAP, ASP-IIS, Oracle8i.</p>"
Response.write "<p> (091)-(022)-(8638399) </p>"
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.write("</card></wml>")
else
response.write "</body></html>"
end if
%>


[ WebD.asp ]

<%
agent = Request.servervariables("http_user_agent")
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.ContentType = "text/vnd.wap.wml"
Response.write("<?xml version=""1.0""?><!DOCTYPE wml PUBLIC""-//WAPFORUM//DTD WML 1.1//EN""""http://www.wapforum.org/DTD/wml_1.1.xml"">")
Response.write("<wml><card>")
Response.write("<do type=""accept"" label=""Go!"" optional=""false"" >")
Response.write("<prev/></do>")
else
Response.ContentType = "text/html"
Response.write "<html><head><title>WAP (WirelessApplication Protocol)</title></head><body>"
end if

Response.write "<p align=""center"">Welcome</p>"
Response.write "<p align=""center"">Jignesh consultancy</p>"
Response.write "<p>[ Web Development Rs.300 and Hosting with fast servers] </p>"
Response.write "<p> (091)-(022)-(8638399) </p>"
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.write("</card></wml>")
else
response.write "</body></html>"
end if
%>


[ Home.asp ]

<%
agent = Request.servervariables("http_user_agent")
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.ContentType = "text/vnd.wap.wml"
Response.write("<?xml version=""1.0""?><!DOCTYPE wml PUBLIC""-//WAPFORUM//DTD WML 1.1//EN""""http://www.wapforum.org/DTD/wml_1.1.xml"">")
Response.write("<wml><card>")
Response.write("<do type=""accept"" label=""Go!"" optional=""false"" >")
Response.write("<prev/></do>")
else
Response.ContentType = "text/html"
Response.write "<html><head><title>WAP (WirelessApplication Protocol)</title></head><body>"
end if

Response.write "<p align=""center"">Welcome</p>"
Response.write "<p align=""center"">Jignesh consultancy</p>"
Response.write "<p>C/204 Patel Nagar, 4.M.G. Cross Road, Kandivali (west), Mumbai 400067, India</p>"
Response.write "<p> (091)-(022)-(8638399) </p>"
if instr(1,agent,"Nokia") or instr(1,agent,"UP/4.0") then
Response.write("</card></wml>")
else
response.write "</body></html>"
end if
%>


That's it!. Enjoy and download code to see live. or check live from your simulator by pointing here

http://www.web-tech.atfreeweb.com/default.asp

See my other article "Booking Movie Tickets on Mobile Phone"

blog comments powered by Disqus
CODE EXAMPLES ARTICLES

- Bipartite Graphs
- Connectivity in Graphs
- The Ford-Fulkerson Algorithm
- Critical Paths
- The Bellman-Ford and Roy-Floyd Algorithms
- Shortest Path Algorithms in Graphs
- Minimum Spanning Tree
- Articulation Edges and Vertexes
- Circles and Connectivity in Graphs
- Depth-First Search in Graphs
- Breadth-First Search in Graphs
- The Prufer Code and the Floyd-Warshall Algor...
- An Insight into Graphs
- Coding a Custom Object with WSC
- Creating a Custom Object with WSC

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials