Form action on context root

View: New views
5 Messages — Rating Filter:   Alert me  

Form action on context root

by Annie Lane :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I'm currently working on my first stripes app. This is what I want:

When a user goes to my site e.g. http://mysite.com/ I want there to be a form on that page where they can enter some information and press 'submit'. On successful form submission I want them to be returned to http://mysite.com/ with info regarding success/failure of their form submission. Basically, I want to do something like http://bit.ly does with its URL shortening.

I'n my web.xml I'm using the DynamicMappingFilter, configured like this:

<filter>
         <filter-name>DynamicMappingFilter</filter-name>
         <filter-class>net.sourceforge.stripes.controller.DynamicMappingFilter</filter-class>
     </filter>
   
    <filter-mapping>
         <filter-name>DynamicMappingFilter</filter-name>
        <url-pattern>/*</url-pattern>
         <dispatcher>REQUEST</dispatcher>
         <dispatcher>FORWARD</dispatcher>
         <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

and the action that the page will execute on form submission is below. My problem is that my shorten() method doesn't seem to be gettting called. If I change the @UrlBinding("/") to (for example) @UrlBinding("/moo") it works fine. I don't want moo to be in my URL though... Can anyone help me out here? I feel like I'm missing something important and obvious but I've been staring at this too long to figure it out. Thanks for any help.

@UrlBinding("/")
public class CreateTinyURLActionBean implements ActionBean {
   
    private static final Logger logger = Logger.getLogger(CreateTinyURLActionBean.class);

    @SpringBean
    private URLManager urlManager;
   
    private ActionBeanContext context;
   
    private String longUrl;
   
    private String shortUrl;
   
    public ActionBeanContext getContext() {
    return context;
    }

    public void setContext(ActionBeanContext context) {
    this.context = context;
    }
   
    public URLManager getUrlManager() {
        return urlManager;
    }

    public void setUrlManager(URLManager urlManager) {
    logger.debug("Setting the url manager");
        this.urlManager = urlManager;
    }

    public String getLongUrl() {
    logger.debug("Getting the long url...");
        return longUrl;
    }

    public void setLongUrl(String longUrl) {
        this.longUrl = longUrl;
    }

    public String getShortUrl() {
        return shortUrl;
    }

    public void setShortUrl(String shortUrl) {
        this.shortUrl = shortUrl;
    }

    @DefaultHandler
    public Resolution shorten() {
    shortUrl = urlManager.shortenAndStoreUrl(getLongUrl());
    logger.debug("****The shortened url is: "+shortUrl);
        return new ForwardResolution("jsp/index.jsp");
    }

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Form action on context root

by Oscar Westra van Holthe - Kind :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 30-10-2009 at 01:05, Annie Lane wrote:
> I'm currently working on my first stripes app. This is what I want:
>
> When a user goes to my site e.g. http://mysite.com/ I want there to be a
> form on that page where they can enter some information and press 'submit'.
[...]

> I'n my web.xml I'm using the DynamicMappingFilter, configured like this:
[...]

> and the action that the page will execute on form submission is below. My
> problem is that my shorten() method doesn't seem to be gettting called. If I
> change the @UrlBinding("/") to (for example) @UrlBinding("/moo") it works
> fine. I don't want moo to be in my URL though... Can anyone help me out
> here? I feel like I'm missing something important and obvious but I've been
> staring at this too long to figure it out. Thanks for any help.
>
> @UrlBinding("/")
> public class CreateTinyURLActionBean implements ActionBean {
[...]


The problem here is that:
a) a binding must start with a '/'
b) any binding ending in '/' is mapped as prefix

So the binding @UrlBinding("/") ensures that any request that cannot be
mapped elsewhere is mapped to CreateTinyURLActionBean. Not what you want.

Incidentally, this exact situation is what prompted me to report this:
http://www.stripesframework.org/jira/browse/STS-688

A solution has not been decided upon yet.


Oscar

--
   ,-_
  /() ) Oscar Westra van Holthe - Kind      http://www.xs4all.nl/~kindop/
 (__ (
=/  ()  Even if you win the rat race, you are still a rat...

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Form action on context root

by Annie Lane :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply.

I'm not sure this is the same issue though, I only have the one action  
and at this stage I'm not concerned about other actions mapping to it.

My problem is that I want the form I have on the first page to use the  
action I created below. When I have the action bound to "/" the main  
action method isn't executed when I submit the form. When I change it  
to "/moo" the action runs as expected on form submit.

Annie

On 30/10/2009, at 8:28, Oscar Westra van Holthe - Kind  
<kindop@...> wrote:

> On 30-10-2009 at 01:05, Annie Lane wrote:
>> I'm currently working on my first stripes app. This is what I want:
>>
>> When a user goes to my site e.g. http://mysite.com/ I want there to  
>> be a
>> form on that page where they can enter some information and press  
>> 'submit'.
> [...]
>
>> I'n my web.xml I'm using the DynamicMappingFilter, configured like  
>> this:
> [...]
>
>> and the action that the page will execute on form submission is  
>> below. My
>> problem is that my shorten() method doesn't seem to be gettting  
>> called. If I
>> change the @UrlBinding("/") to (for example) @UrlBinding("/moo") it  
>> works
>> fine. I don't want moo to be in my URL though... Can anyone help me  
>> out
>> here? I feel like I'm missing something important and obvious but  
>> I've been
>> staring at this too long to figure it out. Thanks for any help.
>>
>> @UrlBinding("/")
>> public class CreateTinyURLActionBean implements ActionBean {
> [...]
>
>
> The problem here is that:
> a) a binding must start with a '/'
> b) any binding ending in '/' is mapped as prefix
>
> So the binding @UrlBinding("/") ensures that any request that cannot  
> be
> mapped elsewhere is mapped to CreateTinyURLActionBean. Not what you  
> want.
>
> Incidentally, this exact situation is what prompted me to report this:
> http://www.stripesframework.org/jira/browse/STS-688
>
> A solution has not been decided upon yet.
>
>
> Oscar
>
> --
>   ,-_
>  /() ) Oscar Westra van Holthe - Kind      http://www.xs4all.nl/~kindop/
> (__ (
> =/  ()  Even if you win the rat race, you are still a rat...
>
> ---
> ---
> ---
> ---------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart  
> your
> developing skills, take BlackBerry mobile applications to market and  
> stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@...
> https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Form action on context root

by Ben Gunter-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

While doing some testing the other day, I noticed that binding to "/" did not work in Jetty 6. It just returned a directory listing instead. I didn't have time to investigate, so I don't have any advice to offer if that's what's happening. What app server are you using?

-Ben

On Thu, Oct 29, 2009 at 10:05 AM, Annie Lane <annielaney@...> wrote:
Hi,

I'm currently working on my first stripes app. This is what I want:

When a user goes to my site e.g. http://mysite.com/ I want there to be a form on that page where they can enter some information and press 'submit'. On successful form submission I want them to be returned to http://mysite.com/ with info regarding success/failure of their form submission. Basically, I want to do something like http://bit.ly does with its URL shortening.

I'n my web.xml I'm using the DynamicMappingFilter, configured like this:

<filter>
         <filter-name>DynamicMappingFilter</filter-name>
         <filter-class>net.sourceforge.stripes.controller.DynamicMappingFilter</filter-class>
     </filter>
   
    <filter-mapping>
         <filter-name>DynamicMappingFilter</filter-name>
        <url-pattern>/*</url-pattern>
         <dispatcher>REQUEST</dispatcher>
         <dispatcher>FORWARD</dispatcher>
         <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

and the action that the page will execute on form submission is below. My problem is that my shorten() method doesn't seem to be gettting called. If I change the @UrlBinding("/") to (for example) @UrlBinding("/moo") it works fine. I don't want moo to be in my URL though... Can anyone help me out here? I feel like I'm missing something important and obvious but I've been staring at this too long to figure it out. Thanks for any help.

@UrlBinding("/")
public class CreateTinyURLActionBean implements ActionBean {
   
    private static final Logger logger = Logger.getLogger(CreateTinyURLActionBean.class);

    @SpringBean
    private URLManager urlManager;
   
    private ActionBeanContext context;
   
    private String longUrl;
   
    private String shortUrl;
   
    public ActionBeanContext getContext() {
    return context;
    }

    public void setContext(ActionBeanContext context) {
    this.context = context;
    }
   
    public URLManager getUrlManager() {
        return urlManager;
    }

    public void setUrlManager(URLManager urlManager) {
    logger.debug("Setting the url manager");
        this.urlManager = urlManager;
    }

    public String getLongUrl() {
    logger.debug("Getting the long url...");
        return longUrl;
    }

    public void setLongUrl(String longUrl) {
        this.longUrl = longUrl;
    }

    public String getShortUrl() {
        return shortUrl;
    }

    public void setShortUrl(String shortUrl) {
        this.shortUrl = shortUrl;
    }

    @DefaultHandler
    public Resolution shorten() {
    shortUrl = urlManager.shortenAndStoreUrl(getLongUrl());
    logger.debug("****The shortened url is: "+shortUrl);
        return new ForwardResolution("jsp/index.jsp");
    }

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: Form action on context root

by Annie Lane :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Ben,

I'm using Tomcat 6 at the moment..

Annie

On 30/10/2009, at 12:58, Ben Gunter <gunterben@...> wrote:

While doing some testing the other day, I noticed that binding to "/" did not work in Jetty 6. It just returned a directory listing instead. I didn't have time to investigate, so I don't have any advice to offer if that's what's happening. What app server are you using?

-Ben

On Thu, Oct 29, 2009 at 10:05 AM, Annie Lane <annielaney@...> wrote:
Hi,

I'm currently working on my first stripes app. This is what I want:

When a user goes to my site e.g. http://mysite.com/ I want there to be a form on that page where they can enter some information and press 'submit'. On successful form submission I want them to be returned to http://mysite.com/ with info regarding success/failure of their form submission. Basically, I want to do something like http://bit.ly does with its URL shortening.

I'n my web.xml I'm using the DynamicMappingFilter, configured like this:

<filter>
         <filter-name>DynamicMappingFilter</filter-name>
         <filter-class>net.sourceforge.stripes.controller.DynamicMappingFilter</filter-class>
     </filter>
   
    <filter-mapping>
         <filter-name>DynamicMappingFilter</filter-name>
        <url-pattern>/*</url-pattern>
         <dispatcher>REQUEST</dispatcher>
         <dispatcher>FORWARD</dispatcher>
         <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>

and the action that the page will execute on form submission is below. My problem is that my shorten() method doesn't seem to be gettting called. If I change the @UrlBinding("/") to (for example) @UrlBinding("/moo") it works fine. I don't want moo to be in my URL though... Can anyone help me out here? I feel like I'm missing something important and obvious but I've been staring at this too long to figure it out. Thanks for any help.

@UrlBinding("/")
public class CreateTinyURLActionBean implements ActionBean {
   
    private static final Logger logger = Logger.getLogger(CreateTinyURLActionBean.class);

    @SpringBean
    private URLManager urlManager;
   
    private ActionBeanContext context;
   
    private String longUrl;
   
    private String shortUrl;
   
    public ActionBeanContext getContext() {
    return context;
    }

    public void setContext(ActionBeanContext context) {
    this.context = context;
    }
   
    public URLManager getUrlManager() {
        return urlManager;
    }

    public void setUrlManager(URLManager urlManager) {
    logger.debug("Setting the url manager");
        this.urlManager = urlManager;
    }

    public String getLongUrl() {
    logger.debug("Getting the long url...");
        return longUrl;
    }

    public void setLongUrl(String longUrl) {
        this.longUrl = longUrl;
    }

    public String getShortUrl() {
        return shortUrl;
    }

    public void setShortUrl(String shortUrl) {
        this.shortUrl = shortUrl;
    }

    @DefaultHandler
    public Resolution shorten() {
    shortUrl = urlManager.shortenAndStoreUrl(getLongUrl());
    logger.debug("****The shortened url is: "+shortUrl);
        return new ForwardResolution("jsp/index.jsp");
    }

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-users mailing list
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users