/servlet URL mapping in tomcat

Source: Internet
Author: User
Tags tomcat

This article originates from http://blog.csdn.net/step123/archive/2004/08/16/servlet1.aspx

<?xml:namespace prefix = o ns = "Urn:schemas-microsoft-com:office:office"/>

trapped in Tomcat4 and Tomcat5 the mihunzhen of the servlet caller

As a tomcat novice, I was puzzled for a long time, the book is too simple to write, did not relate to, once posted on the CSDN, but did not get the answer I want. Yesterday's sudden inspiration, after the machine test, to completely solve the heart of doubt. Really very simple, now issued to servelt/jsp Xueyou together to explore, less detours.

I always thought the latest version was the most functional, so I used the tomcat5.0.19, but as per the book I make up each servlet, debugging in the project directory in the Web-inf/web.xml add code similar to the following:

 

 

Counterservlet

Mypack. Counterservlet

 

 

Counterservlet

/counter

 

Later, after many inquiries, it became known that Tomcat had a caller (Invoker servlet), as long as the following code   was added to the web.xml:

  

Invoker

/servlet/*

< span>>

Directly with http://localhost:8080/project directory name/servlet/servlet name of the way directly debugging, if the project is root, the project directory can be province or Http://localhost:8080/servelt/servlet name. But I use the above method in TOMCAT5 is always unsuccessful (all other configurations are correct), and start Tomcat's DOS window appears multiple lines "serious" words, Hint wrong on the web.xml, even basic Tomcat default page error, the above servlet-mapping removed, there is no more problems. Then carefully looked at the online posts, found that the Internet to talk about the caller's NPC is TOMCAT4, but also heard that tomcat5 relative to Tomcat4 is some changes, so from the official online tomcat4.1.30 version, and then try the above method, incredibly became. Naturally my on the machine also completely switch to TOMCAT4. Because I have WIN2K+WINXP dual system, in order to understand the new features of TOMCAT5, in another system also equipped with TOMCAT5, but debugging or use of TOMCAT4, this question also put down.

It was only yesterday that the caller was enabled by default, due to the revelation of a security flaw, so that later versions of the tomcat4.1.12 are disabled by default. If you want to enable it, you need to uncomment the servlet-mapping in the Conf/web.xml file without the element below. Open the corresponding web.xml and find that there really are

 

 

 

Invoker

/servlet/*

   

-->

Just added an annotation character, disabled. To lift the ban, there is no need to add, only use the annotation to remove the line (then I did not pay attention to it, hehe.) Take it for granted, I looked at the corresponding tomcat5 of the web.xml, it also has these items, is added to the note, the phase must have this function ah. Then switch the system, run, or the above error. Oh, yes, in the Web.xml configuration, pay attention to, the corresponding relationship, in time to view the TOMCAT4 and TOMCAT5 respectively, really found

Invoker

       

Org.apache.catalina.servlets.InvokerServlet

       

       

Debug

0

       

2

The difference is that in TOMCAT5, the above code adds an annotation character that is disabled, and TOMCAT4 does not, which explains why TOMCAT5 is always wrong. So immediately remove the annotation symbol, and then try Tomcat5, initialization did not appear "serious" words, the operation is no problem, another question solved.

In summary, in TOMCAT4, the servlet caller is enabled, only the annotation character named Invoker is removed, and in Tomcat5, you also remove the annotation character with the same name.

Additional: Tomcat4 Highest edition 4.1.30, TOMCAT5 newest edition 5.0.27 can download at Tomcat official address

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

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

Looking at the release-note of Tomcat (my version: 5.0.25), you'll find the following paragraph:

------------------------
Enabling Invoker servlet:
------------------------

Starting with Tomcat 4.1.12, the invoker servlet are no longer available by
Default in all WebApps. Enabling it for all webapps are possible by editing
$CATALINA _home/conf/web.xml to uncomment the "/servlet/*" servlet-mapping
Definition.

Using the Invoker servlet in a production environment are not recommended and
is unsupported.

Besides, when I was reading, the book was just an understatement.

Said a phrase related to the/servlet mapping. This, I do not know how many heroes have been stumped.

Note: The article mentioned in the 4.1.30 test success, I think there are problems. My current project uses the tomcat-4.1.24 version, does not modify Web.xml, simply

This mapping cannot be done/servlet. Those who refer to this article should be based on the description of Tomcat's release-note.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.