The previous section includes an example of a servlet written in Java. JRun also supports a second method for developing servlets that relies much less heavily on Java coding: JSPs. JSPs let you create servlets from text files containing a combination of HTML and scripting code.
The scripting code within a JSP is a combination of JSP syntax and, typically, JavaScript (a subset of ECMAScript) or Java. For more information on JSP syntax and on choosing your scripting language, see Chapter 10, "JSP Programming Techniques".
When a JSP file is requested for the first time, JRun translates it into a Java source file and then compiles the file into a Java class file. So you can create Java servlets without ever writing a line of Java code. Because the runtime image of a JSP file is a Java class file, the web server cannot tell the difference between a file created in Java and one created as a JSP. JSP files can also call other servlets written in Java or implemented as JSP files.
The following example shows a simple JSP that writes "Hello World" to the browser screen five times:
<html>
<head>
<title>Greetings</title>
</head>
<body>
<% for(int i=0;i<5;i++) { %>
<h1>Hello World!</h1>
<% } %>
</body>
</html>
A JSP filename ends in the extension .jsp. JRun recognizes requests for JSPs and translates the JSP into a Java Servlet for execution. For more information on developing JSPs, see Chapter 10, "JSP Programming Techniques".