Servlet mapping

Discussion in 'Java' started by francan00@yahoo.com, Dec 12, 2007.

  1. Guest

    I have a page url like this:
    http://servername:8080/test/Data?abc=2&cwe=n

    Data is a servlet.

    Anyway to map this in web.xml so I can change the name to:
    http://servername:8080/test/mynewname

    This didnt work:

    <servlet>
    <servlet-name>Data</servlet-name>
    <servlet-class>Data</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Data?abc=2&cwe=n</servlet-name>
    <url-pattern>/mynewname</url-pattern>
    </servlet-mapping>
    , Dec 12, 2007
    #1
    1. Advertising

  2. Lew Guest

    wrote:
    > I have a page url like this:
    > http://servername:8080/test/Data?abc=2&cwe=n
    >
    > Data is a servlet.
    >
    > Anyway to map this in web.xml so I can change the name to:
    > http://servername:8080/test/mynewname
    >
    > This didnt work:
    >
    > <servlet>
    > <servlet-name>Data</servlet-name>
    > <servlet-class>Data</servlet-class>
    > </servlet>
    > <servlet-mapping>
    > <servlet-name>Data?abc=2&cwe=n</servlet-name>
    > <url-pattern>/mynewname</url-pattern>
    > </servlet-mapping>


    You cannot put parameters in a servlet mapping.

    You can say

    <servlet-mapping>
    <servlet-name>Data</servlet-name>
    <url-pattern>/mynewname</url-pattern>
    </servlet-mapping>

    --
    Lew
    Lew, Dec 12, 2007
    #2
    1. Advertising

  3. On Dec 11, 8:31 pm, Lew <> wrote:
    > wrote:
    > > I have a page url like this:
    > >http://servername:8080/test/Data?abc=2&cwe=n

    >
    > > Data is a servlet.

    >
    > > Anyway to map this in web.xml so I can change the name to:
    > >http://servername:8080/test/mynewname

    >
    > > This didnt work:

    >
    > > <servlet>
    > > <servlet-name>Data</servlet-name>
    > > <servlet-class>Data</servlet-class>
    > > </servlet>
    > > <servlet-mapping>
    > > <servlet-name>Data?abc=2&cwe=n</servlet-name>
    > > <url-pattern>/mynewname</url-pattern>
    > > </servlet-mapping>

    >
    > You cannot put parameters in a servlet mapping.


    But you might put either another servlet in front (to generate the
    appropriate parameters), add a request filter (likewise), or put
    apache in front and use mod_rewrite to change one URL to the other
    before your servlet container sees it.

    -o
    Owen Jacobson, Dec 12, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Albretch
    Replies:
    2
    Views:
    926
    William Brogden
    Jul 11, 2003
  2. Fran Cotton

    Servlet URL Mapping Evil!

    Fran Cotton, Jul 25, 2003, in forum: Java
    Replies:
    0
    Views:
    3,353
    Fran Cotton
    Jul 25, 2003
  3. Fran Cotton

    Servlet Mapping - What's the point?

    Fran Cotton, Aug 7, 2003, in forum: Java
    Replies:
    3
    Views:
    562
    Tor Iver Wilhelmsen
    Aug 8, 2003
  4. Troy Makaro

    simple servlet-mapping question

    Troy Makaro, Aug 27, 2003, in forum: Java
    Replies:
    0
    Views:
    314
    Troy Makaro
    Aug 27, 2003
  5. circuit_breaker
    Replies:
    2
    Views:
    1,983
    Jack Jia
    Apr 4, 2004
Loading...

Share This Page