Home >Java >javaTutorial >What is the file after jsp is compiled?

What is the file after jsp is compiled?

(*-*)浩
(*-*)浩Original
2019-05-18 15:09:305850browse

Perhaps most Jsp developers will not pay much attention to the Java files generated by Jsp after writing the program and passing the test. In fact, through Java code, the true meaning of the program code can be better reflected, which is helpful for further research on the background operation of the program code. The situation is very helpful.

What is the file after jsp is compiled?

##For example, when writing code in Jsp, sometimes use <%! %>, sometimes use <% %>, with or without an exclamation mark, in the end Is there any difference? (The difference between Jsp code with exclamation mark and without exclamation mark) This kind of problem is generally not covered in tutorials. Where to find the breakthrough point of the problem - the Java file generated by Jsp! Therefore, for Jsp development, it is necessary to know this skill.

For Tomcat, the Java files generated by the JSP page are placed under the Web application corresponding to the work path. For example:

D:/Tomcat5.5/webapps/test/test.jsp

Generate the corresponding java file

D:/Tomcat5.5/work /Standalone/localhost/test/test.java

Relationship between Jsp and Servlet

1. JSP files must be run in the JSP server.

2. JSP files must generate Servlets before they can be executed.

3. The first visitor to each JSP page is very slow because it must wait for the JSP to be compiled into a Servlet.

4. Visitors to the JSP page do not need to install any client, or even an operating environment that can run Java, because the JSP page delivers a standard HTML page to the client.

5. The static content of the JSP page and the JSP script will be converted into the xxxService() method of the Servlet, similar to the service() method when creating a Servlet by yourself.

6. The JSP declaration part is converted into the member part of the Servlet. All JSP declaration parts can use private, protected, public, static and other modifiers, but not elsewhere.

7. JSP output expression (<%= ..%> part), the output expression will be converted into the output statement in the xxxService() method of Servlet.

8. The nine built-in objects are either formal parameters of the xxxService() method or local variables of the method, so the nine built-in objects can only be used in JSP scripts and output expressions.

From the above points 5 and 6, we can actually explain the difference between Jsp code with exclamation mark and without exclamation mark.

How to specify the path of the Java file generated by Jsp under Tomcat?

When you need to customize the location of the Java file generated by Jsp, you can do it through the following two methods:

Method 1. In the tomcat configuration file server.xml (path: tomcat path\conf), find: , add the workDir="" attribute as above, "" Write your path to .java/.class.

Method 2. Go to conf/Catalina/localhost and find your project. xml configuration file, find the code in method 1, and the subsequent operations are the same as method 1.

The above is the detailed content of What is the file after jsp is compiled?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:How to write jspNext article:How to write jsp