主题:求助Servlet中会话跟踪的问题
小弟初学JSP,碰到这个问题,郁闷死了,这是书上的原例,照着打都不对,NND,气死偶了,哪个大哥偶下指出错误。。。
package chapter3;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class ShoppingCart extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>当前购物车中的商品</title></head>");
out.println("<body>");
String[] items=request.getParameterValues("item");
out.println("当前,你的购物车有这些商品:<br>");
if(items==null){
out.println("<b>商品为空!</b>");
}
else
{
out.println("<UL>");
for(int i=0;i<items.length;i++)
{
out.println("<LI>");
out.println(items[i]);
}
out.println("<UL>");
}
out.println("<form action=\"/sessiontrack/ShoppingCart\" method=post>");
if(items!=null)
{
for(int i=0;i<items.length;i++){
out.println("<input type=hidden name=item value=\""+items[i]+"\">");
}
}
int i=new Random().nextInt(100);
out.println("<input type=hidden name=item value=商品>");
out.println(String.valueOf(i));
out.println("您愿意<br>");
out.println("<input type=submit value=添加商品>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
out.close();
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}
这个程序中
我对out.println("<form action=\"/sessiontrack/ShoppingCart\" method=post>");
中的action=\"/sessiontrack/ShoppingCart\" 不明白。。。
谁告诉偶
package chapter3;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class ShoppingCart extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>当前购物车中的商品</title></head>");
out.println("<body>");
String[] items=request.getParameterValues("item");
out.println("当前,你的购物车有这些商品:<br>");
if(items==null){
out.println("<b>商品为空!</b>");
}
else
{
out.println("<UL>");
for(int i=0;i<items.length;i++)
{
out.println("<LI>");
out.println(items[i]);
}
out.println("<UL>");
}
out.println("<form action=\"/sessiontrack/ShoppingCart\" method=post>");
if(items!=null)
{
for(int i=0;i<items.length;i++){
out.println("<input type=hidden name=item value=\""+items[i]+"\">");
}
}
int i=new Random().nextInt(100);
out.println("<input type=hidden name=item value=商品>");
out.println(String.valueOf(i));
out.println("您愿意<br>");
out.println("<input type=submit value=添加商品>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
out.close();
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
doGet(request, response);
}
//Clean up resources
public void destroy() {
}
}
这个程序中
我对out.println("<form action=\"/sessiontrack/ShoppingCart\" method=post>");
中的action=\"/sessiontrack/ShoppingCart\" 不明白。。。
谁告诉偶