FORM scope always empty? URL scope is fine?
Asked Answered
K

1

7

I'm running a legacy CF Fusebox 5.5 app within Railo 4.0.2.002 Express with Jetty 8 on Mac OS X 10.8 with java 1.7. I'm also using jetty urlrewrite http://tuckey.org/urlrewrite/ (if that's relevant)

Why is the FORM scope always blank upon form submissions? But if I use the URL scope it works fine.

The app has worked fine in all other versions of CF and should also work fine here.

UPDATE 1:
Also, when I do onRequestStart within Application.cfc and I dump the FORM scope it's empty there too.

Anyone have trouble with this? I don't think it's necessarily "fusebox" so I'm wondering if it's a Railo 4 compatibility issue?

UPDATE 2:
When the form posts to /admin/index.cfm?event=Main.Login
the form scope work fine. But when it posts to /admin/event/Main.Login the form scope is gone.

<?xml version="1.0" encoding="utf-8"?>

 <!DOCTYPE urlrewrite
     PUBLIC "-//tuckey.org//DTD UrlRewrite 3.0//EN"
     "http://tuckey.org/res/dtds/urlrewrite3.0.dtd">

<urlrewrite>
    <rule>
        <from>^/admin/event/(.*)</from>
          <to last="false">/admin/index.cfm?event=$1</to>
    </rule>
  <rule>
      <from>^/lms/event/(.*)</from>
      <to last="false">/lms/index.cfm?event=$1</to>
  </rule>
</urlrewrite>

UPDATE 3:
It should also be noted that Charles (proxy) is properly detecting the 'POST' Request contains the Email / Password and other form elements properly sent to the server.
The Jetty server is simply not seeing them or not properly forwarding them on to the Railo engine or something?

UPDATE 4:
Here is the tuckey configuration that they tell you to place in your web.xml. I actually placed this in the webdefault.xml in etc/ directory of Railo Express which I guess could just be Jetty files.

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
Kodiak answered 19/12, 2012 at 13:42 Comment(13)
Can you show us some code that's not working? What have you tried?Diaspora
I think I just answered it... I believe it's my URLrewrite rules...Kodiak
They can indeed be tricky. If you do find it to be your URL Rewrite rules, post the before and after as your answer so that others can benefit from the solution.Diaspora
I've never used Tuckey, but if it's doing a 301 or 302 redirect, then it will indeed lose the FORM scope. If you watch the HTTP traffic for the request (using Fiddler (fiddler2.com/fiddler2) or Charles (charlesproxy.com)) do you see a redirect happening?Diaspora
Tuckey is a servlet filter (plugs in to Tomcat) that rewrites URLs (not a HTTP redirect) - it wont do a 301/302 unless you instruct it to, using type="redirect" attribute.Meliorate
BTW - Jetty 8 has its own built-in rewrite engine - you might not need to use Tuckey (although I think Tuckey is more flexible). Also, check that you don't have both engines enabled with conflicting rules (check start.ini in jetty root).Meliorate
It's definitely not doing a redirect, just used Charles as per @DanShort suggested. When I hit refresh in the browser, it's also doing the "Resend" prompt so I know it's definitely hitting the right POST call. Scope is just empty... but if I call directly to the index.cfm?event=main.login and hit submit, the form works fine. So strange!Kodiak
Also, url rewriting wouldn't have anything to do with "POST" data could it? At least I know i've never written any POST related conditions...Kodiak
Also, Charles is showing the Request contains all the fields of the form post... jetty / railo are just not handling them for some reason when the URL is structured this way.Kodiak
URL rewriting just rewrites the URL - unless specifically instructed to, it shouldn't be changing the rest of a HTTP request.Meliorate
You could see if rewriting /admin/index.cfm?bob=$1 to /admin/index.cfm?event=$1 does anything different to your current rewrites - at the least it'll help narrow down the problem.Meliorate
One more thing - Railo has a "Merge URL and Form" option in the Administrator - this should combine values from each scope (i.e. StructAppend(Url,Form) - that shouldn't be an issue here, but it's an extra thing to check and see if it affects things.Meliorate
Ya... no dice... this is an irritating issue to have to figure out. Going to strip it down to it's core and see if it's any possible code issues on my part.Kodiak
T
0

I had a number of issues with Tuckey and ended up using Apache and modrewrite for features that Tuckey just didn't support. That being said Railo + Tomcat/Jetty is not ColdFusion with Jrun and the configuration was challenging to ensure that mod_rewrite had all the request information and even had the request at all. Even Adobe had to patch CF10 after release because they were missing original functionality from CF9-+JRUN connectors.

However, for your solution, you need to reach up and out. See the thread here.

https://groups.google.com/forum/#!msg/railo/uw-U9hCFu5k/bEmr_I2Kl8sJ

Other people have the same problem, and have worked around it by placing this in onRequestStart:

<cfscript>
    if(gethTTPRequestData().method eq "POST") {
            if(NOT structKeyExists(form,"fieldnames")) {
                    var paramMap = getPageContext().getRequest().getParameterMap();
                    var paramMapKeys = structKeyList(paramMap);
                    form.fieldnames = paramMapKeys;
                    for(x =1; x lte listLen(paramMapKeys); x++) {
                            param = listGetAt(paramMapKeys,x);
                            form[param] = paramMap[param][1];
                    }
            }
    }
</cfscript>

It's not clear if this is a bug in Jetty, Railo, or Tuckey.

Tiemroth answered 19/12, 2012 at 17:48 Comment(2)
I've never had a problem with Apache RewriteRule with Tomcat and Railo so I'd be inclined to believe this is a problem with Tuckey and/or Jetty, not Railo.Sundown
Sean, I was referring to the configuration of the connector for sure. It has nothing to do with Railo, it's just that Macromedia had the JRun connector pretty much foolproof out of the box as you know. There is definitely more hands on with the Apache/Tomcat connector (in true Apache group fashion).Tiemroth

© 2022 - 2024 — McMap. All rights reserved.