1

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

  • http:/www.mycompany.com/widget/index.html
  • http:/www.mycompany.com/widget/download.html

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 ?

Vikdor
  • 23,934
  • 10
  • 61
  • 84
Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • Possible duplicate http://stackoverflow.com/questions/950497/is-there-a-url-rewriting-engine-for-tomcat-java – DRCB Sep 25 '12 at 11:34
  • It doesn't matter. End users usually don't care about the URLs, and the fact that it ends up with .jsp or .html doesn't make your app more or less secure. – JB Nizet Sep 25 '12 at 11:43
  • @DRCB there wasn't any good answer there that match best with this problem at the link. you can do it with just the url-mapping – gigadot Sep 25 '12 at 11:44
  • Well jsp pages can be accessed similarly with the plain html pages. – Mohsin Sep 25 '12 at 11:48

1 Answers1

1

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.

Frank Pavageau
  • 11,477
  • 1
  • 43
  • 53