Click Framework  History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: CLK-334
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Bob Schellink
Reporter: Chas Erickson
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Click

Form action incorrect when using JSP

Created: 13/Mar/08 07:45 AM   Updated: 16/Mar/08 12:48 AM
Component/s: core
Affects Version/s: 1.4 , 1.4-RC3
Fix Version/s: 1.5 M1 , 1.4.1

Environment: java 1.6, Resin 3.0.23


 Description  « Hide
I'm using JSP for pages with a template JSP used for all pages. The click framework will forward to the template JSP which will in turn include the page's JSP. If I put a Form on my page, the form's action value comes from the getActionURL which determines the value to use based on the value of getRequestURI(). However, because the original template JSP has been forwarded to, the value at this point is of the template, not the page. At least this is the case in the Resin environment in which I'm working. To get my pages to work, I modified the Form's getActionURL as show below, based on the information here: http://www.caucho.com/resin-3.0/webapp/faq.xtp#forward

Here's my mod to Form that solves my problem:

    /**
     * Return the form "action" attribute URL value. The action URL will be
     * encode by the response to ensure it includes the Session ID if required.
     *
     * @return the form "action" attribute URL value.
     */
    public String getActionURL() {
        HttpServletRequest request = getContext().getRequest();
        HttpServletResponse response = getContext().getResponse();
        String requestURI = (String)request.getAttribute("javax.servlet.forward.request_uri");
if ((requestURI == null) || (requestURI.length()==0)) {
requestURI = request.getRequestURI();
}
return response.encodeURL(requestURI);
    }


 All   Comments   Change History      Sort Order:
Bob Schellink [13/Mar/08 11:28 AM]
Hi Chas,

Thanks for your report, really appreciate it.

Does your JSP border page use <include page='${forward}'/>

Also the check above:

   requestURI.length() == 0

is that needed for Resin or its just a precaution?

regards

bob

Bob Schellink [13/Mar/08 11:36 AM]
Here is a method we can add to ClickUtils and call from Form and Link* controls:

public static String getRequestURI(HttpServletRequest request) {
        // See section 8.3 of the Servlet 2.3 specification.

        String requestURI = (String)
            request.getAttribute("javax.servlet.include.request_uri");
        if (requestURI != null) {
            requestURI = StringUtils.replace(requestURI, ".jsp", ".htm");
        } else {
            requestURI = request.getRequestURI();
        }
        return requestURI;
    }

Chas Erickson [13/Mar/08 01:09 PM]
Hi Bob, now that you mention it, I believe you are absolutely correct that the replacment of .jsp with .htm will be needed. That's great.

Regarding your other comment, the check against length 0 was just a precaution, it's probably not needed.

-Chas

Bob Schellink [16/Mar/08 12:48 AM]
Fix checked into trunk and backported to 1.4.1

I am resolving this issue for now. If there are still issues feel free to reopen it again.