| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1155 人关注过本帖
标题:新手刚上路 就碰问题 故来请教
只看楼主 加入收藏
rmfish
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-10-17
收藏
 问题点数:0 回复次数:4 
新手刚上路 就碰问题 故来请教

刚上手Jsp 现已装完jdk1.6和tomcat 并能成功打开tomcat测试网页
现在ROOT下加了一个JSP网页 内容如下:

<% @ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY BGCOLOR=cyan><font size="4">
<%!
int i=0;
%>
<%
i++;
%>
<p>你是第<% =i %>
个访问本站的客户。
</p>
</font>
</BODY>
</HTML>

但无法正确打开 网页显示如下:
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: 1 in the jsp file: /example_2.jsp
Syntax error on token "contentType", VariableDeclaratorId expected after this token
1: <% @ page contentType="text/html;charset=utf-8" %>
2: <HTML>
3: <BODY BGCOLOR=cyan><font size="4">
4: <%!


An error occurred at line: 1 in the jsp file: /example_2.jsp
contentType cannot be resolved to a type
1: <% @ page contentType="text/html;charset=utf-8" %>
2: <HTML>
3: <BODY BGCOLOR=cyan><font size="4">
4: <%!


An error occurred at line: 1 in the jsp file: /example_2.jsp
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
1: <% @ page contentType="text/html;charset=utf-8" %>
2: <HTML>
3: <BODY BGCOLOR=cyan><font size="4">
4: <%!


An error occurred at line: 10 in the jsp file: /example_2.jsp
Syntax error on token "=", @ expected
7: <%
8: i++;
9: %>
10: <p>你是第<% =i %>
11: 个访问本站的客户。
12: </p>
13: </font>


An error occurred at line: 10 in the jsp file: /example_2.jsp
Syntax error on token(s), misplaced construct(s)
7: <%
8: i++;
9: %>
10: <p>你是第<% =i %>
11: 个访问本站的客户。
12: </p>
13: </font>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
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:308)
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.10 logs.


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

Apache Tomcat/6.0.10


不知是哪里错了 所以希望有谁能指点一下 不甚感激

搜索更多相关主题的帖子: Jsp 网页 tomcat 
2007-08-05 09:15
Gramary
Rank: 4
等 级:贵宾
威 望:13
帖 子:769
专家分:0
注 册:2007-7-9
收藏
得分:0 
你JSP中 <% @ page contentType="text/html;charset=gb2312" %>
报错怎么变成 <% @ page contentType="text/html;charset=utf-8" %>


An error occurred at line: 10 in the jsp file: /example_2.jsp
Syntax error on token "=", @ expected
7: <%
8: i++;
9: %>
10: <p>你是第<% =i %> 这个错误是着里 应该写成 <%= i %> 不像你那样写的
11: 个访问本站的客户。
12: </p>
13: </font>

你先改一下,我不知道你这个怎么会有那么多的错误。



学编程不能急,要慢慢来。
2007-08-05 09:22
rmfish
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-10-17
收藏
得分:0 
回复:(rmfish)新手刚上路 就碰问题 故来请教

谢谢了 我改了 但是问题是一样的
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: 1 in the jsp file: /example_2.jsp
Syntax error on token "contentType", VariableDeclaratorId expected after this token
1: <% @ page contentType="text/html;charset=gb2312" %>
2: <HTML>
3: <BODY BGCOLOR=cyan><font size="4">
4: <%!


An error occurred at line: 1 in the jsp file: /example_2.jsp
contentType cannot be resolved to a type
1: <% @ page contentType="text/html;charset=gb2312" %>
2: <HTML>
3: <BODY BGCOLOR=cyan><font size="4">
4: <%!


An error occurred at line: 1 in the jsp file: /example_2.jsp
Syntax error, insert ";" to complete LocalVariableDeclarationStatement
1: <% @ page contentType="text/html;charset=gb2312" %>
2: <HTML>
3: <BODY BGCOLOR=cyan><font size="4">
4: <%!


An error occurred at line: 10 in the jsp file: /example_2.jsp
Syntax error on token "=", @ expected
7: <%
8: i++;
9: %>
10: <p>你是第<% =i %>
11: 个访问本站的客户。
12: </p>
13: </font>


An error occurred at line: 10 in the jsp file: /example_2.jsp
Syntax error on token(s), misplaced construct(s)
7: <%
8: i++;
9: %>
10: <p>你是第<% =i %>
11: 个访问本站的客户。
12: </p>
13: </font>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
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:308)
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.10 logs.


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

Apache Tomcat/6.0.10

2007-08-05 09:30
走刀口→超
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:5018
专家分:0
注 册:2006-3-14
收藏
得分:0 

<% @ page contentType="text/html;charset=GB2312" %>

是不是该写成:

<%@ page contentType="text/html;charset=GB2312" %>


人在江湖【走】,怎能不挨【刀】;为了能活【口】,唯有把己【超】!come on...
2007-08-05 11:01
rmfish
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-10-17
收藏
得分:0 
回复:(rmfish)回复:(rmfish)新手刚上路 就碰问...
谢谢楼上的 正解 感激不尽~~
2007-08-05 16:52
快速回复:新手刚上路 就碰问题 故来请教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017030 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved