你说什么呀!Session是javax.mail包中的类!或者是javax.jms包中的一个接口!当然后问题了!
解决方案 »
- JTree怎么使用系统图标?
- 正则表达式中把"\\"替换为"/"怎么换呢?
- 请问一下我要读取ftp上面的一个文件应该怎么实现啊
- tomcat和jdk不兼容? 很快结贴
- Windows2000平台上Java程序连接oracle9i的简单问题
- 如何将三个String类型的数据合成为一个Date类型的数据
- 哪有java函数中文手册下载?
- jni的资料谁有
- 我在jb中创建了两个frame....我想通过在第一个frame中的一个按钮,然后打开另一个Frame.....
- 谁有JCreator Pro2.5的注册码?急用!
- 用java做应用程序,需要访问SqlServer2000,请高手给出解决方法?
- 我的jbuilder6.0为什么用jdk1.4升级后,编出的东东后,鼠标滚轮不能够用?
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;public class SessionExample extends HttpServlet
{
public void goGet(HttpServletRequest request ,HttpServletResponse response)
throws IOException,ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession Session = request.getSession(true);
//´òÓ¡sessionÐÅÏ¢
Date created = new Date(Session.getCreationTime());//·µ»Øsession´´½¨µÄʱ¼ä
Date accessed = new Date(Session.getLastAccessedTime());//·µ»Øµ±Ç°Session¶ÔÏó×îºóÒ»´Î±»²Ù×÷µÄʱ¼ä
out.println("ID"+Session.getId());//ÿÉú³ÉÒ»¸öSession¶ÔÏ󣬷þÎñÆ÷¶¼»á¸øËûÒ»¸ö±àºÅ
out.println("Created:"+created);
out.println("Last Accessed:"+accessed);
String dataName = request.getParameter("dataName");
if(dataName !=null && dataName.length() > 0)
{
String dataValue = request.getParameter("dataName");
Session.putValue(dataName,dataValue);
}
String[] valueNames = Session.getValueNames();
if(valueNames !=null && valueNames.length >0)
for(int i=0 ; i<valueNames.length ; i++)
{
String name = valueNames[i];
String value = Session.getValue(name).toString();
out.println(name + "=" + value);
}
}
}
还有,我编译是可以的,是不是你没有把servlet.jar放到你的classpath中?
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;public class SessionExample extends HttpServlet {
public void goGet(HttpServletRequest request ,HttpServletResponse response)
throws IOException,ServletException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
HttpSession Session = request.getSession(true);
//´oÓ¡sessionÐÅÏ¢
Date created = new Date(Session.getCreationTime());//・µ»Øsession´´½¨µÄʱ¼ä
Date accessed = new Date(Session.getLastAccessedTime());//・µ»Øµ±Ç°Session¶ÔÏo×îºoÒ»´Î±»²Ù×÷µÄʱ¼ä
out.println("ID"+Session.getId());//ÿÉu³ÉÒ»¸öSession¶ÔÏo£¬・þÎñÆ÷¶¼»a¸øËûÒ»¸ö±aºÅ
out.println("Created:"+created);
out.println("Last Accessed:"+accessed);
String dataName = request.getParameter("dataName");
if (dataName != null && dataName.length() > 0) {
String dataValue = request.getParameter("dataName");
Session.setAttribute(dataName,dataValue);
}
Enumeration valueNames = Session.getAttributeNames();
while (valueNames.hasMoreElements()) {
String name = (String) valueNames.nextElement();
String value = Session.getAttribute(name).toString();
out.println(name + "=" + value);
}
}
}