Language attribute JSP page directive

I read that with this attribute I can choose which scripting language to use with JSP.

I am currently using Java, but is there a container that Groovy, JRuby or others can use to generate servlet code?

Is it right to say that if another language existed, then Java, in order to use it with JSP, must compile it into byte code compatible with JVM. Then should the web container be able to convert it to a servlet?

+4
source share
3 answers

According to the jsp specification, this attribute is used to declare the language used in scripts, expressions and declarations on the JSP page.

In JSP 2.1 (latest specification), only the specific and required scripting language The value for this attribute is java (all lowercase, case sensitive). This is true for previous specifications.

There are currently no containers, as far as I know, that support a different language than the specification. But if there is; as you said; it should compile it into a standard servlet.

If you plan on using JRuby, you can check out Ruby on Rails; Grails for Groovy.

+1
source

Not what I know - the closest I can find (and used), http://groovy.codehaus.org/GSP is now part of grails . I understand that this is better than jsp when used in conjunction with grails!

0
source

In short: there are no other scripting languages ​​that the JSP can currently support. But maybe in the future.

I searched the language attribute in the JSP documentation and found this:

Table JSP.1-8 Page Directive Attributes

  • Tongue

Defines the scripting language to be used in scripts, expression script expressions and declarations within the body of the translation unit (JSP page and any files included with the include directive below). In JSP 2.1, the only definable and required scripting language value for this attribute is java (all lowercase, case sensitive). This specification describes the semantics of scripts when the value of the language attribute is java. When java is the value of the scripting language, the fragments of the source code of the Java programming language used in the translation unit must conform to the specification of the Java programming language, as described in JSP.9, "Scripting". All scripting languages ​​must provide some implicit objects that a JSP page author can use in declarations, scripts, and expressions. The specific objects that can be used are defined in JSP.1.8.3 “Implicit objects.” All scripting languages ​​must support the Java Runtime Environment (JRE). All scripting languages ​​must expose the Java technology object model into a scripting environment, especially implicit variables , JavaBeans component properties, and public methods. Future versions of the JSP specification may define additional values ​​for a language attribute, and all such values ​​are reserved. This is a fatal translation error for a directive with a non-java language attribute that appears after of how the first element of the script was encountered, the default is java.

0
source

All Articles