Simple JSP page
Resin 3.0

Features
Installation
Configuration
Web Applications
IOC/AOP
Resources
JSP
Servlets and Filters
Portlets
Databases
Admin (JMX)
CMP
EJB
Amber
EJB 3.0
Security
XML and XSLT
XTP
JMS
Performance
Protocols
Third-party
Troubleshooting/FAQ

Introduction
JSP Compilation
Reference
Tutorials
Articles
FAQ

JSP Page Creation
Request
Topics
Tag Libraries

JSP
parse error messages
runtime error messages
JSP Page Creation
JSP Page Creation
parse error messages

Simple JSP page

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 /usr/local/resin/webapps/ROOT/

Create the text file doc/test/add.jsp (/usr/local/resin/webapps/ROOT/test/add.jsp) with your favorite text editor: notepad, emacs, vi, or whatever. It should contain the following text:

add.jsp
2 + 2 = <%= 2 + 2 %>

To see Resin in action, you need to look at the page in the browser. The URL is http://apl02.pmcg.ms.gov.br:80/test/add.jsp

If everything works, you should see the following page:

2 + 2 = 4

An explanation

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:

TagMeaning
<%@ ... %>Directive
<%= ... %>Java expression
<% ... %>Java function
<%! ... %>Java declaration

In the add.jsp example, the expression tags, e.g. <%= 2 + 2 %>, tell Resin to evaluate the text as a Java expression and print the result to the browser. In this case, 4.


JSP Page Creation
JSP Page Creation
parse error messages
Copyright © 1998-2005 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.