我做了两个文件
(1)ch7-1
<html>
<title>信息输入表单</title>
<body>
<form action="ch7-1.jsp" method="post">
<table border="1">
<tr><td bgcolor="yellow">姓名:</td>
<td><input type="text" name="name"></td></tr>
<tr><td bgcolor="yellow">住址:</td>
<td><input type="text" name="addr"></td></tr>
<tr><td bgcolor="yellow">E-mail:</td>
<td><input type="text" name="email"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="确定">
<input type="reset" value="取消">
</td></tr>
</table>
</form>
</body>
</html>
(2)ch7-1.jsp文件
<html>
<title>getParameter方法使用</title>
<body>
<%
string name=request.getparameter("name");
string email=request.getparameter("email");
string address=request.getparameter("addr");
%>
<%=name%><br>
E-mail <%=email%><br>
<%=adress%>
</body>
</html>
运行tomat6.0时页面显示的错误提示如下:
http://127.0.0.1:8080/myapp/ch7-1.jsp
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
string cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
string cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
string cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest
An error occurred at line: 11 in the jsp file: /ch7-1.jsp
Generated servlet error:
adress cannot be resolved
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:354)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
string cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
string cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
string cannot be resolved to a type
An error occurred at line: 4 in the jsp file: /ch7-1.jsp
Generated servlet error:
The method getparameter(String) is undefined for the type HttpServletRequest
An error occurred at line: 11 in the jsp file: /ch7-1.jsp
Generated servlet error:
adress cannot be resolved
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:329)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:314)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.2 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.2
由于我是自学的 所以不知道问题出现错误的原因 希望能够得到各位的帮助
谢谢!!!
急!急!急!急!急!急!急!急!急!急!急!急!
----------------解决方案--------------------------------------------------------
String,首字母要大写,
getParameter("name");
大小写是有区别的.
----------------解决方案--------------------------------------------------------
谢谢了 版主!!~
----------------解决方案--------------------------------------------------------
平时自己看打出的代码颜色是什么样?正确时颜色是不一样的。
----------------解决方案--------------------------------------------------------