说得不清楚
客户得到的都是html的东西啊,jsp是服务器端的

解决方案 »

  1.   

    我就是要在服务器段生成html文件,将来用户访问的时候,都只需要访问html文件,速度快很多的
      

  2.   

    jsp生成html--readtemplates ReadTemplates.javapackage ball.news;
    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;
        }}
      

  3.   

    /**
     *  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>
      

  4.   

    以上代码有错!
    请改正以下代码:

    com.lulu.jspout jf = new com.lulu.jspout("你要保存的html文件的路径");
    替换为:
    com.lulu.jspout jf = new com.lulu.jspout(1024,true);
    jf.init("你要保存的html文件的路径");
      

  5.   

    String path="%myweb%";                               
    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>");
    ...我们就设这样生成一个静态页面的。
      

  6.   

    填写内容以后直接用jsp把它按html格式生成html文件不就行了吗。把标题和生成的文件名放入数据库。
    当时候点连接指向这个文件不就行了
      

  7.   

    我的做法是先定义模板文件,用html格式,其中需要从数据库中提取的部分用标记代替,如$Title$代表在这个位置显示数据库中的Title字段,在信息提交后把模板文件读入到字符串中,再用提交上来的值替换模板里面的标记;这样可以尽量避免在java类中生成html代码,修改页面的风格也比较方便,改模板文件就行了