js| Static | design
Introduction:
We compare it to two large Web sites for example:
51job and Zhaopin (first of all, I'm not advertising for them, I'm just using them as an example for technical comparisons)
51job is a comparison of the "Advanced" PHP technology, and the wisdom of the use of the relatively backward ASP. But we may obviously feel that the 51job reaction rate compared to Zhaopin is really too slow, why this? A careful person may be aware of it. Although the--asp uses ASP, he uses another, more ingenious technique, to generate static page technology. All the dynamic pages are basically converted into HTML static pages, without accessing the database, of course, the response is fast.
Now let's talk about how JSP translates into HTML
The first thing to do is to make a template. Suffixes are not limited, but generally use *.template examples
<title> #title #</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<link href= ". /css.css "Rel=stylesheet type=text/css>
<body>
<p align= "center" >
#title #<br><br><br>
Author: #author #<br><br>
<BR>
#content #<br><br><br><br>
</P>
</body>
To do a class or JSP file that processes the template (to illustrate the problem we start with a JSP file for example)
FilePath = Request.getrealpath ("/") + "web-inf/templates/template.htm";
Out.print (FilePath);
String templatecontent= "";
FileInputStream FileInputStream = new FileInputStream (filePath);//Read Module file
int lenght = fileinputstream.available ();
byte bytes[] = new Byte[lenght];
Fileinputstream.read (bytes);
Fileinputstream.close ();
TemplateContent = new String (bytes);
Out.print ("Below is the template content:<br>" +templatecontent+ "<br> below is the replacement HTML content <br>Templatecontent=templatecontent.replaceall ("#title #", title);
Templatecontent=templatecontent.replaceall ("#author #", editer);//replace the corresponding place in the module
Templatecontent=templatecontent.replaceall ("#content #", content);
According to the time file name
Calendar calendar = Calendar.getinstance ();
String fileame = string.valueof (Calendar.gettimeinmillis ()) + ". html";
Fileame = Request.getrealpath ("/") +fileame;//the generated HTML file save path
Out.print (TemplateContent);
FileOutputStream FileOutputStream = new FileOutputStream (fileame);//create file output stream
byte tag_bytes[] = Templatecontent.getbytes ();
Fileoutputstream.write (tag_bytes);
Fileoutputstream.close ();