dev@grizzly.java.net

Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer

From: Bongjae Chang <carryel_at_korea.com>
Date: Mon, 31 Aug 2009 21:48:01 +0900

Hi Sebastien,

Okay! I will try to make a simple .war for reproducing this issue in a few hours and will attach it.

Thanks!
--
Bongjae Chang


  ----- Original Message -----
  From: Survivant 00
  To: dev_at_grizzly.dev.java.net
  Sent: Monday, August 31, 2009 9:41 PM
  Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


  will try that on debug tonight.

  the mapping doesn't look special. I think grizzly-twitter have the same things.. /words/  something like that.

  I'll check.

  can you package a .war that I can test. Will be easier to test.. with the command line you use please.




  2009/8/31 Bongjae Chang <carryel_at_korea.com>

    Hi Sebastien,
    Â
    Thank you for your reply.
    Â
    I think that maybe your last reply is concerned about the following.
    Â
    ---
    Â Â if (appliPath != null && appliPath.endsWith(File.pathSeparator)) {
    Â Â Â Â Â appliPath = appliPath + File.pathSeparator;
    Â Â }
    ---
    I see...
    Â
    But, I think that definately, the following code is not correct.
    Â
    ---
    mapping = urlPattern.substring(urlPattern.indexOf(sa.getServletPath()));
    ---
    Â
    After you will review it, please let me know. :)
    Â
    Thanks!
    Â
    --
    Bongjae Chang
    Â
    Â
      ----- Original Message -----
      From: Survivant 00
      To: dev_at_grizzly.dev.java.net
      Sent: Thursday, August 27, 2009 6:59 PM
      Subject: Re: servlet-mapping didn't work well in GrizzlyWebServerDeployer


      it's to early in the morning to think about it.. will come back to you later.

      but here what's in the help


-a, --application=[path]* Application(s) path(s). Application(s) deployed can be :
                              Servlet(s), war(s) and expanded war folder(s). To deploy multiple applications use File.pathSeparator Example : -a /app.war:/servlet/web.xml:/warfolder/





      2009/8/27 Bongjae Chang <carryel_at_korea.com>

        Hi,
        Â
        I deployed an web application with using GrizzlyWebServerDeploy, I found that the Servlet is not served because of wrong path mapping.
        Â
        Here is the example of web.xml
        ---
        <web-app>
        <servlet>
        Â Â <servlet-name>TestServlet</servlet-name>
        Â Â <servlet-class>my.test.TestServlet</servlet-class>
        </servlet>
        <servlet-mapping>
        Â Â <servlet-name>TestServlet</servlet-name>
        Â Â <url-pattern>/test/*</url-pattern>
        </servlet-mapping>
        ...
        </web-app>
        ---
        Â
        Assuming that context path is "/example",
        Â
        When I requested http://localhost:port/examples/test/abc, I expected that the TestServlet was serviced.
        Â
        When I debugged, I found some strange codes.
        Â
        In GrizzlyWebServerDeploy.java
        ---
        public String[] getAlias(ServletAdapter sa, Collection<String> aliases) {
        Â Â ...
        Â Â for( String urlPattern : aliases) {
        Â Â Â Â Â String mapping = "";
        Â Â Â Â Â if (!sa.getServletPath().equals(urlPattern) && urlPattern.indexOf(sa.getServletPath()) > -1) {
        Â Â Â Â Â Â Â Â mapping = urlPattern.substring(urlPattern.indexOf(sa.getServletPath()));
        Â Â Â Â Â }
        Â Â Â Â Â String aliasTmp = sa.getContextPath() + sa.getServletPath() + mapping;
        Â Â }
        Â Â ...
        }
        Â
        When I deployed the web app, sa.getServletPath() is equal to "/test" and urlPattern is equal to "/test/*".
        Â
        Then mapping result is equal to "/test/*" , so aliasTmp result is equal to "/example/test/test/*".
        Â
        But I think that aliasTmp should become to be "/examples/test/*".
        Â
        When I edited the mapping code like this experimentally,
        Â
        ---
        mapping = urlPattern.subString(urlPattern.indexOf(sa.getServletPath()) + sa.getServletPath().length());
        ---
        Â
        I could know that my test servlet is served well.
        Â
        Could you please review this?
        Â
        Â
        And I saw another strange code. This is trivial.
        Â
        In GrizzlyWebServerDeployer.java
        ---
        public String appendWarContentToClassPath(String appliPath) throw ... {
        Â Â ...
        Â Â if (appliPath != null && appliPath.endsWith(File.pathSeparator)) {
        Â Â Â Â Â appliPath = appliPath + File.pathSeparator;
        Â Â }
        }
        ---Â
        File.pathSeparator is equal to ";" in Windows.
        Â
        Perhaps you mean File.separator "/" or "\". Is it right?
        Â
        Then, the proposed patch is here.
        ---
        public String appendWarContentToClassPath(String appliPath) throw ... {
        Â Â ...
        Â Â if (appliPath != null && !appliPath.endsWith(File.separator)) {
        Â Â Â Â Â appliPath = appliPath + File.separator;
        Â Â }
        }
        ---Â
        Â
        Is also Right? But, I am not sure. :)
        Â
        Thanks!
        Â
        --
        Bongjae Chang