说得不清楚
客户得到的都是html的东西啊,jsp是服务器端的
客户得到的都是html的东西啊,jsp是服务器端的
解决方案 »
- 如何在打开首页的时候加载数据库数据
- Excel 导出提示打开和保存 jxl
- My97DatePicke 平面日历设置默认日期的问题
- 如何在windows启动后就在后台执行我的java程序?
- apache urlrewrite 规则问题
- SimpleDateFormat日期转换问题
- 问一个关于显示数据的问题.......高手赐教
- 加急!!!对数据进行分类的问题(在线等解)
- 谢谢先_安全机制的问题(马上给分,在线等)
- jsp向oracle数据库中查入数据顺序错乱
- 怎么用cookie的getMaxAge()方法获取cookie的存活时间都是“-1”呢
- 对于页面的访问控制,是不是只有JSP才可以完成.javascript是不是也能够,实现页面的访问控制,说说!
import java.io.*;
import java.util.*;public class ReadTemplates
{ private String temp = null;
private Object a = new Object(); public ReadTemplates()
{
} public String getTlpContent(String s)
{
if(temp == null)
synchronized(a)
{
if(temp == null)
try
{
System.out.println("----------------------------");
temp = a(s);
//System.out.println("test the temp"+temp);
}
catch(Exception e)
{
System.out.println("get tlpconente error"+e.getMessage());
}
}
return temp;
} private synchronized String a(String s)
{
String s1 = null;
try
{
FileInputStream fileinputstream = new FileInputStream(s);
int i = fileinputstream.available();
byte abyte0[] = new byte[i];
fileinputstream.read(abyte0);
fileinputstream.close();
s1 = new String(abyte0);
}
catch(IOException e)
{
System.out.println("ioexception error"+e.getMessage());
}
return s1;
}}
* file:JspOut.java
*/
package com.lulu.jspout;import javax.servlet.jsp.JspWriter;
import java.io.*;public class JspOut
extends JspWriter
{
private File f = null;
private FileOutputStream fs = null;
private PrintWriter pw = null; public JspOut(int bufferSize,boolean autoFlush)
{
super(bufferSize,autoFlush);
} public void init(String fileName)
throws java.io.FileNotFoundException
{
this.f = new File(fileName);
this.fs = new FileOutputStream(f);
this.pw = new PrintWriter(fs);
} public void write(char[] ch,int offset,int length)
{
this.pw.write(ch,offset,length);
} public void write(String x)
{
this.pw.write(x);
} public void write(int x)
{
this.pw.write(x);
} public void write(double x)
{
this.pw.write(x + "");
} public void write(float x)
{
this.pw.write(x + "");
} public void clear()
{} public void clearBuffer()
{} public void close()
throws java.io.IOException
{
this.pw.close();
this.fs.close();
} public void flush()
{} public int getRemaining()
{
return JspWriter.DEFAULT_BUFFER;
} public void newLine()
{
this.pw.println();
} public void print(boolean b)
{
this.pw.print(b);
} public void print(char c)
{
this.pw.print(c);
} public void print(char[] s)
{
this.pw.print(s);
} public void print(double d)
{
this.pw.print(d);
} public void print(float f)
{
this.pw.print(f);
} public void print(int i)
{
this.pw.print(i);
} public void print(long l)
{
this.pw.print(l);
} public void print(java.lang.Object obj)
{
this.pw.print(obj.toString());
} public void print(java.lang.String s)
{
this.pw.print(s);
} public void println()
{
this.pw.println("\r\n");
} public void println(boolean x)
{
this.pw.println(x + "");
} public void println(char x)
{
this.pw.println(x + "");
} public void println(char[] x)
{
this.pw.println(new String(x) + "");
} public void println(double x)
{
this.pw.println(x + "");
} public void println(float x)
{
this.pw.println(x + "");
} public void println(int x)
{
this.pw.println(x + "");
} public void println(long x)
{
this.pw.println(x + "");
} public void println(java.lang.Object x)
{
this.pw.println(x.toString());
} public void println(java.lang.String x)
{
this.pw.println(x);
}
}
下面是Jsp文件
<%@ page contentType="text/html; charset=GBK"%>
<%
// 从这里接收发布的新闻,假如发布的新闻保存在String类型的news中
// 至于news从何处得到那是你的事,可以从数据库,也可以从文本文件,或者word文件
String news = "重大新闻"; // 将该行代码改写,得到你的新闻
com.lulu.jspout jf = new com.lulu.jspout("你要保存的html文件的路径"); JspWriter tmp = out;
out = jf;
%>
<html>
<body>
这里你可以使用任何的网页制作工具对你的新闻样式进行编辑,生成的html文件即你所要的,但要注意
需要将你的样式表,图片文件放置在和你的html文件同样的目录或者访问路径下。
</body>
</html>
<%
out = tmp;
%>
<html>
<body>
文件生成完成,<a href="<%="你要保存的html文件的路径"%>">请查看</a>
</body>
</html>
请改正以下代码:
将
com.lulu.jspout jf = new com.lulu.jspout("你要保存的html文件的路径");
替换为:
com.lulu.jspout jf = new com.lulu.jspout(1024,true);
jf.init("你要保存的html文件的路径");
String fileName = "index.html"
String title = "我的html页面";
File f = new File(path+fileName);
bw = new BufferedWriter(new FileWriter(f));
bw.write("<html>\n<head>");
bw.write("<head><title>" + title + "</title></head>");
bw.newLine();
bw.write("<body>");
...我们就设这样生成一个静态页面的。
当时候点连接指向这个文件不就行了