求助!jsp代码有错。。。
代码:
<%@ Page contentType="text/html" pageEncoding="GBK" %>
<%@ Page import="java.util.*"%>
<html>
<head><title>我的网页myweb</title></head>
<body>
<%
PageContext.setAttribute("name",王某某);
%>
<%
String username=(String)PageContext.getAttribute("name");
%>
姓名:<%=username%>
</body>
</html>
报错:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: /jsp/page_demo1.jsp(1,5) Invalid directive
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:88)
org.apache.jasper.compiler.Parser.parseDirective(Parser.java:473)
org.apache.jasper.compiler.Parser.parseFileDirectives(Parser.java:1749)
org.apache.jasper.compiler.Parser.parse(Parser.java:127)
org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:120)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:180)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.
[解决办法]
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%><% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'MyJsp.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> </head> <body> <% pageContext.setAttribute("name", "王某某"); %> <% String username = (String) pageContext.getAttribute("name"); %> 姓名:<%=username%> </body></html>
[解决办法]
[解决办法]
<%@ Page contentType="text/html;charset=GBK" pageEncoding="GBK" %>
PageContext.setAttribute("name",王某某);
内置变量 开始是小写
pageContext.setAttribute("name",王某某);
[解决办法]
org.apache.jasper.JasperException: /jsp/page_demo1.jsp(1,5) Invalid directive
五行一列
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html