- Water IDE
- How to Build It
- Same Task in JSP
- Multiple Pages in Water
- Summary
- References and Useful links
Same Task in JSP
This notion is quite different from the typical ASP/JSP model where a page is a special construction that is handled differently than normal objects and methods in the programming language.
In JavaServer Pages (JSP), the following code in a file, the_date.jsp, is required to implement the above task.
<%@ page import="java.text.*" %> <%@ page import="java.util.*" %> <HTML> <% Date d = new Date(); DateFormat df = DateFormat.getDateInstance(); out.println("Today is " + df.format(d) ); %> </HTML>
As you can see, the Water code is much simpler than the JSP code. Most template languages such as ASP or JSP have special delimiters to switch between the HTML syntax and the programming language syntax. The HTML in a JSP file is usually treated as a text string with no special processing. In this one short JSP example there's really three different syntaxes. First there are the <@% %> and <% %>. Note that this syntax does not confirm to HTML, XHTML or XML since it uses illegal characters for xml tags and the closing tags to not follow proper xml syntax. Particularly strange is that <% does not end with a corresponding @%>, just %>. Second, we have HTML syntax for the <HTML> tag. Third, we have Java code in Date d = new Date(); With standard Java you say System.out.println because out.println will not work. The JSP-embedded Java code embedded is different than normal Java for several cases. In such a small example, minor syntactic differences may not matter much, but as programs become more complex, these idiosyncrasies add up to a significant burden on novice programmers and program maintainers.
As you might have noticed, Water has no special tags for embedding Water code in HTML or for embedding HTML in Water code. Water uses the same syntax as HTML, and all HTML tags are pre-defined objects in Water. For example, html is an object in Water's hypertext library.
If the JSP file is installed on the server, you would type the following URL to obtain the results of executing the code in the JSP file.
http://jsp.acme.com/the_date.jsp