You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2018/05/16 10:03:31 UTC
svn commit: r1831691 - in /tomcat/trunk: java/org/apache/jasper/JspC.java
java/org/apache/jasper/resources/LocalStrings.properties
webapps/docs/changelog.xml
Author: markt
Date: Wed May 16 10:03:30 2018
New Revision: 1831691
URL: http://svn.apache.org/viewvc?rev=1831691&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=50234
Add the capability to generate a web-fragment.xml file to JspC.
Modified:
tomcat/trunk/java/org/apache/jasper/JspC.java
tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/jasper/JspC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspC.java?rev=1831691&r1=1831690&r2=1831691&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspC.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspC.java Wed May 16 10:03:30 2018
@@ -121,6 +121,7 @@ public class JspC extends Task implement
protected static final String SWITCH_URI_ROOT = "-uriroot";
protected static final String SWITCH_FILE_WEBAPP = "-webapp";
protected static final String SWITCH_WEBAPP_INC = "-webinc";
+ protected static final String SWITCH_WEBAPP_FRG = "-webfrg";
protected static final String SWITCH_WEBAPP_XML = "-webxml";
protected static final String SWITCH_WEBAPP_XML_ENCODING = "-webxmlencoding";
protected static final String SWITCH_ADD_WEBAPP_XML_MAPPINGS = "-addwebxmlmappings";
@@ -142,6 +143,7 @@ public class JspC extends Task implement
protected static final String SHOW_SUCCESS ="-s";
protected static final String LIST_ERRORS = "-l";
protected static final int INC_WEBXML = 10;
+ protected static final int FRG_WEBXML = 15;
protected static final int ALL_WEBXML = 20;
protected static final int DEFAULT_DIE_LEVEL = 1;
protected static final int NO_DIE_LEVEL = 0;
@@ -996,13 +998,36 @@ public class JspC extends Task implement
/**
* File where we generate a web.xml fragment with the class definitions.
* @param s New value
+ * @deprecated Will be removed in Tomcat 10.
+ * Use {@link #setWebXmlInclude(String)}
*/
+ @Deprecated
public void setWebXmlFragment( String s ) {
webxmlFile=resolveFile(s).getAbsolutePath();
webxmlLevel=INC_WEBXML;
}
/**
+ * File where we generate configuration with the class definitions to be
+ * included in a web.xml file.
+ * @param s New value
+ */
+ public void setWebXmlInclude( String s ) {
+ webxmlFile=resolveFile(s).getAbsolutePath();
+ webxmlLevel=INC_WEBXML;
+ }
+
+ /**
+ * File where we generate a complete web-fragment.xml with the class
+ * definitions.
+ * @param s New value
+ */
+ public void setWebFragmentXml( String s ) {
+ webxmlFile=resolveFile(s).getAbsolutePath();
+ webxmlLevel=FRG_WEBXML;
+ }
+
+ /**
* File where we generate a complete web.xml with the class definitions.
* @param s New value
*/
@@ -1513,6 +1538,9 @@ public class JspC extends Task implement
if (webxmlLevel >= ALL_WEBXML) {
mapout.write(Localizer.getMessage("jspc.webxml.header", webxmlEncoding));
mapout.flush();
+ } else if (webxmlLevel >= FRG_WEBXML) {
+ mapout.write(Localizer.getMessage("jspc.webfrg.header", webxmlEncoding));
+ mapout.flush();
} else if ((webxmlLevel>= INC_WEBXML) && !addWebXmlMappings) {
mapout.write(Localizer.getMessage("jspc.webinc.header"));
mapout.flush();
@@ -1532,6 +1560,8 @@ public class JspC extends Task implement
mappingout.writeTo(mapout);
if (webxmlLevel >= ALL_WEBXML) {
mapout.write(Localizer.getMessage("jspc.webxml.footer"));
+ } else if (webxmlLevel >= FRG_WEBXML) {
+ mapout.write(Localizer.getMessage("jspc.webfrg.footer"));
} else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
mapout.write(Localizer.getMessage("jspc.webinc.footer"));
}
Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1831691&r1=1831690&r2=1831691&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Wed May 16 10:03:30 2018
@@ -178,6 +178,7 @@ where options include:\n\
\ -compile Compiles generated servlets\n\
\ -failFast Stop on first compile error\n\
\ -webinc <file> Creates a partial servlet mappings in the file\n\
+\ -webfrg <file> Creates a complete web-fragment.xml the file\n\
\ -webxml <file> Creates a complete web.xml in the file\n\
\ -webxmlencoding <enc> Set the encoding charset used to read and write the web.xml\n\
\ file (default is UTF-8)\n\
@@ -205,6 +206,22 @@ Automatically created by Apache Tomcat J
jspc.webxml.footer=\n\
</web-app>\n\
\n
+jspc.webfrg.header=<?xml version="1.0" encoding="{0}"?>\n\
+<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"\n\
+\ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n\
+\ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee\n\
+\ http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"\n\
+\ version="3.0"\n\
+\ metadata-complete="true">\n\
+\ <name>org_apache_jasper.jspc</name>\n\
+\ <distributable/>\n\
+<!--\n\
+Automatically created by Apache Tomcat JspC.\n\
+-->\n\
+\n
+jspc.webfrg.footer=\n\
+</web-fragment>\n\
+\n
jspc.webinc.header=\n\
<!--\n\
Automatically created by Apache Tomcat JspC.\n\
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1831691&r1=1831690&r2=1831691&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed May 16 10:03:30 2018
@@ -123,6 +123,10 @@
</subsection>
<subsection name="Jasper">
<changelog>
+ <add>
+ <bug>50234</bug>: Add the capability to generate a web-fragment.xml file
+ to JspC. (markt)
+ </add>
<fix>
<bug>62350</bug>: Refactor
<code>org.apache.jasper.runtime.BodyContentImpl</code> so a
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1831691 - in /tomcat/trunk:
java/org/apache/jasper/JspC.java
java/org/apache/jasper/resources/LocalStrings.properties
webapps/docs/changelog.xml
Posted by Mark Thomas <ma...@apache.org>.
On 16/05/18 15:25, Konstantin Kolinko wrote:
> 2018-05-16 16:47 GMT+03:00 Mark Thomas <ma...@apache.org>:
>> On 16/05/18 14:31, Konstantin Kolinko wrote:
>>> 2018-05-16 13:03 GMT+03:00 <ma...@apache.org>:
>
>>>> @@ -205,6 +206,22 @@ Automatically created by Apache Tomcat J
>>>> jspc.webxml.footer=\n\
>>>> </web-app>\n\
>>>> \n
>>>> +jspc.webfrg.header=<?xml version="1.0" encoding="{0}"?>\n\
>>>> +<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"\n\
>>>> +\ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n\
>>>> +\ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee\n\
>>>> +\ http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"\n\
>>>> +\ version="3.0"\n\
>>>
>>> 4) Update version, namespace, schema to 3.1 for Tomcat 8.0, 8.5, 4.0
>>> for Tomcat 9 ?
>>
>> The web.xml generation sticks to Servlet 2.5. I decided to stick to the
>> lowest useable version number for the fragment as well since I could not
>> see any benefit in generating a file with later version number.
>>
>
> As precompilation targets a specific release of Tomcat, and is not guaranteed
> to be compatible with a different build release, I see no benefit in
> trying to be compatible.
Fair point. I'll update the generated files to use the current versions
on that basis.
> Regarding "Servlet 2.5" (or 2.3 actually)
> comment 4 (April 2014) in this bug 50234 has a complaint about it:
> [quote]
> At the moment (Tomcat 7), a dummy web.xml has to be defined in order
> to define the version (i.e. for expresions within the JSPs).
> [/quote]
With the pre-compiled JSPs in a web-fragment-xml, there is no
requirement for a web.xml so that request has been met.
> https://bz.apache.org/bugzilla/show_bug.cgi?id=50234
>
> Sticking to 2.3 is OK when inserting a fragment into existing web.xml.
For the content that is being inserted, the syntax is unchanged so this
should not be an issue.
> When generating a new web.xml, one ends up with a web application that
> uses a different version of spec as opposed to a web app without a
> web.xml file.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1831691 - in /tomcat/trunk: java/org/apache/jasper/JspC.java
java/org/apache/jasper/resources/LocalStrings.properties webapps/docs/changelog.xml
Posted by Konstantin Kolinko <kn...@gmail.com>.
2018-05-16 16:47 GMT+03:00 Mark Thomas <ma...@apache.org>:
> On 16/05/18 14:31, Konstantin Kolinko wrote:
>> 2018-05-16 13:03 GMT+03:00 <ma...@apache.org>:
>>> @@ -205,6 +206,22 @@ Automatically created by Apache Tomcat J
>>> jspc.webxml.footer=\n\
>>> </web-app>\n\
>>> \n
>>> +jspc.webfrg.header=<?xml version="1.0" encoding="{0}"?>\n\
>>> +<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"\n\
>>> +\ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n\
>>> +\ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee\n\
>>> +\ http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"\n\
>>> +\ version="3.0"\n\
>>
>> 4) Update version, namespace, schema to 3.1 for Tomcat 8.0, 8.5, 4.0
>> for Tomcat 9 ?
>
> The web.xml generation sticks to Servlet 2.5. I decided to stick to the
> lowest useable version number for the fragment as well since I could not
> see any benefit in generating a file with later version number.
>
As precompilation targets a specific release of Tomcat, and is not guaranteed
to be compatible with a different build release, I see no benefit in
trying to be compatible.
Regarding "Servlet 2.5" (or 2.3 actually)
comment 4 (April 2014) in this bug 50234 has a complaint about it:
[quote]
At the moment (Tomcat 7), a dummy web.xml has to be defined in order
to define the version (i.e. for expresions within the JSPs).
[/quote]
https://bz.apache.org/bugzilla/show_bug.cgi?id=50234
Sticking to 2.3 is OK when inserting a fragment into existing web.xml.
When generating a new web.xml, one ends up with a web application that
uses a different version of spec as opposed to a web app without a
web.xml file.
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1831691 - in /tomcat/trunk:
java/org/apache/jasper/JspC.java
java/org/apache/jasper/resources/LocalStrings.properties
webapps/docs/changelog.xml
Posted by Mark Thomas <ma...@apache.org>.
On 16/05/18 14:31, Konstantin Kolinko wrote:
> 2018-05-16 13:03 GMT+03:00 <ma...@apache.org>:
>> Author: markt
>> Date: Wed May 16 10:03:30 2018
>> New Revision: 1831691
<snip/>
> 1). There is an example in
> http://tomcat.apache.org/tomcat-9.0-doc/jasper-howto.html
> -> Web Application Compilation
> -> webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
>
> It needs updating?
Probably. I'll take a look.
>> Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
>> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1831691&r1=1831690&r2=1831691&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
>> +++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Wed May 16 10:03:30 2018
>> @@ -178,6 +178,7 @@ where options include:\n\
>> \ -compile Compiles generated servlets\n\
>> \ -failFast Stop on first compile error\n\
>> \ -webinc <file> Creates a partial servlet mappings in the file\n\
>> +\ -webfrg <file> Creates a complete web-fragment.xml the file\n\
>
> 2) s/"the file"/"in the file", as in sibling options?
I'll fix that wording.
> 3) I do not see where JspC processes the "-webfrg" switch.
>
> SWITCH_WEBAPP_FRG in JspC is declared, but not used.
>
> A sibling "webinc" switch (SWITCH_WEBAPP_INC) is processed in
> #setArgs() (line 339).
I went back and forth naming. I may have missed that change. I'll take a
look and add it if necessary.
>> @@ -205,6 +206,22 @@ Automatically created by Apache Tomcat J
>> jspc.webxml.footer=\n\
>> </web-app>\n\
>> \n
>> +jspc.webfrg.header=<?xml version="1.0" encoding="{0}"?>\n\
>> +<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"\n\
>> +\ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n\
>> +\ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee\n\
>> +\ http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"\n\
>> +\ version="3.0"\n\
>
> 4) Update version, namespace, schema to 3.1 for Tomcat 8.0, 8.5, 4.0
> for Tomcat 9 ?
The web.xml generation sticks to Servlet 2.5. I decided to stick to the
lowest useable version number for the fragment as well since I could not
see any benefit in generating a file with later version number.
Thanks for the review.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1831691 - in /tomcat/trunk: java/org/apache/jasper/JspC.java
java/org/apache/jasper/resources/LocalStrings.properties webapps/docs/changelog.xml
Posted by Konstantin Kolinko <kn...@gmail.com>.
2018-05-16 13:03 GMT+03:00 <ma...@apache.org>:
> Author: markt
> Date: Wed May 16 10:03:30 2018
> New Revision: 1831691
>
> URL: http://svn.apache.org/viewvc?rev=1831691&view=rev
> Log:
> Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=50234
> Add the capability to generate a web-fragment.xml file to JspC.
>
> Modified:
> tomcat/trunk/java/org/apache/jasper/JspC.java
> tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
> tomcat/trunk/webapps/docs/changelog.xml
>
> Modified: tomcat/trunk/java/org/apache/jasper/JspC.java
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspC.java?rev=1831691&r1=1831690&r2=1831691&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/jasper/JspC.java (original)
> +++ tomcat/trunk/java/org/apache/jasper/JspC.java Wed May 16 10:03:30 2018
> @@ -121,6 +121,7 @@ public class JspC extends Task implement
> protected static final String SWITCH_URI_ROOT = "-uriroot";
> protected static final String SWITCH_FILE_WEBAPP = "-webapp";
> protected static final String SWITCH_WEBAPP_INC = "-webinc";
> + protected static final String SWITCH_WEBAPP_FRG = "-webfrg";
> protected static final String SWITCH_WEBAPP_XML = "-webxml";
> protected static final String SWITCH_WEBAPP_XML_ENCODING = "-webxmlencoding";
> protected static final String SWITCH_ADD_WEBAPP_XML_MAPPINGS = "-addwebxmlmappings";
> @@ -142,6 +143,7 @@ public class JspC extends Task implement
> protected static final String SHOW_SUCCESS ="-s";
> protected static final String LIST_ERRORS = "-l";
> protected static final int INC_WEBXML = 10;
> + protected static final int FRG_WEBXML = 15;
> protected static final int ALL_WEBXML = 20;
> protected static final int DEFAULT_DIE_LEVEL = 1;
> protected static final int NO_DIE_LEVEL = 0;
> @@ -996,13 +998,36 @@ public class JspC extends Task implement
> /**
> * File where we generate a web.xml fragment with the class definitions.
> * @param s New value
> + * @deprecated Will be removed in Tomcat 10.
> + * Use {@link #setWebXmlInclude(String)}
> */
> + @Deprecated
> public void setWebXmlFragment( String s ) {
> webxmlFile=resolveFile(s).getAbsolutePath();
> webxmlLevel=INC_WEBXML;
> }
1). There is an example in
http://tomcat.apache.org/tomcat-9.0-doc/jasper-howto.html
-> Web Application Compilation
-> webXmlFragment="${webapp.path}/WEB-INF/generated_web.xml"
It needs updating?
> /**
> + * File where we generate configuration with the class definitions to be
> + * included in a web.xml file.
> + * @param s New value
> + */
> + public void setWebXmlInclude( String s ) {
> + webxmlFile=resolveFile(s).getAbsolutePath();
> + webxmlLevel=INC_WEBXML;
> + }
> +
> + /**
> + * File where we generate a complete web-fragment.xml with the class
> + * definitions.
> + * @param s New value
> + */
> + public void setWebFragmentXml( String s ) {
> + webxmlFile=resolveFile(s).getAbsolutePath();
> + webxmlLevel=FRG_WEBXML;
> + }
> +
> + /**
> * File where we generate a complete web.xml with the class definitions.
> * @param s New value
> */
> @@ -1513,6 +1538,9 @@ public class JspC extends Task implement
> if (webxmlLevel >= ALL_WEBXML) {
> mapout.write(Localizer.getMessage("jspc.webxml.header", webxmlEncoding));
> mapout.flush();
> + } else if (webxmlLevel >= FRG_WEBXML) {
> + mapout.write(Localizer.getMessage("jspc.webfrg.header", webxmlEncoding));
> + mapout.flush();
> } else if ((webxmlLevel>= INC_WEBXML) && !addWebXmlMappings) {
> mapout.write(Localizer.getMessage("jspc.webinc.header"));
> mapout.flush();
> @@ -1532,6 +1560,8 @@ public class JspC extends Task implement
> mappingout.writeTo(mapout);
> if (webxmlLevel >= ALL_WEBXML) {
> mapout.write(Localizer.getMessage("jspc.webxml.footer"));
> + } else if (webxmlLevel >= FRG_WEBXML) {
> + mapout.write(Localizer.getMessage("jspc.webfrg.footer"));
> } else if ((webxmlLevel >= INC_WEBXML) && !addWebXmlMappings) {
> mapout.write(Localizer.getMessage("jspc.webinc.footer"));
> }
>
> Modified: tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties
> URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties?rev=1831691&r1=1831690&r2=1831691&view=diff
> ==============================================================================
> --- tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties (original)
> +++ tomcat/trunk/java/org/apache/jasper/resources/LocalStrings.properties Wed May 16 10:03:30 2018
> @@ -178,6 +178,7 @@ where options include:\n\
> \ -compile Compiles generated servlets\n\
> \ -failFast Stop on first compile error\n\
> \ -webinc <file> Creates a partial servlet mappings in the file\n\
> +\ -webfrg <file> Creates a complete web-fragment.xml the file\n\
2) s/"the file"/"in the file", as in sibling options?
3) I do not see where JspC processes the "-webfrg" switch.
SWITCH_WEBAPP_FRG in JspC is declared, but not used.
A sibling "webinc" switch (SWITCH_WEBAPP_INC) is processed in
#setArgs() (line 339).
> \ -webxml <file> Creates a complete web.xml in the file\n\
> \ -webxmlencoding <enc> Set the encoding charset used to read and write the web.xml\n\
> \ file (default is UTF-8)\n\
> @@ -205,6 +206,22 @@ Automatically created by Apache Tomcat J
> jspc.webxml.footer=\n\
> </web-app>\n\
> \n
> +jspc.webfrg.header=<?xml version="1.0" encoding="{0}"?>\n\
> +<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"\n\
> +\ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n\
> +\ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee\n\
> +\ http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"\n\
> +\ version="3.0"\n\
4) Update version, namespace, schema to 3.1 for Tomcat 8.0, 8.5, 4.0
for Tomcat 9 ?
> +\ metadata-complete="true">\n\
> +\ <name>org_apache_jasper.jspc</name>\n\
> +\ <distributable/>\n\
> +<!--\n\
> +Automatically created by Apache Tomcat JspC.\n\
> +-->\n\
> +\n
> +jspc.webfrg.footer=\n\
> +</web-fragment>\n\
> +\n
> jspc.webinc.header=\n\
> <!--\n\
> Automatically created by Apache Tomcat JspC.\n\
>
> Modified: tomcat/trunk/webapps/docs/changelog.xml
> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1831691&r1=1831690&r2=1831691&view=diff
> ==============================================================================
> --- tomcat/trunk/webapps/docs/changelog.xml (original)
> +++ tomcat/trunk/webapps/docs/changelog.xml Wed May 16 10:03:30 2018
> @@ -123,6 +123,10 @@
> </subsection>
> <subsection name="Jasper">
> <changelog>
> + <add>
> + <bug>50234</bug>: Add the capability to generate a web-fragment.xml file
> + to JspC. (markt)
> + </add>
> <fix>
> <bug>62350</bug>: Refactor
> <code>org.apache.jasper.runtime.BodyContentImpl</code> so a
Best regards,
Konstantin Kolinko
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org