Bug 110058

Summary: c.a.web.URL mixes up ordering of servlet prefix, context prefix and dispatcher prefix
Product: [Retired] Red Hat Web Application Framework Reporter: Daniel BerrangĂ© <berrange>
Component: otherAssignee: Justin Ross <jross>
Status: CLOSED RAWHIDE QA Contact: Jon Orris <jorris>
Severity: high Docs Contact:
Priority: medium    
Version: nightly   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-12-02 22:51:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 109665    
Attachments:
Description Flags
Diff for fix none

Description Daniel Berrangé 2003-11-14 15:53:06 UTC
Description of problem:

Consider a URL /apps/plaintext/ccm/portal/homepage.jsp

The /apps/ bit is the context prefix, the /plaintext/ bit is the
dispatcher prefix and the /ccm/ bit is the servlet prefix.
Unfortunately the c.a.web.URL class chops the components out in the
order context, servlet, dispatcher prefixes. So when it re-consistutes
the URL you get /apps/ccm/plaintext/portal/homepage.jsp which
obviously doesn't dispatch to anything.

This bug looks like it was always there, but we didn't encounter it
previously because we always mounted apps on / instead of /ccm.


In addition the PageTransformer class is adding the dispatcher prefix
onto the end of the context-prefix variable, so it ends up duplicated
thus:  /ccm/text/text

Version-Release number of selected component (if applicable):


How reproducible:
Always


Steps to Reproduce:
1. Add in an instance of the InternalPrefixerServlet to web.xml
2. Visit the homepage using the prefix defined in web.xml
3. Look at the XML source to view the any URLs in the page
  
Actual results:
URLs are  starting with /ccm/text/pvt


Expected results:
URLs are starting with /text/ccm/pvt


Additional info:

The patch is:

====
//core-platform/dev/src/com/arsdigita/bebop/page/PageTransformer.java#5
-
/var/ccm-devel/dev/dan/aplaws-rickshaw/core/src/com/arsdigita/bebop/page/PageTransformer.java
====
245,247c245
<                  com.arsdigita.web.URL.getDispatcherPath() +
<                  (DispatcherHelper.getDispatcherPrefix(req) == null
? "" :
<                   DispatcherHelper.getDispatcherPrefix(req)));
---
>                  com.arsdigita.web.URL.getDispatcherPath());
==== //core-platform/dev/src/com/arsdigita/web/URL.java#29 -
/var/ccm-devel/dev/dan/aplaws-rickshaw/core/src/com/arsdigita/web/URL.java
====
229,231d228
<         m_url.append(servletPath);
<         m_servletPathEnd = m_url.length();
< 
236a234,236
>         m_url.append(servletPath);
>         m_servletPathEnd = m_url.length();
> 
457a458,466
>      * <p>Experimental</p>
>      * <p>Returns the dispatcher prefix of this request as
>      * set by the InternalPrefixerServlet
>      */
>     public final String getDispatcherPrefix() {
>         return m_url.substring(m_contextPathEnd, m_dispatcherPrefixEnd);
>     }
> 
>     /**
465c474
<         return m_url.substring(m_contextPathEnd, m_servletPathEnd);
---
>         return m_url.substring(m_dispatcherPrefixEnd, m_servletPathEnd);
469,477d477
<      * <p>Experimental</p>
<      * <p>Returns the dispatcher prefix of this request as
<      * set by the InternalPrefixerServlet
<      */
<     public final String getDispatcherPrefix() {
<         return m_url.substring(m_servletPathEnd, m_dispatcherPrefixEnd);
<     }
< 
<     /**
488c488
<         final String pathInfo = m_url.substring(m_dispatcherPrefixEnd);
---
>         final String pathInfo = m_url.substring(m_servletPathEnd);
885c885
<                 return context + servlet + prefix;
---
>                 return context + prefix + servlet;

Comment 1 Richard Li 2003-11-14 15:59:26 UTC
btw, can you do diff -uw next time? i personally hate regular ol' diffs...

Comment 2 Daniel Berrangé 2003-11-14 16:08:58 UTC
Created attachment 95971 [details]
Diff for fix

Comment 3 Justin Ross 2003-11-21 18:10:34 UTC
The above fix was applied in perforce change 38216.