首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

java.lang.NoClassDefFoundError: javax.servlet.http.HttpServletRequest

2014-01-26 
测试目的: 当页面a.jsp向页面b.jsp提交 b.jsp通过request.getParameter( 属性名 )获得相应提交值 当a.jsp

测试目的:
当页面a.jsp向页面b.jsp提交
b.jsp通过request.getParameter( "属性名 ")获得相应提交值
当a.jsp没有提交相应属性值时,通过Exception_other类来处理该异常
问题:报异常
----------------- a.jsp ---------------
<%@ page language= "java " import= "java.util.* " pageEncoding= "UTF-8 "%>
<html>
<head> </head>
<body>
<form name= "form1 " method= "post " action= "b.jsp ">
请输入用户姓名: <input type= "text " name= "username ">
<input type= "submit " name= "Submit " value= "提交 ">
</form>
</body>
</html>

---------------- b.jsp -----------------
<%@ page language= "java " import= "java.util.*,com.cn.Exception_other " pageEncoding= "UTF-8 "%>
<html>
<body>
<%
String username =
Exception_other.operatGetMothod(request, "username ");
%>
<%=username%>
</body>
</html>
----------- com.cn.Exception_other ----------
package com.cn;

import javax.servlet.http.HttpServletRequest;

public class Exception_other {

private static String getStr = " ";
public static String operatGetMothod(HttpServletRequest request,String str){

try {
getStr = request.getParameter(str);
if(getStr.equals(str)){
getStr = str;
}else{
getStr = " ";
}
} catch (Exception e) {
getStr = " ";
}
return getStr;
}
}
========================所报错误========================
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax/servlet/http/HttpServletRequest
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.b_jsp._jspService(b_jsp.java:63)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NoClassDefFoundError: javax.servlet.http.HttpServletRequest
com.cn.Exception_other.operatGetMothod(Exception_other.java:11)
org.apache.jsp.b_jsp._jspService(b_jsp.java:49)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


--------------------------------------------------------------------------------


------解决方法--------------------------------------------------------
<%@ page language= "java " import= "java.util.*,com.cn.Exception_other " pageEncoding= "UTF-8 "%>         

热点排行