Topic: 请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? |
Print this page |
1.请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 13:35 import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class servletOne extends HttpServlet{ int count = 0; public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IoException{ res.setContentType("text/plain"); PrintWriter out = res.getWriter(); int local_count; synchronized(this){ local_count = ++count; } out.println("<HTML>"); out.println("<HEAD><TITLE= A SimpleCounter </TITLE></HEAD>"); out.println("<BODY>"); out.println("<h5 align=\"center\">" + "<font color=\"#0000FF\">"); out.println("since web server startup,the servlet has accessed" + "<h1>" + local_count + "times" +"</h1>"); out.println("</font></h5>"); out.println("</body></HTML>"); } } 编译错误如下: C:\javago\JC\servletOne.java:2: package javax.servlet does not exist import javax.servlet.*; ^ C:\javago\JC\servletOne.java:3: package javax.servlet.http does not exist import javax.servlet.http.*; |
2.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 13:59 把JAVAX。SERVLET包加入CLASSPATH |
3.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 14:08 已加了 C:\Tomcat 4.1\common\lib\servlet.jar 但是不行。 还有什么可能哪里少了东西吗? |
4.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 14:19 pardchen wrote: 打开包查看一下,是否存在那些类 |
5.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 14:37 怎么打开?他是一个jar? 如没有应怎样? |
6.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: ringayumi Posted on: 2003-09-24 14:48 jar -xvf servlet.jar set CLASSPATH=C:\Tomcat 4.1\common\lib\servlet.jar in your autoexec.bat |
7.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 14:56 运行结果如下 can't find class sun/tools/jar/main |
8.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 15:01 pardchen wrote: 用WINZIP 打开,如果没有你得去找个啦! |
9.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: jameszhang] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 15:07 jameszhang wrote: 看到了 里面所有的类都有 但编译却找不到。 有没有其它错误的可能性? |
10.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 15:12 pardchen wrote: 手工编译 javac -classpath c:\servlet.jar Your.java 看看编译是否通过呢? |
11.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 15:52 to jameszhang: 运行结果 java.lang.NullPointerException at java.util.Hashtable.put(Compiled Code) at java.util.zip.ZipFile.readCEN(Compiled Code) at java.util.zip.ZipFile.<init>(ZipFile.java:61) at java.util.zip.ZipFile.<init>(ZipFile.java:71) at sun.tools.java.ClassPath.<init>(Compiled Code) at sun.tools.javac.Main.compile(Compiled Code) at sun.tools.javac.Main.main(Main.java:465) |
12.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 15:58 pardchen wrote: 找到了吧,这个好象不是这种错误了? |
13.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 16:02 没有生成class啊。 那个结果是什么意思啊? |
14.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 16:05 pardchen wrote: 编译出错了不生成CLASS,这个结果得看你的代码了!是上面的那段吗? |
15.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 16:09 对。 最上面的那个。 |
16.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: jameszhang Posted on: 2003-09-24 16:24 { there isn't anything new and interesting, but a credit is rewarded for your effort to help (in other threads as well) -- why } pardchen wrote: 除了你的IoException ----> IOException 其余均为原样 servletOne.rar (1.31k) |
17.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 16:29 我解压了你的rar在桌面,可我这边编释还是不行。 找不到servlet是关建。 不知将程序重装是否能解决问题?头痛 C:\Documents and Settings\Administrator\桌面\servletOne.java:2: package javax.servlet does not exist import javax.servlet.*; ^ C:\Documents and Settings\Administrator\桌面\servletOne.java:3: package javax.servlet.http does not exist import javax.servlet.http.*; ^ C:\Documents and Settings\Administrator\桌面\servletOne.java:4: cannot resolve symbol symbol : class HttpServlet location: class servletOne public class servletOne extends HttpServlet{ ^ C:\Documents and Settings\Administrator\桌面\servletOne.java:6: cannot resolve symbol symbol : class HttpServletRequest location: class servletOne public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{ ^ C:\Documents and Settings\Administrator\桌面\servletOne.java:6: cannot resolve symbol symbol : class HttpServletResponse location: class servletOne public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{ ^ C:\Documents and Settings\Administrator\桌面\servletOne.java:6: cannot resolve symbol symbol : class ServletException location: class servletOne public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException{ ^ C:\Documents and Settings\Administrator\桌面\servletOne.java:13: incompatible types found : servletOne required: java.lang.Object synchronized(this){ ^ 7 errors |
18.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 16:38 就是不认我的servlet.jar 还有j2ee.jar |
19.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 16:45 classpath=C:\jdk1.3\lib\dt.jar;C:\jdk1.3\lib\tools.jar;C:\jdk1.3\jre\lib\rt.jar;C:\jdk1.3\jre\lib\i18n.jar;c:\j2ee\lib\j2ee.jar;C:\Tomcat 4.1\common\lib\servlet.jar 辛苦了! |
20.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: helloworld Posted on: 2003-09-24 17:02 呵呵,估计是j2ee.jar和servlet.jar冲突. 我看不出要安装j2EE的意义,刚学时用tomcat就够了, 深入以后,大家也是用jboss/weblogic的多. 建议把j2EE删除~~~~~~~~ 之后, 再把tomcat的那个servlet.jar复制并扔到JAVA_HOME/jre/lib/ext目录下(就可以不加servlet.jar的classpath了).就万事OK了哦. |
21.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: helloworld] | Copy to clipboard |
Posted by: pardchen Posted on: 2003-09-24 17:15 我试试看。 先谢了。 |
22.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: ajinjin Posted on: 2003-09-26 09:13 弟弟有点菜哈 |
23.Re:请帮忙:可以运行tomcat的网页例子,包括jsp和servlet.但编译servlet却总不行? [Re: pardchen] | Copy to clipboard |
Posted by: wqianghx Posted on: 2003-09-29 13:52 J2EE1。3和Tomcat4。X版本的Servlet包应该是不会冲突的。 如果你是在命令行下编译的,建议你编译前先运行 “set classpath=%servletpath%;%classpath%", 然后编译。如果你是用其他的Java开发工具, 那你要留意一下那个工具有没有自己的Classpath设置。 比如TextPad、Jpro、Jb、Tomcat、Weblogic之类的, 启动时都会设置自己的Classpath。 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |