Bug 110058 - c.a.web.URL mixes up ordering of servlet prefix, context prefix and dispatcher prefix
Summary: c.a.web.URL mixes up ordering of servlet prefix, context prefix and dispatche...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Web Application Framework
Classification: Retired
Component: other
Version: nightly
Hardware: All
OS: Linux
medium
high
Target Milestone: ---
Assignee: Justin Ross
QA Contact: Jon Orris
URL:
Whiteboard:
Depends On:
Blocks: 109665
TreeView+ depends on / blocked
 
Reported: 2003-11-14 15:53 UTC by Daniel Berrangé
Modified: 2007-04-18 16:59 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2003-12-02 22:51:32 UTC
Embargoed:


Attachments (Terms of Use)
Diff for fix (3.03 KB, patch)
2003-11-14 16:08 UTC, Daniel Berrangé
no flags Details | Diff

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.


Note You need to log in before you can comment on or make changes to this bug.