[73-MappingDiscovery] and getNamedDispatcher() (was: Re: [servlet-spec] [ADMIN] Heads Up: Proposed Final Draft handed to JCP)


Edward Burns
 

On Thu, 22 Jun 2017 14:52:39 -0700, Edward Burns <edward.burns@...> said:
EB> I would very much like to stick with the existing resolution. That
EB> said, yes, it is a draft. I need to see if we can make a change like
EB> this without having to do another Proposed Final Draft. Let me restate
EB> Greg's counter proposal.

CounterProposal> If the servlet corresponding to this request was
CounterProposal> obtained using the getNamedDispatcherMethod method,
CounterProposal> this method returns the mapping last applied to this
CounterProposal> request to set the values of getServletPath and
CounterProposal> getPathInfo.

EB> While I check on our ability to make this change without needing
EB> to do another PFD, please take this opportunity to review Greg's above
EB> CounterProposal. ACTION: If you really disagree with the null
EB> resolution and would rather go with Greg's CounterProposal, please reply
EB> with your thoughts by COB GMT-0500 Friday 23 June 2017.

I have been given the greenlight to quickly try to get this in so first
let me confirm the correctness of Greg's CounterProposal in two scenarios.

Scenario NamedDispatcherAForwardtoB:
====================================

<servlet>
<servlet-name>ServletA</servlet-name>
<servlet-class>ServletA</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletA</servlet-name>
<url-pattern>/NamedDispatcherAForwardToB</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>ServletB</servlet-name>
<servlet-class>ServletB</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletB</servlet-name>
<url-pattern>/ServletB</url-pattern>
</servlet-mapping>

ServletA has:

RequestDispatcher rd = request.getServletContext().getNamedDispatcher("ServletB");
rd.forward(request, response);

ServletB has

request.getServletContext().log(this.getClass().getSimpleName() + " "
+ request.getHttpServletMapping());

Consider a GET to /NamedDispatcherAForwardToB.

I assert that the values of the HttpServletMapping would be as follows
after implementing Greg's CounterProposal:

MappingImpl{matchValue=NamedDispatcherAForwardToB, pattern=/NamedDispatcherAForwardToB, servletName=ServletA, mappingMatch=EXACT}

QUESTION: Is this correct?

Scenario NamedDispatcherAIncludesB:
===================================

<servlet>
<servlet-name>ServletA</servlet-name>
<servlet-class>ServletA</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletA</servlet-name>
<url-pattern>/NamedDispatcherAIncludesB</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>ServletB</servlet-name>
<servlet-class>ServletB</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletB</servlet-name>
<url-pattern>/ServletB</url-pattern>
</servlet-mapping>

ServletA has:

RequestDispatcher rd = request.getServletContext().getNamedDispatcher("ServletB");
rd.include(request, response);

ServletB has

request.getServletContext().log(this.getClass().getSimpleName() + " "
+ request.getHttpServletMapping());

Consider a GET to /NamedDispatcherAIncludesB.

I assert that the values of the HttpServletMapping would be as follows
after implementing Greg's CounterProposal:

MappingImpl{matchValue=NamedDispatcherAIncludesB, pattern=/NamedDispatcherAIncludesB, servletName=NamedDispatcherAIncludesB, mappingMatch=EXACT}

QUESTION: Is this correct?

Finally, here are the proposed spec changes.

In the javadoc for HttpServletRequest.getHttpServletMapping(), change
the newly added text regarding getNamedDispatcher() to be the following:

If the Servlet corresponding to this request was obtained using
ServletContext.getNamedDispatcher(java.lang.String), the returned
HttpServletMapping instance must have properties that reflect the
mapping last applied to this request.

In PDF section 12.3.1 remove the newly added sentence that starts with
"As with the included and forwarded request parameters..."

ACTION: I need some responses here! The resolution in the PFD, of
returning null, will stand unless I get some feedback on this by COB
GMT-0500 Tuesday 27 June 2017.

I have the impl and spec changes teed up and ready to go, but I can't
make the change without some feedback.

Thanks,

Ed

--
| edward.burns@... | office: +1 407 458 0017


Greg Wilkins
 


Ed,

your examples and text look good to me.

cheers


--
Greg Wilkins <gregw@...> CTO http://webtide.com