Mapping to the context root

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

Mapping to the context root

by Stephen Nelson-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I'm just beginning development with Stripes having come from Struts2  
and Wicket in the past. I have a question which I feel is probably a  
FAQ but couldn't find it either on the stripes site or with some  
Google searching. Maybe I missed it though.

Anyway I want to map an action to the context root (e.g. /), so that a  
user browsing www.example.com will run my action. I don't really want  
a index.jsp doing a redirect so wondered if this had been tackled  
before. I am using the dynamic mapping filter if that makes any  
difference.

Also just a quick word of thanks to the developers working on this  
framework. It truly is the best MVC-based framework I have seen in  
Java so far. Really easy to get going with and doesn't get in your way.

Many thanks,

--
Stephen Nelson




------------------------------------------------------------------------------
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: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Stephen,

You can do this:

@UrlBinding("/")
public class YourActionBean implements ActionBean {
  @DefaultHandler
  public Resolution something() {
     ...
  }
}

Hope that helps. Sorry for the quick minimal answer but I'm short on
time, let me know if you need more details.

Cheers,
Freddy
http://www.stripesbook.com

On Sun, 18 Oct 2009 21:51:50 +0100, "Stephen Nelson"
<stephen@...> said:

> Hello,
>
> I'm just beginning development with Stripes having come from Struts2  
> and Wicket in the past. I have a question which I feel is probably a  
> FAQ but couldn't find it either on the stripes site or with some  
> Google searching. Maybe I missed it though.
>
> Anyway I want to map an action to the context root (e.g. /), so that a  
> user browsing www.example.com will run my action. I don't really want  
> a index.jsp doing a redirect so wondered if this had been tackled  
> before. I am using the dynamic mapping filter if that makes any  
> difference.
>
> Also just a quick word of thanks to the developers working on this  
> framework. It truly is the best MVC-based framework I have seen in  
> Java so far. Really easy to get going with and doesn't get in your way.
>
> Many thanks,
>
> --
> Stephen Nelson
>
>
>
>
> ------------------------------------------------------------------------------
> 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: Mapping to the context root

by Grzegorz Krugły :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Remember that in web.xml it has to say like the following - url-pattern
is important here.
I've had many problems with binding to / and in the end just wrote my
own filter which rewrites some URLs (eg. / to /home). If You'd like, I
can give it to You.

    <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>



Freddy Daoud pisze:

> Hi Stephen,
>
> You can do this:
>
> @UrlBinding("/")
> public class YourActionBean implements ActionBean {
>   @DefaultHandler
>   public Resolution something() {
>      ...
>   }
> }
>
> Hope that helps. Sorry for the quick minimal answer but I'm short on
> time, let me know if you need more details.
>
> Cheers,
> Freddy
> http://www.stripesbook.com
>
> On Sun, 18 Oct 2009 21:51:50 +0100, "Stephen Nelson"
> <stephen@...> said:
>  
>> Hello,
>>
>> I'm just beginning development with Stripes having come from Struts2  
>> and Wicket in the past. I have a question which I feel is probably a  
>> FAQ but couldn't find it either on the stripes site or with some  
>> Google searching. Maybe I missed it though.
>>
>> Anyway I want to map an action to the context root (e.g. /), so that a  
>> user browsing www.example.com will run my action. I don't really want  
>> a index.jsp doing a redirect so wondered if this had been tackled  
>> before. I am using the dynamic mapping filter if that makes any  
>> difference.
>>
>> Also just a quick word of thanks to the developers working on this  
>> framework. It truly is the best MVC-based framework I have seen in  
>> Java so far. Really easy to get going with and doesn't get in your way.
>>
>> Many thanks,
>>
>> --
>> Stephen Nelson
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> 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

Re: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Grzegorz,

> I've had many problems with binding to / and in the end just wrote my
> own filter which rewrites some URLs (eg. / to /home).

I'm curious, what were the many problems that you encountered?

Cheers,
Freddy
http://www.stripesbook.com


------------------------------------------------------------------------------
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: Mapping to the context root

by Grzegorz Krugły :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Freddy Daoud pisze:
> Hi Grzegorz,
>
>  
>> I've had many problems with binding to / and in the end just wrote my
>> own filter which rewrites some URLs (eg. / to /home).
>>    
>
> I'm curious, what were the many problems that you encountered?

Well... First of all, setting appropriate context root in web app didn't
work because when it is packed in an EAR file, application.xml has to be
used. But having / there doesn't work, neither ROOT, etc. So I found out
that there's a conception of default web app in Glassfish settings. Then
I had to dig up the information about filter mappings (that /* thing).
Then it turned out that Glassfish is buggy and it's context root is //
instead of /

I needed a URL mapping solution anyways, so I decided to write my own
filter. Every other mapping than / works fine, but / is way easier in
PHP than in JEE for me ;-)

Best regards,
Grzegorz


------------------------------------------------------------------------------
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: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Well... First of all, setting appropriate context root in web app didn't
> work because when it is packed in an EAR file, application.xml has to be
> used. But having / there doesn't work, neither ROOT, etc. So I found out
> that there's a conception of default web app in Glassfish settings. Then
> I had to dig up the information about filter mappings (that /* thing).
> Then it turned out that Glassfish is buggy and it's context root is //
> instead of /

Ah.. well I don't use Glassfish, I don't use EAR files, and I don't
have any problems with /  ;-)

Cheers,
Freddy
http://www.stripesbook.com

------------------------------------------------------------------------------
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: Mapping to the context root

by Grzegorz Krugły :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Freddy Daoud pisze:
> Ah.. well I don't use Glassfish, I don't use EAR files, and I don't
> have any problems with /  ;-)
>  

Yeah, most of my problems are because of Glassfish bugs (see my trouble
with URL decoding few posts back) and being too enterprisey ;-) Perhaps
people here have experiences with other servers they'd like to share? My
only real requirement is that I have to be able to deploy EARs (with EJBs).

Anyway, I'm really glad I chose Stripes (and bought Your book) -- it
keeps amazing me with how well thought it is.

Best regards,
Grzegorz


------------------------------------------------------------------------------
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: Mapping to the context root

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

Reply to Author | View Threaded | Show Only this Message

On 18-10-2009 at 17:39, Freddy Daoud wrote:

> Hi Stephen,
>
> You can do this:
>
> @UrlBinding("/")
> public class YourActionBean implements ActionBean {
>   @DefaultHandler
>   public Resolution something() {
>      ...
>   }
> }
>
> Hope that helps. Sorry for the quick minimal answer but I'm short on
> time, let me know if you need more details.

Alas, that surfaces a feature/bug in Stripes in that if you have these
mappings:
        /
        /search
        /profile

In this case, /searchfoo will also yield the page for /.
This is an undecided point, and listed in issue
http://www.stripesframework.org/jira/browse/STS-688


Oscar

--
   ,-_
  /() ) Oscar Westra van Holthe - Kind      http://www.xs4all.nl/~kindop/
 (__ (
=/  ()  DRM "manages access" in the same way that a jail "manages freedom".

------------------------------------------------------------------------------
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: Mapping to the context root

by Stephen Nelson-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 19 Oct 2009, at 02:17, Freddy Daoud wrote:

>> Well... First of all, setting appropriate context root in web app  
>> didn't
>> work because when it is packed in an EAR file, application.xml has  
>> to be
>> used. But having / there doesn't work, neither ROOT, etc. So I  
>> found out
>> that there's a conception of default web app in Glassfish settings.  
>> Then
>> I had to dig up the information about filter mappings (that /*  
>> thing).
>> Then it turned out that Glassfish is buggy and it's context root  
>> is //
>> instead of /
>
> Ah.. well I don't use Glassfish, I don't use EAR files, and I don't
> have any problems with /  ;-)
>
> Cheers,
> Freddy
> http://www.stripesbook.com
>


Hi Freddy/Grzegorz

Thanks for the reply. I did try that URL mapping in the first instance  
and it didn't seem to work - even though I had identical settings in  
web.xml. However, as I'm using Glassfish it seems that may be the  
reason! I don't have to use Glassfish but it seemed a nice contained  
EE server - as I do need JMS.

Do you know which servers is this confirmed to work well on? Maybe I  
can look at getting my application running on a different server as I  
would like to have this functionality and I'm still in development.

Cheers,

--
Stephen Nelson




------------------------------------------------------------------------------
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: Mapping to the context root

by Stephen Nelson-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 19 Oct 2009, at 06:04, Oscar Westra van Holthe - Kind wrote:

>
> Alas, that surfaces a feature/bug in Stripes in that if you have these
> mappings:
> /
> /search
> /profile
>
> In this case, /searchfoo will also yield the page for /.
> This is an undecided point, and listed in issue
> http://www.stripesframework.org/jira/browse/STS-688
>
>
> Oscar
>
> --  
>   ,-_
>  /() ) Oscar Westra van Holthe - Kind      http://www.xs4all.nl/~kindop/
> (__ (
> =/  ()  DRM "manages access" in the same way that a jail "manages  
> freedom".
>


Hi Oscar

That's not ideal as I would like to capture 404s. Maybe I should just  
have an index.jsp to redirect to /home or something like that?

Cheers,

--
Stephen Nelson




------------------------------------------------------------------------------
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: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Thanks for the reply. I did try that URL mapping in the first instance  
> and it didn't seem to work - even though I had identical settings in  
> web.xml. However, as I'm using Glassfish it seems that may be the  
> reason! I don't have to use Glassfish but it seemed a nice contained  
> EE server - as I do need JMS.

For what it's worth, I usually use an index.jsp file as described
in the book, or a simple index.html file with a redirect:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
    <meta http-equiv="refresh" content="0;url=login">
  </head>
</html>

I know that using an index.{jsp,html} was not what you wanted, but
it is simple and straightforward (and it works).

Cheers,
Freddy
http://www.stripesbook.com

------------------------------------------------------------------------------
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: Mapping to the context root

by Grzegorz Krugły :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Freddy Daoud pisze:

>> Thanks for the reply. I did try that URL mapping in the first instance  
>> and it didn't seem to work - even though I had identical settings in  
>> web.xml. However, as I'm using Glassfish it seems that may be the  
>> reason! I don't have to use Glassfish but it seemed a nice contained  
>> EE server - as I do need JMS.
>>    
>
> For what it's worth, I usually use an index.jsp file as described
> in the book, or a simple index.html file with a redirect:
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>   "http://www.w3.org/TR/html4/strict.dtd">
> <html>
>   <head>
>     <meta http-equiv="refresh" content="0;url=login">
>   </head>
> </html>
>
> I know that using an index.{jsp,html} was not what you wanted, but
> it is simple and straightforward (and it works).

I noticed that index.jsp is an oftenly proposed solution, but I don't
think it's good for Search Engine Optimization reasons. I believe
rewriting URL is a better solution, as the user (and Google, etc.) will
still see the original URL even though we serve them something different
(for instance, when we match the URL to / we can serve what Stripes has
bound to /home but the user still sees / in his address bar).

Here's the simple UrlRewritingFilter I've developed, it allows me to
bypass most of the problems (such as Glassfish going to // instead of /,
the need for normal 404s instead of going to /, etc.) AND to control URL
mapping using a configuration table, EJB method, or whatever. Feel free
to change it (there's a logic for matching appropriate CMS nodes in my
code) and use it.

It needs to be configured in web.xml like that (put it BEFORE Stripes
filter):

    <filter>
        <filter-name>UrlRewritingFilter</filter-name>
       
<filter-class>pl.krop.web.servlet.filter.UrlRewritingFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>UrlRewritingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>




package pl.krop.web.servlet.filter;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import pl.krop.nawigacja.ejb.FrontFacadeLocal;

/**
 *
 * @author Grzegorz Krugły
 */
public class UrlRewritingFilter implements Filter {
    private FilterConfig filterConfig;

    public void init(FilterConfig filterConfig) throws ServletException {
        this.filterConfig = filterConfig;
    }

    public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest) request;

        // since all requests are going through this filter,
        // it's not a bad place to fix the XX-century assumption
        // that Glassfish makes about request encoding (it always assumes
        // it's iso-8859-1 but we use UTF-8 everywhere)
        // thanks to this line, POSTed form data doesn't break
diacritical characters
        req.setCharacterEncoding("UTF-8");

        String rewrittenUrl = null;

        // TODO GK check URL mapping in the database table and redirect
if needed

        Long nodeId =
lookupFrontFacadeBean().getNodeId(req.getRequestURI());

        if ("/".equals(req.getRequestURI()) ||
"//".equals(req.getRequestURI())) {
            // if root is requested - even as // which is Glassfish bug
- view the home page
            nodeId = lookupFrontFacadeBean().getNodeId("/");
            rewrittenUrl = String.format("/node/%d", nodeId);
        } else if (nodeId != null) {
            // if there's a node with URL matching to the current one,
view it
            rewrittenUrl = String.format("/node/%d", nodeId);
        }

        if (rewrittenUrl == null) {
            chain.doFilter(request, response);
        } else {
           
filterConfig.getServletContext().getRequestDispatcher(rewrittenUrl).forward(request,
response);
            return;
        }
    }

    public void destroy() {
        this.filterConfig = null;
    }

    private FrontFacadeLocal lookupFrontFacadeBean() {
        try {
            Context c = new InitialContext();
            return (FrontFacadeLocal)
c.lookup("java:comp/env/FrontFacadeBean");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,
"exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}



HTH,
Grzegorz


------------------------------------------------------------------------------
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: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Grzegorz Krugły <gk@...> writes:

> Anyway, I'm really glad I chose Stripes (and bought Your book) -- it
> keeps amazing me with how well thought it is.

Thanks Grzegorz, I'm very happy to hear that! :-)

Cheers,
Freddy
http://www.stripesbook.com


------------------------------------------------------------------------------
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: Mapping to the context root

by Stephen Nelson-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Mon, Oct 19, 2009 at 12:23 PM, Freddy Daoud <xf2697@...> wrote:
Grzegorz Krugły <gk@...> writes:

> Anyway, I'm really glad I chose Stripes (and bought Your book) -- it
> keeps amazing me with how well thought it is.

Thanks Grzegorz, I'm very happy to hear that! :-)

Hi

I'll go with the index.jsp in development and then use a re-write rule in the web server when deploying the app. This should give the best of both worlds in that case - SEO and minimal setup for development.

Thanks everyone for the replies. I will probably get the book too as I always like to be shown the proper way before trying the alternatives!

Many thanks

Stephen 

------------------------------------------------------------------------------
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: Mapping to the context root

by azizi yazit :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Best MVC framework!
On Mon, Oct 19, 2009 at 4:51 AM, Stephen Nelson <stephen@...> wrote:
Hello,

I'm just beginning development with Stripes having come from Struts2
and Wicket in the past. I have a question which I feel is probably a
FAQ but couldn't find it either on the stripes site or with some
Google searching. Maybe I missed it though.

Anyway I want to map an action to the context root (e.g. /), so that a
user browsing www.example.com will run my action. I don't really want
a index.jsp doing a redirect so wondered if this had been tackled
before. I am using the dynamic mapping filter if that makes any
difference.

Also just a quick word of thanks to the developers working on this
framework. It truly is the best MVC-based framework I have seen in
Java so far. Really easy to get going with and doesn't get in your way.

Many thanks,

--
Stephen Nelson




------------------------------------------------------------------------------
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: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Grzegorz Krugły <gk@...> writes:

> I noticed that index.jsp is an oftenly proposed solution, but I don't
> think it's good for Search Engine Optimization reasons. I believe
> rewriting URL is a better solution, as the user (and Google, etc.) will
> still see the original URL even though we serve them something different
> (for instance, when we match the URL to / we can serve what Stripes has
> bound to /home but the user still sees / in his address bar).

I don't mean to argue about this, but when you have index.jsp as a
welcome-file in web.xml and that JSP forwards to your action bean, the
user (and Google) *will* still see the original URL, /, in the address
bar[1] and *will* see the response of the action in the content, because
the JSP does a forward, not a redirect. So, I don't think that this is
a case against the index.jsp solution.

That being said, I'm not here to have a big argument over this - certainly
there are other valid reasons for preferring a URL-rewriting solution.

[1] in Tomcat and Jetty, at least.

Cheers,
Freddy
http://www.stripesbook.com



------------------------------------------------------------------------------
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: Mapping to the context root

by Grzegorz Krugły :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Freddy Daoud pisze:

> Grzegorz Krugły <gk@...> writes:
>
>  
>> I noticed that index.jsp is an oftenly proposed solution, but I don't
>> think it's good for Search Engine Optimization reasons. I believe
>> rewriting URL is a better solution, as the user (and Google, etc.) will
>> still see the original URL even though we serve them something different
>> (for instance, when we match the URL to / we can serve what Stripes has
>> bound to /home but the user still sees / in his address bar).
>>    
>
> I don't mean to argue about this, but when you have index.jsp as a
> welcome-file in web.xml and that JSP forwards to your action bean, the
> user (and Google) *will* still see the original URL, /, in the address
> bar[1] and *will* see the response of the action in the content, because
> the JSP does a forward, not a redirect. So, I don't think that this is
> a case against the index.jsp solution.
>
> That being said, I'm not here to have a big argument over this - certainly
> there are other valid reasons for preferring a URL-rewriting solution.
>
> [1] in Tomcat and Jetty, at least.
>
>  
By no means meant or mean I to argue :-) If one forwards to an action
bean, it probably works as You're saying, but You've suggested <meta
http-equiv="refresh" content="0;url=login"> which will obviously do the
redirect client-side :-)

Index.jsp is nice and easy solution, it's just that customers recently
tend to have high requirements as to optimizing URLs and rewriting gives
me total control AND I'm quite used to Apache's mod_rewrite.

Best regards,
Grzegorz

------------------------------------------------------------------------------
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: Mapping to the context root

by Freddy D. :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Grzegorz Krugły <gk@...> writes:

> By no means meant or mean I to argue  If one forwards to an action
> bean, it probably works as You're saying, but You've suggested <meta
> http-equiv="refresh" content="0;url=login"> which will obviously do the
> redirect client-side

Indeed, the index.html solution I posted earlier is an altogether different
beast than the index.jsp solution that I use in the book.

So, we agree :-)

Cheers,
Freddy
http://www.stripesbook.com



------------------------------------------------------------------------------
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: Mapping to the context root

by Newman, John W :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

We did have an ear file with one of the wars bound to "/" on JBoss 4.22... FWIW...  Not that I am exactly recommending jboss, but that is one thing that does work =)  



-----Original Message-----
From: Freddy Daoud [mailto:xf2697@...]
Sent: Monday, October 19, 2009 1:12 PM
To: stripes-users@...
Subject: Re: [Stripes-users] Mapping to the context root

Grzegorz Krugły <gk@...> writes:

> By no means meant or mean I to argue  If one forwards to an action
> bean, it probably works as You're saying, but You've suggested <meta
> http-equiv="refresh" content="0;url=login"> which will obviously do the
> redirect client-side

Indeed, the index.html solution I posted earlier is an altogether different
beast than the index.jsp solution that I use in the book.

So, we agree :-)

Cheers,
Freddy
http://www.stripesbook.com



------------------------------------------------------------------------------
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: Mapping to the context root

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

Reply to Author | View Threaded | Show Only this Message

On 19-10-2009 at 10:00, Stephen Nelson wrote:
>
> That's not ideal as I would like to capture 404s. Maybe I should just  
> have an index.jsp to redirect to /home or something like that?

My personal preference is to use /home as a welcome file (Tomcat supports
this; I don't know about other application servers). Others have mentioned
alternatives, as you'll have read.


Oscar

--
   ,-_
  /() ) Oscar Westra van Holthe - Kind      http://www.xs4all.nl/~kindop/
 (__ (
=/  ()  Don't let your boss fuck you; that's anti-capitalist.

------------------------------------------------------------------------------
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