4

I have tried this, this and this. The examples use a different framework. I'm using Atmosphere + Jersey. I want to know how to configure 2 servlets in a single web.xml. EDIT: web.xml

<servlet>
    <description>AtmosphereServlet</description>
    <servlet-name>AtmosphereServlet</servlet-name>
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.example.package1</param-value>
    </init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>AtmosphereServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
<servlet>
    <description>Admin</description>
    <servlet-name>Admin</servlet-name>
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>com.example.package2</param-value>
    </init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Admin</servlet-name>
    <url-pattern>/admin/*</url-pattern>
</servlet-mapping>
Community
  • 1
  • 1
Gaurav Bhor
  • 1,057
  • 2
  • 11
  • 26
  • 1
    Post your web.xml file content. – Luiggi Mendoza Nov 02 '13 at 04:15
  • 1
    Did you try putting the more specific servlet+mapping (the one mapping at `/admin/*`) before the more generic? – Nikos Paraskevopoulos Nov 02 '13 at 10:28
  • That did the trick. I might have missed out on something the last time I tried that. Thank you @NikosParaskevopoulos – Gaurav Bhor Nov 02 '13 at 13:55
  • I got my mistake as well. Though here the servlet class says `org.atmosphere.cpr.AtmosphereServlet` I had changed it to `com.sun.jersey.spi.container.servlet.ServletContainer`. Changed it back and worked. And also, the order does not matter. – Gaurav Bhor Nov 02 '13 at 14:01
  • @NikosParaskevopoulos Now that being done, resources from my `AtmosphereServlet` are not being found. – Gaurav Bhor Nov 04 '13 at 14:02
  • It would be great if the author Gaurav Bhor would answer himself the working solution to his question by posting a new answer below and then check it as solution. – basZero Mar 29 '17 at 07:46

0 Answers0