0 Replies Latest reply on Jul 1, 2012 10:04 AM by Sam W

    Can't establish servlet-mapping.

    Sam W Expert

      Hi with spring mvc 3.1 and jboss 7.1, I am trying to map a path /category/image/* into a servlet CategoryImageServlet.java class, but it doesn't establish the mapping.


      Here is web.xml file:

       

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
      version="2.4">

       

      <!-- The master configuration file for this Spring web application -->
      <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>
      /WEB-INF/config/web-application-config.xml
      </param-value>
      </context-param>

       

      <!-- Loads the Spring web application context -->
      <listener>
      <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
      </listener>

       

      <!-- Enables use of HTTP methods PUT and DELETE -->
      <filter>
      <filter-name>httpMethodFilter</filter-name>
      <filter-class>org.springframework.web.filter.HiddenHttpMet hodFilter</filter-class>
      </filter>

       

      <filter-mapping>
      <filter-name>httpMethodFilter</filter-name>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
      </filter-mapping>

       

      <!-- Enables Spring Security -->
      <filter>
      <filter-name>springSecurityFilterChain</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFil terProxy</filter-class>
      </filter>

       

      <filter-mapping>
      <filter-name>springSecurityFilterChain</filter-name>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
      </filter-mapping>

       

      <!-- The front controller of this Spring Web application, responsible for handling all application requests -->
      <servlet>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
      <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value></param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
      </servlet>

       

      <!-- Map all *.spring requests to the DispatcherServlet for handling -->
      <servlet-mapping>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
      <url-pattern>/</url-pattern>
      </servlet-mapping>

       

      <!-- category image servlet -->

       

      <servlet>
      <servlet-name>categoryImageServlet</servlet-name>
      <servlet-class>ix.houseware.category.servlet.CategoryImageS ervlet</servlet-class>
      </servlet>
      <servlet-mapping>
      <servlet-name>categoryImageServlet</servlet-name>
      <url-pattern>/category/image/*</url-pattern>
      </servlet-mapping>

       

      </web-app>


       

      CategoryImageServlet.java:

       

      public class CategoryImageServlet extends HttpServlet {

       

      private static final long serialVersionUID = 1L;
      private static final Logger logger = Logger.getLogger(CategoryImageServlet.class);

       

      protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException
      {
      logger.info("calling CategoryImageServlet.....");
      }

       

      list.jsp:

       

      <td><img src="/category/image/${category.categoryId}" /></td>


       

      Any help would be very appreciated.

      Thanks

      Sam