日期:2014-05-18  浏览次数:20708 次

jsp的一个问题
我用eclipse开发了一个tomcat   项目jspstudy,前几个jsp,servlet程序都可以运行正常,但是我又写了一个SessionExample.java程序和一个名为SessionServlet.jsp页面,启动tomcat却显示这样的错误:
HTTP   Status   404   -   /jspstudy/

--------------------------------------------

type   Status   report

message   /jspstudy/

description   The   requested   resource   (/jspstudy/)   is   not   available.
以前的几个程序都可以运行啊!!!
SessionServlet.jsp:源代码:
<%@   page   language= "java "   contenType= "text/html;charset=gb2312 "%>
<html>
<center>
<title> Session-Servlet测试 </title>
<body>
<%--设置Session中的共享变量dataName和   dataValue--%>
<%
session.putValue( "dataName ", "session-share ");
session.putValue( "dataValue ", "100 ");
%>
<form   method=post   action= "./SessionExample ">
输入数据上限:
<input   type=text   name= "dataLimit ">
<p>
<input   type=submit>
</form>
</body>
</center>
</html>
Servlet程序SessionExample.java的源代码:
/**
  *   在JSP   和Servlet之间传递数据
  */
package   test;

import   java.io.*;
import   java.util.*;
import   javax.servlet.*;
import   javax.servlet.http.*;

/**
  *   @author   李彬
  *
  */
public   class   SessionExample   extends   HttpServlet   {

/**
  *   添加缺省的序列好
  */
private   static   final   long   serialVersionUID   =   1L;
public   void   doGet(HttpServletRequest   request,HttpServletResponse   response)
throws   IOException,ServletException  
{
response.setContentType( "text/html;charset=gb2312 ");
PrintWriter   out   =   response.getWriter();

//从request对象中获得当前用户的Session
HttpSession   session   =   request.getSession(true);
//输出session信息
//获得session创建时间
Date   created   =   new   Date(session.getCreationTime());
//获得Session最后访问时间
Date   accessed   =   new   Date(session.getLastAccessedTime());
out.println( "session   ID: "   +   session.getId()   +   " <br> ");
out.println( "创建时间: "   +   created   +   " <br> ");
out.println( "上次访问时间: "   +   accessed   +   " <br> ");

//设置Session信息
String   dataName   =   request.getParameter( "dataName ");
if(dataName   !=   null   &&   dataName.length()> 0){
String   dataValue   =   request.getParameter( "dataValue ");
session.setAttribute(dataName,dataValue);
}
//输出session内容
Enumeration   e   =   session.getAttributeNames();
while(e.hasMoreElements()){
String   name   =   (String)e.nextElement();
String   value   =   session.getAttribute(name).toString();
out.println(name   +   "= "   +