3 Replies Latest reply on Jul 27, 2004 6:33 AM by Darran Lofthouse

    Can I set 2 servlet mapping in web.xml?

    psupawa Newbie

      I would like to have 2 servlet mapping in web.xml file. Can I do that, how?

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE web-app
       PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
       "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
      
      <web-app>
       <servlet>
       <servlet-name>ChartViewer</servlet-name>
       <servlet-class>org.jfree.chart.servlet.ChartViewer</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>ChartViewer</servlet-name>
       <url-pattern>/servlet/ChartViewer</url-pattern>
       </servlet-mapping>
       <servlet>
       <servlet-name>PieChart</servlet-name>
       <servlet-class>myapp.servlet.PieChart</servlet-class>
       </servlet>
       <servlet-mapping>
       <servlet-name>PieChart</servlet-name>
       <url-pattern>/servlet/PieChart</url-pattern>
       </servlet-mapping>
      </web-app>
      


        • 1. Re: Can I set 2 servlet mapping in web.xml?
          Darran Lofthouse Master

          Do the servlet entries first, then the servlet-mapping entries.

          • 2. Re: Can I set 2 servlet mapping in web.xml?
            psupawa Newbie

             

            Do the servlet entries first, then the servlet-mapping entries.


            How to do that please?
            Here what I found in the dtd doc, don't know how to do.

            <!ELEMENT web-app (icon?, display-name?, description?, distributable?,
            context-param*, servlet*, servlet-mapping*, session-config?,
            mime-mapping*, welcome-file-list?, error-page*, taglib*,
            resource-ref*, security-constraint*, login-config?, security-role*,
            env-entry*, ejb-ref*)>
            


            From my first posted, could you modify code for those 2 servlets to get it works please?

            • 3. Re: Can I set 2 servlet mapping in web.xml?
              Darran Lofthouse Master

               

              <servlet>
               <servlet-name>ChartViewer</servlet-name>
               <servlet-class>org.jfree.chart.servlet.ChartViewer</servlet-class>
               </servlet>
               <servlet>
               <servlet-name>PieChart</servlet-name>
               <servlet-class>myapp.servlet.PieChart</servlet-class>
               </servlet>
               <servlet-mapping>
               <servlet-name>ChartViewer</servlet-name>
               <url-pattern>/servlet/ChartViewer</url-pattern>
               </servlet-mapping>
               <servlet-mapping>
               <servlet-name>PieChart</servlet-name>
               <url-pattern>/servlet/PieChart</url-pattern>
               </servlet-mapping>