Finishing the Project: Java Web Development in Eclipse and Tomcat
Last week, I introduced you to some of the fundamental concepts you need for working with Java web components. For this project we'll be working with JSP and servlets. I walked you through getting the appropriate downloads installed and setting up your work space. We stopped after just creating the web project. In this part, we will add our content, including HTML, JSP, and servlets.
Finishing the Project: Java Web Development in Eclipse and Tomcat - Create welcome.jsp (Page 2 of 4 )
Creating a JSP page requires taking similar steps as you did for creating an HTML file except for selecting JSP rather than HTML from the context menu. The text of welcome.jsp file is below.
You can see that JSP is a mixture of HTML elements and Dynamic Java code.
Everything between the start tag <% Œ and end tag %> is JSP code, in other words, Java code.
A JSP page may contain the following components:
static HTML
JSP directives such as the include directive
JSP scripting elements and variables
JSP actions
custom tags
In this simple JSP, only JSP scripting elements and variables are used.
You might ask where the request Ž comes from. The request is one of six JSP Implicit Objects: out, page, pageContext, request, session, and config. They can be references from your JSP code directly.
The code between Œ and features scriptlets just like your Java Code in a method.