Create a jsp environment on linux
I have long seen the introduction of Jsp (Java Server Pages) on foreign websites, saying that it is so good and powerful, but I only know that jsp is good and has never had the chance to use it. I heard that the configuration of jsp environment under Unix is complicated, so I have never dared to touch it. Later, I found an article written by * old in configuring a jsp environment under Linux. If I got it, I immediately took the initiative to go to the internet and wanted to try how. Unfortunately, I failed to paint the gourd as usual. So I went to search in several large bbs in China, visited a few fronts, and found some fragmented configuration methods. Most of these methods are used to run jsp with gnujsp0.9x/1.0. I configured them one by one, and the results are mostly just for ApacheJserv to run. I have been unable to run jsp. Finally, the writer decided to understand the configuration method himself, so all the packaged software downloaded back from the official website as much as possible. The following are the package software used in the configuration process of the author: Apache_1.3. (from download) ApacheJserv-1.1. (from download) gnujsp-1. (from education network) JSDK-2. (from education network) JDK-1.2. (For Linux version, downloadable) After 8 hours of continuous thinking about the installation files in gnujsp-1.0 and several installation articles on the comprehensive head. There is also a simple installation configuration article downloaded from the upload and download. The author finally successfully configured the jsp environment and successfully ran the jsp program that calls beans. The following is a detailed description of the principles, procedures, precautions and key points of installation and configuration. 1. Configuration requirements RedHat or (the author can successfully edit and configure it in systems such as TurboLinux 4.02/6.0 Bluepoint1.0/2.0) JSDK2.0 (actually, it requires a 70k) gnujsp1.0 (actually, it requires a jar file inside) or JDK-1. (both versions can successfully pass the edit and configure it) ApacheJserv1.0 or edit the make, gcc and other programs, translators and functions required 2. Basic configuration principles To enable JSP to correctly parse and run well, it is necessary to ensure that ajp1.2 (apacheJserv protocol1.2) can communicate normally on the local port 8007. Servlets need to be able to run normally, and the Jserv configuration file must be properly configured so that gnujsp can correctly parse the jsp file. This article uses static (static) translation method to edit ApacheJserv. 3. Basic steps: First of all, make sure that ApacheJserv is correctly edited and tested. Then correctly configure the configuration file of ApacheJserv so that gnujsp can parse the jsp file. The following is a diagram of the installation step: JDK-->JSDK-->apache(basic configuration)-->ApacheJserv(configuration/editing)-->apache(configuration/editing/installing) -->gnujsp-->Edit ApacheJserv configuration file-->Test-->OK 4. Detailed procedures 1. Install JDK In fact, there is no installation. You only need to copy the JDK to a fixed directory. The author here uses the binary version of JDK-1.2.2. For readers who use 1., if you choose the static method, you can use DSO mode when you fail (it is recommended that both JDK-1. versions are better to use DSO mode). #tar xfz JDK-1.2. #mv JDK-1.2.2 /www/JDK122 2. Installing JSDK is the same as installing JDK. You only need to unpack and copy it to a fixed directory. However, it should be noted that this package's files are actually only used, so you must know the path to this file. #tar xfz jsdk-2. #mv JSDK-2.0 /www/jsdk #ls -l /www/jsdk/lib total 80 -r--r--r-- 1 root root 76453 Jun 28 01:03 3. Basic apache configuration This cannot be said to be a real configuration, it is just a step that needs to generate some required .h files when unpacking the first time. Similar to pre-configuration. #tar xfz apache_1.3.#cd apache_1.3.12#./configure#cd .. This will generate a head file such as the same one. If these files are not available, the configuration of ApacheJserv or Php3 will be reported later. 4. ApacheJserv configuration and translation The instructions that need to be used here are at least: --with-apache-src= (Specify the path to the apache source code, used for static translation) --with-jdk-home= (Specify the root directory of jdk) --with-JSDK= (Specify the directory, note that it is a large JSDK!!!) As for the others, it is not necessary to write, but it is recommended to specify such as the installation directory, jdk platform number (1 or 2), etc. Where java-platform is specified like this: that is, if jdk-1 is used, it is 1 (the default is 1, you can not write it). If it is jdk-1, specify 2. #tar xfz ApacheJserv-1.1. #cd ApacheJserv-1.1.2#./configure --with-apache-src=../apache_1.3.12 --prefix=/www/jserv \>-with-jdk-home=/www/jdk122 --with-java-platform=2 \>--with-JSDK=/www/jsdk/lib/ --disable-debugging#make #make install#cd .. 5. Configuration translation of Apache Many documents about Apache configuration are explained, so I won't mention it here. #cd apache_1.3.12#./configure --prefix=/www/httpd --activate-module=src/modules/jserv/ #make #make install 6. gnujsp installation In fact, it only requires several jar files in gnujsp-1.0. #tar xfz gnujsp-1. #mkdir /www/gnujsp #cp gnujsp-1.0/lib/*.jar /www/gnujsp#mkdir /www/gnujsp/bean_jsp#ls -l /www/gnujspdrwxr-xr-x 10 root root 4096 Sep 15 15:56 bean_jsp/ -rw-rw-r-- 1 root root 125972 Sep 15 12:55 -rw-rw-r-- 1 root root 153015 Sep 15 12:55 -rw-rw-r-- 1 root root 37291 Sep 15 12:55 servlet-2. -rw-r--r-- 1 root root 38826 Sep 15 12:55 servlet-2. 7. Editing of Jserv configuration file This is the key to whether jsp can correctly parse and use it, and it is also the focus of this article. The key point is to set up the jserv related files: Or create a new properties file, and the editing order is roughly: -->-->--> Customized properties file. Now assuming that you need to define a zone called gsp, you can edit the relevant content according to the following steps and methods: *Before editing this file, please add the sentence "include /www/jserv/etc/" to the apache file. This sentence can be placed anywhere in the document, but after realizing it, it is best to put it to the end!!!! You can run this way: #echo "include /www/jserv/etc/" >> /www/httpd/conf/ After finishing it, edit it with, for example, vi editor. If you want to record all actions of jserv, it is best to allow log, remove the following statement notes: ApJServLogFile /www/jserv/logs/mod_jserv.log and find the line "# Mount point for Servlet zones", which defines the mount point of Servlet zones (similar to Linux installation points). We add the following line: ApJServMount /gsp /gsp Then find the ApJServAction keyword and add the following line: ApJServAction .jsp /gsp/gnujsp This defines the .jsp file for gnujsp to parse. This file is basically set up. *You need to set it here, find the keyword, and add the following line: =/www/jdk122/lib/ Then find the line "# Servlet Zones parameters" and modify zones=root to become: zones=root,gsp (add gsp this zone) Then add the properties line with the definition of gsp after =/www/jserv/etc/: =/www/jserv/etc/. Basically, it is set. * As for the setting, there is no need to be set, because this defines a new zone-->gsp, which works. Find: # List of Repositories This line, and add the following lines: repositories=/www/gnujsp/=/www/gnujsp/servlet-2.=/www/gnujsp/bean_jsp The third line defines the response directory of the bean, which can be defined in a casual manner. But it must exist. Find "# Servlet Aliases" line and add the alias line: ==checkclass=true,\(Please be careful not to stop the return)<pagebase=/www/httpd/htdocs,scratdir=/www/httpd/jsp,\(Please be careful not to stop the return)<debug=true,compiler=builtin-javac -classpath%classpath%:%scratdir%:/www/gnujsp/servlet-2.:/www/gnujsp/ :/www/gnujsp/bean_jsp -d %scratdir% -deprecation %source% The second line starts and ends at the end is actually the same, and the line-changing symbol is added due to the space problem. Please be sure to use the same line as much as possible!!!!!!, and note that the symbols must not be missing. Some of these parameters are explained: pagebase means that the starting directory of the jsp file is allowed to be parsed. scratchdir is a temporary directory of generated .java and .class files. Please note that this directory must be writeable for nobody!!! So you must use the chown command to change the owner and group of this directory to nobody. The following is that classpath is the path to define search, which includes the directory of the bean, otherwise there is no way to use the bean. In addition, you can also add several similar directories, but they must be defined in the above files. At this point: the basic settings are all completed. Next, you can conduct a test. 8. Test First, make sure you have re-activated apache to make all settings take effect. Then you can enter "http://localhost/gsp/Hello" in the browser. If: Example Apache JServ ServletCongratulations, ApacheJServ 1.1.2 is working! Then it means that servlets are running normally. Then, create a file: <html><body><h1>The Famous JSP Hello Program</h1><% SString s = "GNUJSP"; %>The following line should contain the text "Hello GNUJSP World!".<br>If thats not the case start debugging ...<p>Hello <%= s %> World!</body></html> Then put it in the htdocs directory and run. If it is correctly executed, it means that everything is basically normal. Next, let’s test whether gnujsp supports Chinese correctly. By modifying the above file into Chinese characters, you can see if it is correct. In the experiment of the writer, I found that gnujsp is very good for Chinese support and does not require any supplements. 5. Things to note: In the detailed steps, the author has also emphasized it many times. Improving this again. These are also key points of success: After unpacking apache for the first time, you must first run configure to generate corresponding head files. The created scratchdir directory must be written for anyone, using the nobody owner. The bean directory to be used must also be defined in the bean directory, and the bean elements that need to be used must be placed in the bean directory you specified. There is no need to modify the system's path. Some articles say it needs to be modified, but it is not necessary because there is a classpath in the configuration file. (6) End of the article The reason why this article is not very complicated to describe the configuration process and principles is so detailed, that it is hoped that readers can correctly configure the jsp environment after reading it, and do not get hurt by the jsp environment anymore. In fact, in addition to using this solution, you can also use tomcat, jrun, etc. gnujsp is just a cheap plan. Performance and functionality are not very good. The author also wrote a simple installation script to help readers install and configure the jsp environment more conveniently. For details, please refer to the author's other articles.
Related Articles
JSP exports an instance of Excel table
Below, the editor will bring you an example of JSP exporting Excel tables. The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2017-06-06JSP technology to implement dynamic pages to static pages
Implementing dynamic pages to static pages to reduce the pressure and burden on the database and server is an ideal solution in many practical development and application work. So this article will explain to you how to implement dynamic pages to static pages.2016-10-1010. Session status
10. Session status...2006-10-10Summary of four ways of passing parameters to the background by JSP
Below, the editor will bring you a summary of four ways of passing parameters to the background by JSP. The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2017-02-02Design and implementation method of JSP-based RSS reader (recommended)
Below, the editor will bring you an article on the design and implementation method of a JSP-based RSS reader (recommended). The editor thinks it is quite good, so I will share it with you now and give you a reference. Let's take a look with the editor2016-07-07How to solve the problem of importing .xls files on jsp page
There is an error in importing .xls files on the jsp page. This article will provide solutions. Friends who need to know can refer to it.2012-12-127. HTTP response status
7. HTTP response status...2006-10-10JSP method to use application to count online users
This article mainly introduces the method of using application to count online users. The code contains detailed comments for easy understanding. It is a relatively practical technique. Friends who need it can refer to it.2015-01-01JSP method to realize page displays the current system time in real time
Display the current system time in real time on the page, and it is simply implemented through jsp. The details are as follows. Interested friends can refer to the following2013-08-08The problem of garbled code in jsp value transmission local test machine without garbled code is solved
When using jsp to pass values locally, everything is normal and there is no garbled code. When placed on the test machine, it is found that there is garbled code. This article provides a detailed solution to this problem. Interested friends can refer to it.2013-04-04