exception javax.servlet.ServletException: Error instantiating servlet class wm.servlet.sendMess
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
java.lang.Thread.run(Unknown Source)
root cause java.lang.Error: Unresolved compilation problems:
The import javax.servlet.http cannot be resolved
HttpServlet cannot be resolved to a type
ServletException cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type
RequestDispatcher cannot be resolved to a type
RequestDispatcher cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type wm.servlet.sendMess.<init>(sendMess.java:7)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
java.lang.Thread.run(Unknown Source)再登陆的时候报上面这个异常,在线等待
sendMess.java
package wm.servlet;import java.util.*;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;import wm.bean.messFun;public class sendMess extends HttpServlet{
public void init()throws ServletException
{
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
messFun MF=new messFun();//创建功能对象
String username="";
String title="";
String keyword="";
String email="";
String content="";
String restore="";
String msg="";//自定义错误信息
username=request.getParameter("yhm");
title=request.getParameter("title");
keyword=request.getParameter("keyword");
email=request.getParameter("email");
content=request.getParameter("content");
String ip=request.getRemoteHost();
String sj=MF.gettime(); if(username=="")
msg+="<li>用户名不能为空</li>";
else if(!(MF.validLength(username,3,12)))//验证内容的合法性
msg+="<li>用户名应在3到12位之间</li>";
if(email=="")
msg+="<li>邮箱不能为空</li>";
else if(email.equals("")||(email.indexOf('@')==-1)||(email.indexOf('.')==-1))
msg+="<li>邮箱格式不正确</li>";
if(content=="")
msg+="<li>内容不能为空</li>";
else if(!(MF.validLength(content,10,512)))
msg+="<li>内容应该在10和100字符之间</li>";
response.setContentType("text/html;charset=GBK");
if(msg.equals(""))//如果没有错误
{
boolean result=MF.addMess(ip,title,keyword,email,sj,content,restore,username);
if(result==true)
msg+="留言成功";
else
msg+="留言失败";
request.setAttribute("msg",msg);
RequestDispatcher wm=request.getRequestDispatcher("common.jsp");
wm.forward(request,response);
}
else
{
request.setAttribute("msg",msg);
RequestDispatcher wm=request.getRequestDispatcher("common.jsp");
wm.forward(request,response);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
} //Clean up resources
public void destroy()
{
}
}
我知道类名该大写,但这个应该不是主要问题
请高手帮忙解决下
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
java.lang.Thread.run(Unknown Source)
root cause java.lang.Error: Unresolved compilation problems:
The import javax.servlet.http cannot be resolved
HttpServlet cannot be resolved to a type
ServletException cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type
RequestDispatcher cannot be resolved to a type
RequestDispatcher cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type wm.servlet.sendMess.<init>(sendMess.java:7)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
java.lang.Thread.run(Unknown Source)再登陆的时候报上面这个异常,在线等待
sendMess.java
package wm.servlet;import java.util.*;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;import wm.bean.messFun;public class sendMess extends HttpServlet{
public void init()throws ServletException
{
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
messFun MF=new messFun();//创建功能对象
String username="";
String title="";
String keyword="";
String email="";
String content="";
String restore="";
String msg="";//自定义错误信息
username=request.getParameter("yhm");
title=request.getParameter("title");
keyword=request.getParameter("keyword");
email=request.getParameter("email");
content=request.getParameter("content");
String ip=request.getRemoteHost();
String sj=MF.gettime(); if(username=="")
msg+="<li>用户名不能为空</li>";
else if(!(MF.validLength(username,3,12)))//验证内容的合法性
msg+="<li>用户名应在3到12位之间</li>";
if(email=="")
msg+="<li>邮箱不能为空</li>";
else if(email.equals("")||(email.indexOf('@')==-1)||(email.indexOf('.')==-1))
msg+="<li>邮箱格式不正确</li>";
if(content=="")
msg+="<li>内容不能为空</li>";
else if(!(MF.validLength(content,10,512)))
msg+="<li>内容应该在10和100字符之间</li>";
response.setContentType("text/html;charset=GBK");
if(msg.equals(""))//如果没有错误
{
boolean result=MF.addMess(ip,title,keyword,email,sj,content,restore,username);
if(result==true)
msg+="留言成功";
else
msg+="留言失败";
request.setAttribute("msg",msg);
RequestDispatcher wm=request.getRequestDispatcher("common.jsp");
wm.forward(request,response);
}
else
{
request.setAttribute("msg",msg);
RequestDispatcher wm=request.getRequestDispatcher("common.jsp");
wm.forward(request,response);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
doGet(request, response);
} //Clean up resources
public void destroy()
{
}
}
我知道类名该大写,但这个应该不是主要问题
请高手帮忙解决下
解决方案 »
- eclipse的 struts框架下 印刷问题
- 用连接池中的连接与SQL Server连接的问题
- 100分求经验!!有没有朋友到广东北电去面试?
- MySql的驱动程序应该是哪个?搞不懂了
- jsp页面中如何取得前一页的URL
- 一个简单的问题!
- 超级菜鸟问题:tomcat配置问题!!!
- preparedStatement("xxx ?, ?, ?") setInt(1,var1) setInt(2,var1) setInt(3,var1) 也就是他们都是一个值, 请问怎么优化阿?
- 各位:jsp和javascript的相互调用???
- apache mina 或者 netty 与手机端通信。加密方案?
- 求oracle用clob类型存储大量文字信息的例子~~
- 在struts中实现删除的问题
HttpServlet cannot be resolved to a type
ServletException cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type
RequestDispatcher cannot be resolved to a type
RequestDispatcher cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type 总的来说,类库找不到