当前位置: 技术问答>java相关
编叻个servlet程序..可出错..说javax.Servlet.*等很多包不存在???
来源: 互联网 发布时间:2015-10-13
本文导语: import java.io.*; import java.lang.*; import javax.Servlet.*; import javax.Servlet.http.*; public class CurrentTime extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOExceoptin,ServletException{ response....
import java.io.*;
import java.lang.*;
import javax.Servlet.*;
import javax.Servlet.http.*;
public class CurrentTime extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOExceoptin,ServletException{
response.setContentType("text/html;charset=gb2321");
PrintWriter out=response.getWriter();
out.println("");
out.println("");
out.println("显示当前时间---servlet");
out.println("");
out.println("");
java.util.Date dt=new java.util.Date(System.currentTimeMillis());
out.print(dt.getHours());
out.print(":");
out.print(dt.getMinutes());
out.print(":");
out.print(dt.getSeconds());
out.print("");
out.print(""); }
};
上面编译下说..Servlet.*,Servlet.HttpServlet.*...等包不存在?
怎么搞底...
我用editplus写...要编译servlet是不是应该先把它编译成class再放到tomcat的classes里阿...???
import java.lang.*;
import javax.Servlet.*;
import javax.Servlet.http.*;
public class CurrentTime extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOExceoptin,ServletException{
response.setContentType("text/html;charset=gb2321");
PrintWriter out=response.getWriter();
out.println("");
out.println("");
out.println("显示当前时间---servlet");
out.println("");
out.println("");
java.util.Date dt=new java.util.Date(System.currentTimeMillis());
out.print(dt.getHours());
out.print(":");
out.print(dt.getMinutes());
out.print(":");
out.print(dt.getSeconds());
out.print("");
out.print(""); }
};
上面编译下说..Servlet.*,Servlet.HttpServlet.*...等包不存在?
怎么搞底...
我用editplus写...要编译servlet是不是应该先把它编译成class再放到tomcat的classes里阿...???
|
在tomcatlib目录下有个servlet.jar你把它加到你的CLASSPATH里面就OK了