日期:2014-05-17  浏览次数:20699 次

jsp画面加载问题
一个测试画面,代码如下:
HTML code
<%@ page contentType = " text/html;charset=gb2312" %>
  
<html>
<head>
<title>Test Action</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<%
String  name = null;
if (session.getAttribute("name")! = null )
 name = ( String )session.getAttribute("name");
String host = java.net.InetAddress.getLocalHost().toString();
%>
<body>
<br>
<br>
<center>
  The host is :<%=host %><br>
  Your session id is :<%=session.getId() %><br>
  Your session detail is :<%=session.toString() %><br>
  Your session context is :<%=session.getSessionContext() %><br><br>
<%
if (name! = null ){
 out.print( " Your name is  " + name + "<br>" );
 out.print( " The session is valid. " );
}else{
 out.print( " The session is invalid!!! " );
}
%>
<a href ="index.jsp">Return!</a>
</center>
</body>
<%
if (session.getAttribute("name")! = null )
 session.invalidate();
%>
</html>


这个画面是从另外一个画面跳转过来的,第一个画面显示正常,这个画面报错,由于对jsp不是很了解,请大家指点一下!谢谢!

报错信息如下:

11:37:15,392 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 8 in the jsp file: /test/session.jsp
Generated servlet error:
Syntax error on tokens, they can be merge to form !=

An error occurred at line: 22 in the jsp file: /test/session.jsp
Generated servlet error:
Syntax error on tokens, they can be merge to form !=

An error occurred at line: 33 in the jsp file: /test/session.jsp
Generated servlet error:
Syntax error on tokens, they can be merge to form !=


  at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErro
rHandler.java:84)
  at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher

------解决方案--------------------
session.getAttribute("name")! = null 

!和= 不能分开的吧
------解决方案--------------------
编译出错,!=有问题