jsp文件放哪里才可以正确运行

来源:百度知道 编辑:UC知道 时间:2024/06/20 04:55:54
我是一个新手.在网上刚学习了tomcat的配置.是很详细的那个.所有步骤都成功了.现在我照书本上写了一个JSP程序,就是helloworld.jsp,我把他放到了D:\Tomcat\webapps\myapp,可是当我(端口我安装tomcat的时候改为9090)在浏览器输入http://localhost:9090/myapp/helloworld.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: Unable to compile class for JSP:

An error occurred at line: 11 in the jsp file: /helloworld.jsp
The method parselnt(String) is undefined for the type Integer
8: <center>
9: <h1>
10: <%
11: int times=Integer.parselnt(request.getParameter("times"));
12:

你用的方法是对的。
tomcat作为服务器,怎么能不能编译jsp呢?1楼是外行!

错误在这:
<%
int times=Integer.parselnt(request.getParameter("times"));

times这个变量你没有办法从页面获得到,所以出错!
解决方案就是把它去掉:
这样写:

<h1>
<%
out.println("HelloWorld!");
out.println("<br>");
%>
</h1>

就OK了!

tomcat不能编辑类为整个JSP页面,建议更改一下路径!

//Integer.parseInt(参数不能为空)
//修改成这样就行了
<%
int times=0;
String str = request.getParameter("times");
if(str != null)
{
times = Integer.parselnt(request.getParameter("times"));
}
for(int i=0;i<=times;i++)
{
out.println("HelloWorld!");
out.println("<br>");
}
%>