Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

appengine java development server displaying source code

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

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 -> 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

like image 395
xtrahelp.com Avatar asked May 14 '12 06:05

xtrahelp.com


1 Answers

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>

like image 184
Nick Siderakis Avatar answered Oct 16 '22 05:10

Nick Siderakis