When I access a jsp page like this on an appengine development server:
localhost:8888/index.jsp/
it's displaying the source code of index.jsp in the browser. if you access without the trailing slash (i.e. index.jsp) then it renders jsp but with the trailing slash (i.e. index.jsp/) it displays the source code
Any idea why is this? and how to fix it?
It seems to happen only in development server and not in production. Production gives a 404 Not Found error, which is fine.
I am using SDK 1.6.4
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>RegisterPage</servlet-name>
<jsp-file>/register.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>RegisterPage</servlet-name>
<url-pattern>/signup</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
==========
so...
index.jsp -> renders page
index.jsp/ -> returns source code
register.jsp/ -> returns source code
register.jsp -> renders jsp
signup/ -> renders register.jsp
signup -> renders register.jsp
so it seems like it's the urls with *.jsp/ that have the issue
You should move all the *.jsp files into the /WEB-INF directory, and update your web.xml.
This way the *.jsp files will not be accessible directly, and the source code will be hidden.
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>RegisterPage</servlet-name>
<jsp-file>/WEB-INF/register.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>RegisterPage</servlet-name>
<url-pattern>/signup</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>IndexPage</servlet-name>
<jsp-file>/WEB-INF/index.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>IndexPage</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index</welcome-file>
</welcome-file-list>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With