problems with servlet-mapping url-pattern lbrtchx

Discussion in 'Java' started by Albretch, Jul 7, 2003.

  1. Albretch

    Albretch Guest

    I have compiled my servlets and tested them via the invoker servlet

    http://localhost:8080/myapp/servlet/myserv06

    Now I need for this servlet to be accessed under the url

    http://localhost:8080/book00/chap02/section06/

    I have tried a number of changes to the
    <servlet-mapping><url-pattern>
    section of the file web.xml

    $TOMCAT_HOME/webapps/myapp/WEB-INF/web.xml

    How can you use an arbitrary url after you have tested your servlets?

    As I understood it you must:

    1._ Make sure the invoker servlet has been commented out

    2._ use the <web-app><servlet-mapping><url-pattern> section of the
    web.xml file to set the url-pattern this servlet is invoked under, or
    am I missing something here?

    My web.xml file looks like this:

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

    <web-app>
    <display-name>Book Section 06</display-name>
    <description>Book Section 06</description>
    <servlet>
    <servlet-name>myserv06</servlet-name>
    <servlet-class>myserv06</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>myserv06</servlet-name>
    <url-pattern>/book00/chap02/section06/</url-pattern>
    </servlet-mapping>
    </web-app>
     
    Albretch, Jul 7, 2003
    #1
    1. Advertising

  2. Albretch

    Wendy S Guest

    "William Brogden" <> wrote in message
    news:3f0effca$...
    >
    > "Albretch" <> wrote in message
    > news:...
    > > I have compiled my servlets and tested them via the invoker servlet
    > > http://localhost:8080/myapp/servlet/myserv06
    > > Now I need for this servlet to be accessed under the url
    > > http://localhost:8080/book00/chap02/section06/


    Have you moved the entire context over to /path/to/tomcat/webapps/book00
    instead of /path/to/tomcat/webapps/myapp? That part right after
    localhost:8080 is _usually_ the name of the context, which usually
    corresponds to the directory name under 'webapps'. You can change it, but
    it's done when you deploy the webapp. If you're just letting Tomcat
    magically "find" it with no other action on your part, then the URL will
    have that directory name in it. Or if you put everything under the ROOT
    webapp, then you can get rid of the context name in the URL.

    How did you deploy the "new" version of your webapp?

    Ditch the invoker servlet, even for testing, and package your code.

    > > <servlet-mapping>
    > > <servlet-name>myserv06</servlet-name>
    > > <url-pattern>/book00/chap02/section06/</url-pattern>
    > > </servlet-mapping>
    > > </web-app>


    This would mean visiting http://localhost:8080/myapp/book00/chap02/section06
    based on your example above. (Note the 'myapp' part that you were missing,
    unless you've made this your root webapp.)

    (Wouldn't you just want a "Book" servlet that takes the book#, chapter# and
    section# as parameters? Are you going to map every single section
    separately?)

    --
    Wendy in Chandler, AZ
     
    Wendy S, Jul 11, 2003
    #2
    1. Advertising

  3. "Albretch" <> wrote in message
    news:...
    > I have compiled my servlets and tested them via the invoker servlet
    >
    > http://localhost:8080/myapp/servlet/myserv06
    >
    > Now I need for this servlet to be accessed under the url
    >
    > http://localhost:8080/book00/chap02/section06/
    >
    > I have tried a number of changes to the
    > <servlet-mapping><url-pattern>
    > section of the file web.xml
    >
    > $TOMCAT_HOME/webapps/myapp/WEB-INF/web.xml
    >
    > How can you use an arbitrary url after you have tested your servlets?
    >
    > As I understood it you must:
    >
    > 1._ Make sure the invoker servlet has been commented out
    >
    > 2._ use the <web-app><servlet-mapping><url-pattern> section of the
    > web.xml file to set the url-pattern this servlet is invoked under, or
    > am I missing something here?
    >
    > My web.xml file looks like this:
    >
    > <?xml version="1.0" encoding="ISO-8859-1"?>
    >
    > <!DOCTYPE web-app
    > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    > "http://java.sun.com/dtd/web-app_2_3.dtd">
    >
    > <web-app>
    > <display-name>Book Section 06</display-name>
    > <description>Book Section 06</description>
    > <servlet>
    > <servlet-name>myserv06</servlet-name>
    > <servlet-class>myserv06</servlet-class>


    Better put your servlet in a package, make sure the class is in a directory
    that reflects the package.
    Otherwise Tomcat may not find it.


    > </servlet>
    >
    > <servlet-mapping>
    > <servlet-name>myserv06</servlet-name>
    > <url-pattern>/book00/chap02/section06/</url-pattern>
    > </servlet-mapping>
    > </web-app>





    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
     
    William Brogden, Jul 11, 2003
    #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. Fran Cotton

    Servlet URL Mapping Evil!

    Fran Cotton, Jul 25, 2003, in forum: Java
    Replies:
    0
    Views:
    3,385
    Fran Cotton
    Jul 25, 2003
  2. joel s

    servlet mapping problems

    joel s, Nov 3, 2003, in forum: Java
    Replies:
    5
    Views:
    729
    Wendy S
    Nov 5, 2003
  3. circuit_breaker
    Replies:
    2
    Views:
    2,085
    Jack Jia
    Apr 4, 2004
  4. sods
    Replies:
    5
    Views:
    2,772
  5. Mike Schilling

    Re: servlet annotations for URL mapping?

    Mike Schilling, May 1, 2008, in forum: Java
    Replies:
    3
    Views:
    1,035
    Mike Schilling
    May 2, 2008
Loading...

Share This Page