Tomcatservlet URL mapping

xiaoxiao2021-03-06  61

This article is from http://blog.9cbs.net/step123/rchive/2004/08/16/servlet1.aspx

Tomcat4 and Tomcat5's Soul Array

As a new hand of Tomcat, I was confused for this question for a long time, and I was too simple to write, I didn't involve; I was posted on 9cbs, but I didn't want the answer. I was inspired yesterday, and I was completely solved in my heart. It's really simple, exiting, for the SERVELT / JSP's student, discusses less and walk less.

I always thought that the latest version is the most perfect function, so I use Tomcat5.0.19, but according to the book, I have to compose each servlet, and the web-INF / Web.xml in the project directory is similar to the following. Code:

CounterServlet

Mypack.counterServlet

CounterServlet

/ counter

Later, I learned from multiple parties, I know that Tomcat has an invoker servlet, as long as the following code is added to Web.xml:

Invoker

/ servlet / *

>

Use the http: // localhost: 8080 / project directory name / servlet / servlet name, if the project is ROOT, where the project catalog can save the http: // localhost: 8080 / servelt / servlet name. But I used the above method in Tomcat5 in Tomcat5, which is always unsuccessful (other configuration is correct), and the Tomcat's DOS window appears multi-line "serious" words, prompts in Web.xml, even the basic Tomcat default page error, Remove the above servlet-mapping, there is no problem. Later, I took a closer look at the post on the Internet. I found that the people who talk about the reactor are Tomcat4, and I also heard that Tomcat5 is a little change in Tomcat4, so it has been Tomcat4.1.30 from the official website, and then press the above method, Actually. Naturally, my machine is completely used in Tomcat4. Since I have a Win2K WinXP dual system, in order to understand the new features of Tomcat5, Tomcat5 is also installed on another system, but the debugging or use Tomcat4, this question is also put down.

I learned Tomcat 4.1.12, which is enabled by default. Due to the disclosure of a security defect, this subsequent version, the caller is disabled by default. If you want to enable, you need to cancel the servlet-mapping below the conf / web.xml file. Open the corresponding web.xml, found that there is really

Invoker

/ servlet / *

->

However, add an comment, disabled. To be lifted, don't add again, just use the comment to get out of it (I didn't pay attention, huh, huh. I think of the corresponding web.xml of Tomcat5, it also has these items, which is added There must be this feature! So switching the system, run, or the above error. Oh, yes, in the web.xml configuration, pay attention

,

Corresponding relationship, view Tomcat4 and Tomcat5 respectively

I really discovered

Invoker

Org.apache.catalina.servlets.invokerseervlet

Debug

0

2

The difference is that in Tomcat5, the above code has been added to be disabled, and Tomcat4 is not, this explains why Tomcat5 is always wrong. So immediately remove the comment, try Tomcat5, initialization did not appear "serious" words, running no problem, another question solved.

In summary, in Tomcat4, the servlet caller is enabled, only uses the name INVOKER.

The comment is clicked;

In Tomcat5, in addition to this, you have to remove the same name.

The comment.

Another attached: Tomcat4 highest version 4.1.30, Tomcat5 latest version 5.0.27 can be downloaded in Tomcat official address

http:// http://jakarta.apache.org/site/binindex.cgi download

=============================================================================================================================================================================================================

View Tomcat Release-Note (I use of version: 5.0.25), will find the following paragraph:

---------------------------------------------------------------------------------------------------------------------------------------

ENABLING Invoker Servlet:

---------------------------------------------------------------------------------------------------------------------------------------

Starting with Tomcat 4.1.12, The Invoker Servlet Is No Longer Available By

DEFAULT IN All WebApps. Enabling it for all webapps is possible by editing

$ Catalina_home / conf / web.xml to uncomment the "/ servlet / *" servlet-maping

DEFINITION.

Using the invoker servlet in a production environment is not recommended and

IS unsupported.

In addition, I am reading

At the time, the book is just a light written.

I said a word that is related to the / servlet mapping. This point, I don't know how many heroes!

Note: The test is successful in 4.1.30, I think there is a problem. My current project uses Tomcat-4.1.24 version, does not modify web.xml,

Can't do / servlet this mapping. Referring to the person of this article, you should be based on the instructions in Tomcat's release-note.

转载请注明原文地址:https://www.9cbs.com/read-118959.html

New Post(0)