<%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.io.*"%> <html> <head><title>test</title></head> ***我加了这行我这里运行OK*** <body> AAAAAAAAAAAAAA <% out.print("this the second test !"); %> </body> </html> 如果你那里再不行,那就不是代码问题了。
jakarta-tomcat-4.1.18下 一切正常
你把<%@ page contentType="text/html;charset=gb2312"%>改成下列试试 <%@ page session="true"language="java" contentType="text/html;charset=gb2312"%><% out.print("this the second test !"); %>改为<% out.println("this the second test !"); %>
你应该把整个程序和运行后的源文件放上来,还有说明你的所有的配置啊,运行的命令之类的信息。这样大家才容易全面的帮你调试啊! <% String a = "this the second test !"; %> <%=a%> 这样试试,关键如果运行后的源文件已经显示这行的话那就可能是你的浏览器的问题,而不是程序问题。对了!!突然想起你说的话!源程序在结果文件中打印出来了??你看看是否<% 或者 %>之类错用了中文符号!!重新敲一遍程序保险啊!!有时候中文字符或者隐含字符让你累死也检查不出错误啊! 重新打开空白文件,一行行老老实实重新敲一遍看看问题!!
language="java" 少了这句可以吗?
谢谢 yiweiping2003(yiweiping) 大哥, 我的问题还是解决不了,我的源码(test.jsp)如下,放在server\default\deploy\ 下面 启动jboss 3.06 后,运行 http://localhost:8083/test.jsp 在浏览器中显示 hello 没有显示 this is a test 我在classpath是设置了JBOSS_HOME E:\JBOSS JAVA_HOME E:\JDK141<%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.io.*" %> <html> hello <%out.print('this is a test');%> </html>在浏览器中点击 “查看”-> “源文件”,显示如下 <%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.io.*" %> <html> hello <%out.print('this is a test');%> </html> 然后把这个程序COPY到TOMCAT的有关目录下,执行得到正确的结果
<%@ page import="java.io.*"%>
<html>
<head><title>test</title></head> ***我加了这行我这里运行OK***
<body>
AAAAAAAAAAAAAA
<% out.print("this the second test !"); %>
</body>
</html>
如果你那里再不行,那就不是代码问题了。
一切正常
<%@ page session="true"language="java" contentType="text/html;charset=gb2312"%><% out.print("this the second test !"); %>改为<% out.println("this the second test !"); %>
jdk1.4,tomcat4,win2k Advance Server.
another pc 也不行
那直接用<%="this the second test !"%>試試
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset="gb2312"">
</head>
试一下
有三种可能:1、JSP文件名是否为全小写?
2、该文件是否在Tomcat的server.xml文件的<Context ... />指定的路径里,或者在ROOT里?
3、是否在IE中地址栏输入http://localhost:8080/contextpath/file.jsp来打开?(在“我的电脑”直接双击JSP文件名是不执行JSP语句的。)我认为你可能是1或2的问题。
1、我的文件名都是小写的
2、不明白你的意思,我的test.jsp的存放路径是
\jboss\server\default\deploy\jmx-console.war\myweb.jar\test.jsp
2、我是这样打开的
http://localhost:8083/myweb.war/test.jsp
小弟拙见,好像那句应该是<% System.out.print("this the second test !"); %>
<% System.out.print("this the second test !"); %>
http://localhost:8083/test.jsp你试一下,因为照你说的情况,服务器只是把它的Html部分正确显示了。
郁闷!
<%@ page import="java.io.*"%>
<html>
<body>
AAAAAAAAAAAAAA
<% out.print("this the second test !"); %>
bbbbbbbbbbbbbbbb
</body>
</html>
看bbbbbbbbbbbbbbbb能不能出来?
我装的是jboss,不是tomcat,
jboss我装了n遍了
<% String a = "this the second test !"; %>
<%=a%>
这样试试,关键如果运行后的源文件已经显示这行的话那就可能是你的浏览器的问题,而不是程序问题。对了!!突然想起你说的话!源程序在结果文件中打印出来了??你看看是否<% 或者 %>之类错用了中文符号!!重新敲一遍程序保险啊!!有时候中文字符或者隐含字符让你累死也检查不出错误啊! 重新打开空白文件,一行行老老实实重新敲一遍看看问题!!
少了这句可以吗?
我的问题还是解决不了,我的源码(test.jsp)如下,放在server\default\deploy\ 下面
启动jboss 3.06 后,运行 http://localhost:8083/test.jsp
在浏览器中显示 hello
没有显示 this is a test
我在classpath是设置了JBOSS_HOME E:\JBOSS
JAVA_HOME E:\JDK141<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<html>
hello
<%out.print('this is a test');%>
</html>在浏览器中点击 “查看”-> “源文件”,显示如下
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<html>
hello
<%out.print('this is a test');%>
</html>
然后把这个程序COPY到TOMCAT的有关目录下,执行得到正确的结果
<%@ page import="java.io.*"%>
<html>
<body>
AAAAAAAAAAAAAA
<% out.print("this the second test !"); %>
</body>
</html>在 apache 2.0.45 + tomcat 4.1.12 整合环境下没有问题!检查一下你的 jboss 吧!
郁闷!