什么意思啊?用session比较容易嘛,
<%@ page session="true" %><%
session.putValue("cartid",gwcid);
%><%=session.getValue("cartid") %>

解决方案 »

  1.   

    只要你不在<%@ page session="false" %>,就自动默认了session的使用
      

  2.   

    我按2楼的代码写了,但是编译出错Error #: 300 : method putValue(java.lang.String, int) not found in interface javax.servlet.http.HttpSession at line 22
      

  3.   

    <%session.setAttribute("pk","gwcid");%>
      

  4.   

    写在.jsp文件里,不要写在.java文件里
      

  5.   

    <%@ page session="true" %>但jsp中这个值是默认设为true的
    session是内置对象,直接用的
    session.putValue()方法已经被淘汰了
    现在都是用session.setAttribute();
      

  6.   

    就像4楼写的那样
    <%session.setAttribute("pk","gwcid");%>
      

  7.   

    session是隐含对象,在jsp里可以直接使用
    就相当于servlet里的HttpSession类的对象
      

  8.   

    <%@ page contentType="text/html; charset=GBK" %>
    <html>
    <head>
    <title>Session参数设置和获取示例</title>
    </head>
    <body>
    <center>
    <h3>Session参数设置和获取示例</h3>
    <form method="post" action="SessionAttrDemo1.jsp">
    <p>产品标识:<input type="TextField" name="product" value=""></p>
    <p>产品数量:<input type="TextField" name="quantity" value=""></p>
    <input type="submit" name="Submit" value="设置session参数">
    <input type="reset" value="重写">
    <a href="SessionAttrDemo2.jsp">显示session的产品标识和数量</a>
    </form>
    <%
      //取得产品标识
      String product = request.getParameter("product");
      //取得产品数量
      String quantity = request.getParameter("quantity");
      if(product!=null && quantity!=null){
        //设置session的产品标识
        session.setAttribute("product", product);
        //设置session的产品数量
        session.setAttribute("quantity", quantity);
      }
    %>
    </center>
    </body>
    </html>
    -------------------------------------------------<%@ page contentType="text/html; charset=GBK" %>
    <html>
    <head>
    <title>Session参数设置和获取示例</title>
    </head>
    <body>
    <center>
    <p>产品的名字是<%=session.getAttribute("product")%></p>
    <p>产品的数量是<%=session.getAttribute("quantity")%></p>
    </center>
    </body>
    </html>