3 Replies Latest reply: Mar 5, 2011 3:31 AM by 823177 RSS

    Java Servlet URL Mapping

    823177
      Hello to all, i fairly new to java servlet.

      Please forgive me if this question seems stupid.

      I have add servlet mapping such as servlet class and url pattern using netbeans in web.xml servlet tab but when the application was running it does not direct go into the target url which is http://localhost:8080/HelloDuke2/greeting but
      http://localhost:8080/HelloDuke2/

      What am i missing in the configuration ?

      How to set the start up url to http://localhost:8080/HelloDuke2/greeting ?


      Please help.

      Thanks.

      Edited by: peterwkc on Feb 25, 2011 11:40 PM
        • 1. Re: Java Servlet URL Mapping
          Opal
          Paste the web.xml file, without it, it's deifficult to say something. To redirect to particular server use <welcome-file> element in web.xml (google for this) to set the welcome site and from this site redirect to servlet.
          • 2. Re: Java Servlet URL Mapping
            823177
            Opal wrote:
            Paste the web.xml file, without it, it's deifficult to say something. To redirect to particular server use <welcome-file> element in web.xml (google for this) to set the welcome site and from this site redirect to servlet.
            Thanks for your reply.

            Actually, i not require to redirect from home site(welcome file) to a particular servlet but i might require this in future and i will google it.

            <?xml version="1.0" encoding="UTF-8"?>
            <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
            <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
            </context-param>
            <servlet>
            <servlet-name>GreetingDukeServlet</servlet-name>
            <servlet-class>HelloDuke.GreetingDukeServlet</servlet-class>
            </servlet>
            <servlet>
            <servlet-name>ResponseDukeServlet</servlet-name>
            <servlet-class>HelloDuke.ResponseDukeServlet</servlet-class>
            </servlet>
            <servlet-mapping>
            <servlet-name>ResponseDukeServlet</servlet-name>
            <url-pattern>/ResponseDukeServlet</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
            <servlet-name>GreetingDukeServlet</servlet-name>
            <url-pattern>/GreetingDukeServlet</url-pattern>
            </servlet-mapping>
            <session-config>
            <session-timeout>
            30
            </session-timeout>
            </session-config>
            </web-app>



            Thanks.

            Edited by: peterwkc on Mar 1, 2011 12:36 AM

            Edited by: peterwkc on Mar 4, 2011 10:45 PM
            • 3. Re: Java Servlet URL Mapping
              823177
              Please help.


              Thanks.