Appengine java development server displaying source code

When I access a jsp page like this on the application development server:

local: 8888 / index.jsp /

it displays the source code of index.jsp in the browser. if you access without a trailing slash (i.e. index.jsp) then it displays jsp but with a trailing slash (i.e. index.jsp /) it displays the source code

Any idea why this is? and how to fix it?

It seems to only happen on the development server, not in production. Production gives a 404 Not Found error, which is good.

I am using SDK 1.6.4

web.xml:

<?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 -> displays the page

index.jsp / -> returns the source code

register.jsp / -> returns the source code

register.jsp → renders jsp

signup / -> renders register.jsp

signup → renders register.jsp

so it seems that urls with * .jsp / have a problem

+7
source share
2 answers

You must move all * .jsp files to the / WEB -INF directory and update your web.xml.

Thus, * .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> 

+1
source

I have some problem when I used "redirect" and apache tomcat 7 because redirection is not supported in the new version of apache. To solve problematic search news in the changelog of your apache version (if you use it) for the tag that you used on your page, or publish the code of your page to offer other solutions. You may be using outdated tags. Also, save the localhost [DATE] .log file for more details.

0
source

All Articles