Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you render a file without a .jsp extension as a JSP?

Is it possible to tell a standard Java EE servlet container to interpret and render a file as a JSP even if it doesn't have a .jsp extension?

Say I have a file called foo.xyz in the root directory of my WAR. This file contains some jstl logic as you would expect in a .jsp file. If I request http://myserver/myapp/foo.xyz I'm going to see the literal code from that file rendered as text. Is there a way to configure the web app such that it renders the file using the JSP interpreter without changing the files extension?

Please don't ask why I'd want to do this. The constraints are complicated.

like image 727
Mike Deck Avatar asked May 08 '12 23:05

Mike Deck


People also ask

What is the extension for JSP file?

The recommended file extension for the source file of a JSP page is . jsp. The page can be composed of a top file that includes other files that contain either a complete JSP page or a fragment of a JSP page.

Do We Need web XML for JSP?

No, you don't need, jsp file can be directly invoked by URL.

What is a JSP file browser?

This package contains an easy to use and easy to install file browser java server page. This JSP program allows remote web-based file access and manipulation. Features: - Create, copy, move, rename and delete files and directories - Shortkeys - View Files (pictures, movies, pdf, html,…)

How do I open a JSP file extension?

Basically to open a . jsp file, you can use notepad , notepad++ , eclipse , textpad and so on. To open whole application, debug, run and test, better to use Eclipse .


1 Answers

You can add the following configuration in your web.xml to make files ending with .xyz beeing processed as JSP:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.xyz</url-pattern>
    </jsp-property-group>
</jsp-config>

This solution is working with Tomcat and Websphere. And probably with any JEE compliant server container.

like image 97
LaurentG Avatar answered Oct 25 '22 12:10

LaurentG