JSP读文件代码
<%@ page contentType="text/html; charset=gbk" language="java" import="java.io.*" buffer="64kb" %>
<%
String path_in = "";
String content = "";
path_in = request.getRealPath("/")+"admin"+File.separator+"temp_1.txt";
out.println(path_in);
try
{
BufferedReader in = new BufferedReader (new FileReader(path_in));
String file = "";
String temp = "";
while((temp=in.readLine())!=null)
{
file+=temp;
out.println("writer.println(\""+temp+"\");");
}
in.close();
out.println(file);
out.flush();
}
catch(Exception e)
{
out.println(e);
e.printStackTrace();
}
%>
----------
说明:也许你读出来的是未被显示的东西,可以查看网页源代码,完全显示。
相关文档:
500错误,classnotfound异常,代码没有问题,数据库也没问题,打了补丁,装了驱动,但是在TOMCAT上找不到那个驱动而引发的错误。。。
解决办法:首选项设置里,MyRclipse->J2EE Project->Web Project->Deployment勾上那三个驱动。 ......
1. RequestDispatcher.forward()
是在服务器端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet or JSP到另外一个Servlet,JSP 或普通HTML文件,也即你的form提交至a.jsp,在a.jsp用到了forward()重定向至b.jsp,此时form提交的所有信息在 b.jsp都可以获得,参数自动传递. 但forward()无法重定向至有frame ......
<script language="javascript">
var times=6;
clock();
function clock()
{
window.setTimeout('clock()',1000);
times=times-1;
time.innerHTML =times;
}
</script>
<head>
<meta http-equiv= "Refresh" content= "5;url=index.jsp "& ......
'-------------------------------------------------------------------以下是登录代码
<%@ page contentType="text/html; charset=gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3 ......