我电脑XP系统
安装的JBUILDER2006 自带JDK1.5和TOMCAT5
以前运行JAVA程序正常JDK没问题
现在运行servlet程序 总是出HTTP 500错误 抛异常
TOMCAT的路径应该是集成好的啊
把代码贴出来 希望各位帮忙
servlet代码
package demo;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Checkusers extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK";
//Initialize global variables
public void init() throws ServletException {
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String n=request.getParameter("username");
String name=new String(n.getBytes());
String p=request.getParameter("password");
String pass=new String(p.getBytes());
out.println("<html>");
out.println("<head><title>Checkusers</title></head>");
out.println("<body bgcolor=\"#ffffff\">");
out.println("用户名:"+name+"<br>密码:"+pass);
out.println("</body>");
out.println("</html>");
out.close();
}
//Clean up resources
public void destroy() {
}
}
HTML代码
<html>
<head>servlet测试
</head>
<body>
<form method="POST" action="Checkusers">
<table>
<tr>
<td colspan="2" align="center">用户登陆</td>
</tr>
<tr>
<td>用户名</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td colspan="=2" align="center"><input type="submit" value="提交"></td>
</tr>
</table>
</form>
</body>
</html>
错误提示:
D:\安装程序\Jbuilder\jdk1.5\bin\javaw -classpath "D:\安装程序\Jbuilder\thirdparty\jakarta-tomcat-5.5.9\bin\bootstrap.jar;D:\安装程序\Jbuilder\jdk1.5\lib\tools.jar" "-Dcatalina.home=D:/安装程序/Jbuilder/thirdparty/jakarta-tomcat-5.5.9" org.apache.catalina.startup.Bootstrap -config C:\demo\Tomcat\conf\server8083.xml start
2007-3-21 20:15:48 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8083
2007-3-21 20:15:48 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 6046 ms
2007-3-21 20:15:48 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2007-3-21 20:15:49 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/5.5.9
2007-3-21 20:15:49 org.apache.catalina.core.StandardHost start
信息: XML validation disabled
2007-3-21 20:15:52 org.apache.catalina.realm.JAASRealm setContainer
信息: Set JAAS app name Catalina
2007-3-21 20:15:53 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8083
2007-3-21 20:15:53 org.apache.catalina.startup.Catalina start
信息: Server startup in 5016 ms
2007-3-21 20:15:55 org.apache.catalina.core.ApplicationContext log
信息: Marking servlet checkusers as unavailable
2007-3-21 20:15:55 org.apache.catalina.core.ApplicationContext log
严重: Error loading WebappClassLoader
delegate: false
repositories:
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@1a082e2
demo.Checkusers
java.lang.ClassNotFoundException: demo.Checkusers
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1027)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
2007-3-21 20:15:55 org.apache.catalina.core.StandardWrapperValve invoke
严重: Allocate exception for servlet checkusers
java.lang.ClassNotFoundException: demo.Checkusers
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1332)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1181)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1027)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:750)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:130)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
----------------解决方案--------------------------------------------------------
怎么每人给点意见啊
查了半天也查不出来 千里冰峰在不在啊
----------------解决方案--------------------------------------------------------
java.lang.ClassNotFoundException: demo.Checkusers =======>没找到类
<form method="POST" action="Checkusers"> ==> checkusers c要小写
----------------解决方案--------------------------------------------------------
我后来也以为是那里小写 可改了之后还是不对
----------------解决方案--------------------------------------------------------
servlet要在web.xml文件中配置你的这个文件呢?
----------------解决方案--------------------------------------------------------
不是吧!个人觉得web。xml没有错
既然
信息: Marking servlet checkusers as unavailable
说明装载失败――从下面看应该是类编译错误,或者你的web-inf/classes/demo/下没有这个类
包结构是正确的,从错误提示看配置应该没有问题!应该是类不存在或者最后没有放到web-inf/classes/下
package demo;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class Checkusers extends HttpServlet {
----------------解决方案--------------------------------------------------------
楼上你分析的是正确的 因为我刚开始学这里很多地方都不明白
今天去学校机房运行下是对的
又对比了在家做的那个 结果发现目录不正确
servlet编译后的class文件应该在WEB-INFO目录下的classes文件夹下的
可是我在家用JBUILDER2006编译后没有产生classes目录 里面根本就没有.class文件
不知道是为什么 JBUILDER不是集成好了JDK和TOMCAT吗 难道还要配置下?
还有是不是在创建模块或是servlet时要选择路径呢?
请大家帮忙解决下 谢谢!!!
----------------解决方案--------------------------------------------------------
补充下 问题就是Jbuilder2006运行 servlet程序 编译后在WEB-INFO目录下产生不了classes文件夹 里面没有servlet的class文件 就是这个问题
----------------解决方案--------------------------------------------------------
不是吧,应该不会阿,我用过jbuilder阿,集成很好的啊!重来没有出现过这个问题
嘿嘿――为了扩大eclipse阵营,推荐使用eclipse + myeclipse开发j2ee
----------------解决方案--------------------------------------------------------
我也不知道怎么回事你用的2005吧 我用的2006
其实我也不想用这个笨拙的家伙 但是教材就要用这个
我见很多人都在用ECLIPSE~!
----------------解决方案--------------------------------------------------------