页面出现错误,请大家看看是什么原因.

houfeng_dao 2006-02-17 10:02:50
页面一为登陆界面,跳到一个验证移面,使用了JAVA BEAN,
错误提示为:
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: /header.jsp(0,0) Page directive: can't have multiple occurrences of contentType
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:49)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:383)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:95)
at org.apache.jasper.compiler.Validator$PageDirectiveVisitor.visit(Validator.java:115)
at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:235)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1031)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:187)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1045)
at org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:274)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1031)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:187)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
at org.apache.jasper.compiler.Validator.validate(Validator.java:536)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:186)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:427)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:142)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:627)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:382)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:306)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:391)
at org.apache.jsp.checklogin_jsp._jspService(checklogin_jsp.java:68)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:92)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:162)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:240)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:200)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:146)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:144)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2358)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:133)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:594)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:127)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:596)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:433)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:948)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:152)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

请问是哪发方面出现错误.
...全文
140 点赞 收藏 16
写回复
16 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
feixianking 2006-02-17
text/html; charset=gb2312
中间有空格和没空格是不一样的
回复
feixianking 2006-02-17
就是少了<%@ page contentType="text/html; charset=gb2312"%>
这个是指定编码的,不能少
你的错误肯定是
<%@ page contentType="text/html; charset=gb2312" %>和<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
这些不一致才出现的,检查所有的相关的JSP文件,包括你include进来的,都要保持一致才行
回复
houfeng_dao 2006-02-17
恩,是啊,谢谢啊 
不知道是什么原因?
回复
feixianking 2006-02-17
#####好了,我搞好了,只要将head.jsp中的<%@ page contentType="text/html; charset=gb2312"%>
去掉就行了.###

有中文的时候又要出问题了~
回复
infowain 2006-02-17
大概是你这一行里面有什么奇怪的字符,你把其他页面上的copy过来,试试看,应该也是好的。
回复
infowain 2006-02-17
大概是你这一行里面有什么奇怪的字符,你把其他页面上的copy过来,试试看,应该也是好的。
回复
houfeng_dao 2006-02-17
好了,我搞好了,只要将head.jsp中的<%@ page contentType="text/html; charset=gb2312"%>
去掉就行了.
不过在head.jsp和shopping.jsp中好象都是用的gb2312啊,为什么会出错误呢?
回复
houfeng_dao 2006-02-17
在login.jsp的那句啊,不行啊,去掉后还是那样子
回复
feixianking 2006-02-17
<%@ page contentType="text/html; charset=gb2312" %>
把charset=gb2312" %>中间的空格去掉看看
回复
feixianking 2006-02-17
这个是header.jsp ?
你检查一下<%@ page contentType="text/html; charset=gb2312" %>和<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
空格也要一样才行
回复
houfeng_dao 2006-02-17
用户名不是hellking 时跳转到 nextpage="login.jsp";是正确的.
回复
houfeng_dao 2006-02-17
上面是head.jsp
shopping.jsp:
<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="com.jspdev.ch6.*"%>
<jsp:useBean id="products" class="com.jspdev.ch6.Products" scope="session"/>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<LINK href="hellking2.css" type=text/css rel=stylesheet>
<body>
<%@ include file="header.jsp"%>
<center>
<form action="cart.jsp" method=get>
<table width="75%" border="1" bordercolor="#006633">
<tr bgcolor="#999999">
<td>id</td>
<td>名称</td>
<td>价格</td>
<td>是否有库存</td>
<td>出版社</td>
</tr>
<%
java.util.Vector v=products.getItems();
java.util.Enumeration e=v.elements();
while(e.hasMoreElements())
{
Item item=(Item)e.nextElement();

%>
<tr>
<td><input type="checkbox" name="itemId" value="<%=item.getItemId()%>"></td>
<td><%=item.getDescription()%></td>
<td><%=item.getPrice()%></td>
<td><%=item.getAvailable()%></td>
<td><%=item.getProducer()%></td>
</tr>
<%}%>
<tr align=left><td colspan=5 ><input type=submit value="add" name="action"></td></tr>
<tr align=left><td colspan=5><a href="cart.jsp">购物车</a>『』<a href="logout.jsp">注销</a></td></tr>
</table>
</form>
</center>
<%@ include file="tail.jsp"%>
</body>
</html>
回复
houfeng_dao 2006-02-17
<%@ page contentType="text/html; charset=gb2312"%>
<LINK href="hellking2.css" type=text/css rel=stylesheet>
<center>
======================================<br>
  一个简单的购物车程序<br>
=======================================<br>
欢迎您!
<jsp:getProperty name="cart" property="userId"/>
.当前的时间是:<%=new java.util.Date().toLocaleString()%>
<br>
</center>
回复
feixianking 2006-02-17
can't have multiple occurrences of contentType

header.jsp页面用了两种不同的contentType
把header.jsp贴出来~
检查一下是不是都用了<%@ page contentType="text/html; charset=gb2312" %>
回复
houfeng_dao 2006-02-17
验证移面为:
<jsp:useBean id="cart" class="com.jspdev.ch6.Cart" scope="session">
<jsp:setProperty name="cart" property="*"/>
</jsp:useBean>
<% session.setMaxInactiveInterval(900);//设置session超时为30分钟%>
<%
String nextpage;
if(cart.getUserId().equals("hellking"))nextpage="shopping.jsp";
else nextpage="login.jsp";
%>
<jsp:forward page="<%=nextpage%>"/>
是飞思书上的原程序,好像错误的!请大家指教
回复
houfeng_dao 2006-02-17
登陆界面为:
<%@ page contentType="text/html; charset=gb2312" %>
<% session.invalidate() ;%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<LINK href="hellking2.css" type=text/css rel=stylesheet>

<body>
<center>
<hr>
::请输入一个用户标识后点击登录::<br>::只有用户名为"hellking"才能登录::
<form action="checklogin.jsp" method=get>
<table width="30%" border="1">
<tr bgcolor="#336600">
<td>用户登录</td>
</tr>
<tr align="center" bgcolor="#CCCCCC">
<td>用户名 :<input type="text" name="userId"></td>
</tr>
<tr align="center" bgcolor="#CCCCCC">
<td>用户密码:<input type="password" name="password"></td>
</tr>
<tr align="center" bgcolor="#993399">
<td align="center"><input type="submit" value="登录"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2006-02-17 10:02
社区公告
暂无公告