I have created a jsp page which run fine when executed in tomcat.But when i change the extension of my file to .html it show nothing. Is there any way where i can run .jsp with .html file extension
Asked
Active
Viewed 8,948 times
5
-
And why do you want that? JSP is a preprocessor for HTML. When browser requests a `.jsp` file, tomcat generates valid, static HTML from the templating rules. When browser requests a `.html` file, it is served as it is. Do you want your URLs to have a `.html` extension instead of `.jsp`? – Jesvin Jose Feb 13 '12 at 05:54
-
yes i want url extension to be .html – jan5 Feb 13 '12 at 05:55
-
Then you need URL rewriting. The only way I can (yes, there could be simpler ways) think of is putting Apache as a reverse proxy (mod_proxy) **in front of** Tomcat and implementing URL rewrite rules (mod_rewrite) to rename `.jsp` to `.html` – Jesvin Jose Feb 13 '12 at 06:25
-
thank u aitchnya i added
in web.xml and it worked fine – jan5 Feb 13 '12 at 06:42jsp *.html -
So there **was** a simpler method :-) – Jesvin Jose Feb 13 '12 at 08:47
-
@jan5 A blackbox pen-tester sees .jsp and .do and knows the server is tomcat. You're doing their job for them by not masking this in some way. – Nielsvh Feb 20 '15 at 16:20
2 Answers
8
add
<servlet-mapping> <servlet-name>jsp</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
in web.xml
jan5
- 1,129
- 3
- 17
- 28
-
This works but I think this answer is neater: https://stackoverflow.com/a/21875973/387048 – Omid Feb 23 '18 at 07:44
0
The accepted answer didn't work for me. I did get something working for a specific html page though (index.html)
<servlet>
<servlet-name>IndexServlet</servlet-name>
<jsp-file>/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>IndexServlet</servlet-name>
<url-pattern>/index.html</url-pattern>
</servlet-mapping>
Greg St.Onge
- 31
- 1