Also talk about the technology of using JSP to implement the groom and sohu news system.
Author:Eve Cole
Update Time:2009-07-02 17:12:28
I just completed such a similar system in the past two days, and I hope to discuss with you the technology of jsp implementation.
Systems like Sina sohu should be similar, that is, the background dynamically generates the front-end html page, regardless of what tools are used in the background.
Because the company forced me to build such a news system, there was no other way. I worked on it for two days and finally got it done. It will be posted on the company homepage soon.
Of course, I only made a background management thing, using jsp+javabean to dynamically generate html files.
This is how I achieved it
1. First, you need a written HTM file template, and use the Writer object to write the file in the background. Then several places that need to be replaced, such as news titles and news content, are directly replaced according to the input. The file name uses the date, such as 2000-12- 18-1.htm similar;
2. Use the jspsmartupload component for file upload, which is mainly used to upload news pictures, and then replace the img src tag in the template with the generated picture path;
3. The file title, file name, date and other information are simultaneously saved in the database. There is no need to retain other information such as news content;
4. Just call the front desk to directly retrieve the XXX.htm file name and file title from the database;
In addition, I also used a few tricks. Because the jspsmartupload component does not support file upload and renaming, I set up a temporary directory to store the uploaded image files, and then wrote a method to copy the files to the specified directory through IO operations. Of course, the name has also been changed to the name corresponding to the htm file. This is to prevent files from having the same name with multiple names. They are usually named by date or by automatically adding variables.
After preliminary testing, the speed is relatively fast because the news are all static html files.
After working hard for two days, I can finally take a little rest tonight :)
If you have made a similar system using jsp, you are welcome to communicate with us.