Tomcat4.1.12 is defective in dealing with custom tags

xiaoxiao2021-03-06  94

Tomcat4.1.12 is defective in dealing with custom tags

1. Foreword

When I was practicing a TAG, I found some strange phenomena when I was running in Tomcat4.1.12, and I found that Tomcat4.1.12 was partially issued in handling custom tags.

2. Phenomenon

Question one

I have a property setting in tag that cannot be accepted as a variable, that is, I can only accept static values, but I found Tomcat4.1.12 when used in JSP, and the JSP specification (I reference is JSP1.2) does not match, it does not throw errors in compile, there is no abnormality at runtime, but it is ignored this illegal parameter, and the property is sided for this property when executing the TAG implementation class.

Two problems

This problem is discovered in the experimental problem. After you modify the TLD file, even if you restart Tomcat, if your JSP has not modified, you will not work about the TLD file when requesting the JSP. (I analyzed that JSP has not been modified, will not be re-compiled, will not re-refer to the TLD file, and will not re-analyze the TLD file, then the modification of the TLD file will not work.) But I think this Treatment is extremely unfavorable to JSP programmers modifying TLD files, which is unreasonable.

3. Comparison of Tomcat5.0

By doing experiments in Tomcat 5.0, there is no two problems described above in Tomcat 5.0. If the variable is assigned to the request when the request is not accepted, the variable will be thrown out in the request of the JSP. Tomcat5.0 can also react to TLD files instantly, and even Tomcat does not have to restart.

4. My test program source code

Index.jsp

<% @ Taglib Uri = "/ Web-INF / TLDS / MYLIB.TLD" prefix = "TEST0"%>

<% @ page language = "java"%>

<% @ Page Import = "java.util. *"%>

<%

String thevalue = "maojb";

%>

" />

<% = new date ()%>

Hellotag.java

Package com.mycompany;

Import java.io. *;

Import javax.servlet.jsp. *;

Import javax.servlet.jsp.tagext. *;

Public class hellotag extends tagsupport {

Private string name = "world";

Public void setname (String name) {

THIS.NAME = Name;

}

PUBLIC INT DOENDTAG () {

Try {

PageContext.get (). Println ("Hello XiaoCX" Name;

} catch (ioexception e) {

}

Return Eval_page;

}

}

MYLIB.TLD

DOCTYPE TAGLIB

Public "- // Sun microsystems, inc .//dtd jsp tag library 1.1 // en"

"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

1.0

1.1

Test

Hello

com.mycompany.hellotag

Empty

Nam

YES

NO

The catalog body is as follows

Index.jsp

WEB-INF

Casses

COM

Mycompany

Hellotag.class

TDS

MYLIB.TLD

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

New Post(0)