wml页面传递变量

1.wapTest.jsp

<%@ page language="java" import="java.util.*" contentType="text/vnd.wap.wml;charset=GBK"%>

<%

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

<?xml version="1.0" Encoding="GBK"?>

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

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

<wml>

<head>

<meta http-equiv="contentType" content="text/vnd.wap.wml"/>

<meta http-equiv="Expires" content=" 0"/>

<meta http-equiv="Cache-Control" content="no-cache"/>

</head>

<card id="list" title="choose company">

<select name="company">

<option onpick="#sa">索爱</option>

<option onpick="#nokia">Nokia</option>

</select>

</card>

<card id="sa" title="索爱">

<do type="accept" label="OK">

<go href="#test"></go>

</do>

<select name="type">

<option value="索爱1">索爱1</option>

<option value="索爱2">索爱2</option>

</select>

</card>

<card id="nokia" title="Nokia">

<do type="accept" label="OK">

<go href="#test"></go>

</do>

<select name="type">

<option value="Nokia1">Nokia1</option>

<option value="Nokia2">Nokia2</option>

</select>

</card>

<card id="test" title="postfield">

<p>型号:$type</p>

<do type="accept" label="submit">

<go href="wapTest" method="post">

<postfield name="company" value="$type"/>

</go>

</do>

</card>

</wml>


//---------------------

2.servlet

路径:wapTest

///////////////////////////////////////

public void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("text/vnd.wap.wml;charset=gbk");

PrintWriter out = response.getWriter();

out.print("<wml>");

if(request.getParameter("company")!=null){



out.print("<card><p>company is:"+request.getParameter("company"));

out.print("</p></card>");

}

out.print("</wml>");

out.flush();

out.close();

}

当然,jsp就可以通过url传递

<a href="test.jsp?param=text">jsp</a>

你可能感兴趣的:(jsp,cache,Go,Nokia,WAP)