Paul Taylor
Paul Taylor

Reputation: 13150

With Tomcat Servlet container how do I serve jsp files as html files

So I have files such as index.jsp and download.jsp in my web application widget.war and am using Tomcat 7. I would like these files to be accessible from the internet as html files i.e

Questions:

  1. How do I do this, I know it can be done as I did it about 5 years ago but cannot remember how.

  2. Is it a good idea, it seems like a good idea as users are familar with html but jsps, and returning as jsps shows an implementation detail, but does it matter ?

Upvotes: 1

Views: 1274

Answers (1)

Frank Pavageau
Frank Pavageau

Reputation: 11735

You can map *.html through your application's web.xml to the jsp servlet defined in tomcat_path/conf/web.xml.

<servlet-mapping>
    <servlet-name>jsp</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

However, extensions in general are an implementation detail, so it makes no big difference to your users if the URL ends with .html or .jsp. Most won't probably care anyway.

Upvotes: 1

Related Questions