NCoder
NCoder

Reputation: 335

Can servlets have extensions?

I have a page http://domain.com/servlets/projecta?action=cust_active

but need to provide a link to the same place with an extension (like .jsp or something).

Is there a way to add an extension to this, but have it still load the same way?

Upvotes: 0

Views: 64

Answers (1)

Akber Choudhry
Akber Choudhry

Reputation: 1785

You would need multiple URL mappings for your servlet in web.xml. Assuming that your existing servlet is mapped to projecta like this:

  <servlet-mapping>
    <servlet-name>servlet</servlet-name>
    <url-pattern>/projecta</url-pattern>
  </servlet-mapping>

You might need:

  <servlet-mapping>
    <servlet-name>servlet</servlet-name>
    <url-pattern>/projecta</url-pattern>
    <url-pattern>/projecta.ext</url-pattern>
  </servlet-mapping>

Also see this in case your servlet version is different: many url-pattern for the same servlet

Upvotes: 2

Related Questions