PlanetJava
Custom Search

java-stripes-user
[Top] [All Lists]

Re: Clean URLs failing on form post

Subject: Re: Clean URLs failing on form post
Date: Thu, 3 Feb 2011 11:31:45 +0800
William,
I had a question, which i think is unrelated to your original problem:
Why are you using : @HandlesEvent(....) instead of renaming the
Resolution handler methods to the name you pass in param of
@HandlesEvent ?
ie:
       public Resolution save() throws SchedulerException {
instead of:
 @HandlesEvent("save")
       public Resolution saveJob() throws SchedulerException {
Regards,
Sam
On Thu, Feb 3, 2011 at 11:21 AM, Rose William <[email protected]> wrote:
> Hi Nikolaos,
>
> It probably is!
>
> In my case, the only thing in my folder structure was JSPs, so moving
> them to some other folder structure would fix the issue.
>
> More generally, though, I thought that part of the magic of
> DynamicMappingFilter was supposed to be that one could have one's action
> beans appearing to share the same folders as their resources (e.g. CSS,
> JS, images) and so it ought not matter that the JSPs were there too.
>
> Let's say I rearranged my JSPs, but also added some extra graphics and
> stylesheets:
>
> /jobs
> Â Â /images
> Â Â Â Â Â Â/add-icon.png
> Â Â Â Â Â Â/del-icon.png
> Â Â /css
> Â Â Â Â /edit.css
>
> /WEB-INF
> Â Â Â /jsp
> Â Â Â Â Â /jobs
> Â Â Â Â Â Â Â Â/edit.jsp
> Â Â Â Â Â Â Â Â/list.jsp
>
> I still have the same problem with Tomcat adding a / to
> /contextPath/jobs, despite following best practice for placement of
> JSPs.
>
> Kind regards,
>
> William Rose
> Business Intelligence Team Leader
> Information Management
>
> +61 3 9656 5231 Â | Â Level 8, St Andrews Place, East Melbourne VIC 3002
>
> -----Original Message-----
> From: Nikolaos Giannopoulos [mailto:[email protected]]
> Sent: Thursday, 3 February 2011 2:11 PM
> To: Stripes Users List
> Subject: Re: [Stripes-users] Clean URLs failing on form post
>
> William,
>
> Isn't it best practice to place ones JSPs rooted under /WEB-INF. ÂThis
> ensures that your JSPs are never directly accessible from the outside
> while still allowing your ActionBean's to forward to them.
>
> If you followed this then Tomcat nor any other Web Container would
> succeed in placing a slash and matching your JSP structure.
>
> Or am I missing something...?
>
> --Nikoloas
>
>
>
>
> Rose William wrote:
>> Hi there,
>>
>> I found the recent discussion on the mailing list about clean URLs
>> seemingly failing to find the right event handler when a form is
>> POSTed, and saw a variety of solutions to creating the URL oneself.
>>
>> After trying to debug the same issue myself, I think the reason for
>> this behaviour is tied up in Tomcat bug 32424 (see
>> https://issues.apache.org/bugzilla/show_bug.cgi?id=32424).
>>
>>
>> My web app is set up with DynamicMappingFilter applied to /*.
>>
>> I have a WEB directory structure like this:
>>
>> Â Â/jobs
>> Â Â Â Â /edit.jsp
>> Â Â Â Â /list.jsp
>>
>> I have an action bean annotated like this:
>>
>> Â Â@UrlBinding("/jobs/{$event}/{fullName}")
>>
>> There is a list event, new event and save event:
>>
>> Â Â Â //@DefaultHandler
>> Â Â Â @DontBind
>> Â Â Â @HandlesEvent("list")
>> Â Â Â public Resolution list() throws SchedulerException {
>> Â Â Â Â Â Â Â s_log.debug("in list()");
>>
>> Â Â Â Â Â Â Â return new ForwardResolution("/jobs/list.jsp");
>> Â Â Â }
>>
>> Â Â Â @HandlesEvent("new")
>> Â Â Â @DontValidate
>> Â Â Â public Resolution newJob() throws SchedulerException {
>> Â Â Â Â Â Â Â s_log.debug("in newJob()");
>>
>> Â Â Â Â Â Â Â return new ForwardResolution("/jobs/edit.jsp");
>> Â Â Â }
>>
>> Â Â Â @HandlesEvent("save")
>> Â Â Â public Resolution saveJob() throws SchedulerException {
>>
>> Â Â Â Â Â Â Â return new RedirectResolution(JobAction.class,
>> "edit").addParameter("fullName", this.jobDetail.getFullName());
>> Â Â Â }
>>
>>
>>
>> In edit.jsp, I have a form like this:
>>
>> Â Â<stripes:form name="jobEdit" id="jobEditForm"
>> beanclass="myorg.action.JobAction">
>> Â Â Â Â[form fields]
>> Â Â Â Â<stripes:submit name="save" value="Save" />
>> Â Â</stripes:form>
>>
>>
>> What happens is that when the page is rendered, I get HTML like:
>>
>> Â Â Â Â <form id="jobEditForm" name="jobEdit"
> action="/contextPath/jobs"
>> method="post">
>>
>>
>> The important thing to note here is that /contextPath/jobs resolves to
>
>> a folder -- the one that contains edit.jsp and possibly other
> resources.
>> Ostensibly, DynamicMappingFilter caters for such things because it
>> waits until the request 404's before handling it. And when a link is
>> constructed or a form submitted using GET, everything is just fine.
>>
>> The problem is that Tomcat, as per the bug above, sees that
>> /contextPath/jobs is a folder early in the processing of the POSTed
>> form and issues a redirect to /contextPath/jobs/. This happens means
>> all the POST data is dropped and a GET request to /contextPath/jobs/
>> with no extra parameters is issued.
>>
>> Hence, Stripes will complain with errors like "No default handler
>> could be found for ActionBean", or just show the default handler for
>> that action bean (in my case, if I uncommented the @DefaultHandler
>> annotation, I would always see the job list).
>>
>> I think that this is why fixes proposed in the recent thread that
>> involved creating the URL differently would end up working -- in the
>> end, those URLs would be terminated with a slash, or at least would
>> not end up looking like a known directory to Tomcat. Other web
>> containers may do the same thing.
>>
>> So a potential fix for Stripes to work around the fact that Tomcat
>> devs consider this "not a bug" is to have the form tag pop a / at the
>> end of beanclass based URLs when the method is POST (?).
>>
>> My workaround is to make my URL patterns not overlap with actual
>> folders
>> -- changing jobs to job in @UrlBinding("/job/{$event}/{fullName}") --
>> means that the post URL is /contextPath/job, and Tomcat doesn't mess
>> with it.
>>
>> I hope this helps someone avoid spending their morning trying to
>> figure out why their by-the-book clean URL is not working!
>>
>> Kind regards,
>>
>> William Rose
>>
>> This email (including any attachments or links) may contain
>> confidential and/or legally privileged information and is intended
>> only to be read or used by the addressee. ÂIf you are not the intended
>
>> addressee, any use, distribution, disclosure or copying of this email
>> is strictly prohibited.
>> Confidentiality and legal privilege attached to this email (including
>> any attachments) are not waived or lost by reason of its mistaken
>> delivery to you.
>> If you have received this email in error, please delete it and notify
>> us immediately by telephone or email. ÂPeter MacCallum Cancer Centre
>> provides no guarantee that this transmission is free of virus or that
>> it has not been intercepted or altered and will not be liable for any
>> delay in its receipt.
>>
>>
>> ----------------------------------------------------------------------
>> -------- Special Offer-- Download ArcSight Logger for FREE (a $49 USD
>> value)!
>> Finally, a world-class log management solution at an even better
> price-free!
>> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
>> February 28th, so secure your free ArcSight Logger TODAY!
>> http://p.sf.net/sfu/arcsight-sfd2d
>> _______________________________________________
>> Stripes-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/stripes-users
>>
>>
>
>
> ------------------------------------------------------------------------
> ------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better
> price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires February
> 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
> This email (including any attachments or links) may contain
> confidential and/or legally privileged information and is
> intended only to be read or used by the addressee. ÂIf you
> are not the intended addressee, any use, distribution,
> disclosure or copying of this email is strictly
> prohibited.
> Confidentiality and legal privilege attached to this email
> (including any attachments) are not waived or lost by
> reason of its mistaken delivery to you.
> If you have received this email in error, please delete it
> and notify us immediately by telephone or email. ÂPeter
> MacCallum Cancer Centre provides no guarantee that this
> transmission is free of virus or that it has not been
> intercepted or altered and will not be liable for any delay
> in its receipt.
>
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
-- 
Samuel Baudouin
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users
msgmiddle
<Prev in Thread] Current Thread [Next in Thread>
Current Sitemap | © 2012 planetjava | Contact | Privacy Policy