选择显示字体大小

在asp中编写wml程序

(1) 将wml程序使用<%和%>包含起来,格式为:

<%

……(语句)

%>

(2) 声明wml文件类型。与前面讲述的方法相同,可采用asp的response对象,并将contenttype作为它的方法,但书写时不再需要使用<%和%>。格式为:

response.contenttype="text/vnd.wap.wml"

(3) 对于其他的wml语句,一律采用response对象的write方法来处理。基本格式为:

response.write("……(wml标签或语句)")

其中的“wml标签或语句”在write方法中可以连写,以节省程序代码行。

(4) 在wap服务器端,增加服务器asp的处理能力。操作方法与前面介绍的一样,这里不再重述。

(5) 程序文件保存时也要采用“.asp”的扩展名。

下面的程序就是在asp中编写wml页面的简单例子:



<%

     'msg = "hello "

     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("hello wml ! test ok !")

     response.write("</p></card></wml>")

%>



当然,我们这里给出的属于asp与wml结合使用的简单例子,但采用这种基本方法,并利用asp的复杂功能,便可以开发出能够实现丰富功能的wml页面。

例如,下面的asp程序不仅可以显示“hello”信息,同时可以显示信息的来源地或所在环境,这是通过利用request对象的servervariables方法来获取服务器的http_x_up_subno和http_x_up_uplink两个变量实现的。程序代码如下:



<%

' hellowml.asp

'

dim msg, subid, uplink



msg = "hello "

subid = request.servervariables("http_x_up_subno")

uplink = request.servervariables("http_x_up_uplink")



if not len(subid) = 0 then

  msg = msg & "from " & subid

end if

if not len(uplink) = 0 then

  msg = msg & " at " & uplink

end if



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><p>")

response.write(msg)

response.write("</p></card></wml>")

%>



为增强大家对asp编写wml程序的印象,我们再给出phone.com提供的一个例子。该例的作用是根据对服务器和客户端设置测试结果的不同,给出不同的警告信息。程序代码如下:



<%

' pushalert.asp

'

dim uplink, subid, url, ttl, alerttype, title

dim contenttype, lastresult

contenttype = "application/x-up-alert"



uplink = request.servervariables("http_x_up_uplink")

subid = request.servervariables("http_x_up_subno")



url = "http://updev.phone.com/dev/hdml/devhome3.hdml"

ttl = 3600

alerttype = "d---"

title = "call: " & subid



set ntfycl = server.createobject("ntfn3client.ntfn3client.1")

ntfycl.ntfnsethost uplink

ntfycl.ntfnsettimeout ttl

ntfycl.ntfnpostalert subid, url, ttl, alerttype, title

lastresult = ntfycl.ntfngetlastresult



dim errstring, msg

if lastresult <> 0 then

  errstring = ntfycl.ntfngeterrordetail

  if errstring <> null then

    msg = errstring

  else

    msg = "no error detail, error number: " & lastresult

  end if

else

  msg = "sent alert to " & subid & " at " & uplink

end if



dim my, digeststring

set my = server.createobject("pdcdigestutils.cpdcdigest")

my.decktype = 0

my.digestadddeck "deck1", "<wml><card><p>" & msg & "</p></card></wml>"



my.digestsuppresscontenttype 1

digeststring = my.digestserialize(0)

response.contenttype = my.digestgetcontenttype

response.binarywrite(digeststring)

%>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons