The sample page you'll be creating adds 2 + 2 and displays the result in the browser.
JSP pages are created by putting a add.jsp file in the document directory. The JSP page is a mixture of HTML and Java code. Resin's JSP engine compiles the .jsp file into a Java servlet and then runs the servlet to produce the output.
Resin's web server stores its pages in a directory named doc. On this machine it's /var/resin/hosts/www.caucho.com/webapps/ROOT/
Create the text file doc/test/add.jsp (/var/resin/hosts/www.caucho.com/webapps/ROOT/test/add.jsp) with your favorite text editor: notepad, emacs, vi, or whatever. It should contain the following text:
To see Resin in action, you need to look at the page in the browser. The URL is http://www.caucho.com:80/test/add.jsp
If everything works, you should see the following page:
The web server uses the '.jsp' extension to make 'add.jsp' an active page. For HTML pages and GIF files, the web server just copies the file from your computer to the browser. That's why looking at the file index.html in your browser looks the same as looking at http://localhost:8080/index.html.
By default, Resin copies text to the browser. For example, Resin copied the '2 + 2 = ' to the browser. In fact, if you wrote a JSP file with no special tags, Resin would copy it entirely to the browser; it would be equivalent to an '.html' file. Resin is smart enough to see that the page is static, so it can avoid working hard.
The special tags '<%' and '%>' tell Resin to do something active, something script related. You will only need to learn a few of these special tags:
||<%@ ... %>||Directive
||<%= ... %>||Java expression
||<% ... %>||Java function
||<%! ... %>||Java declaration
In the add.jsp example,
the expression tags, e.g.
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.