JSP Basics with Java Studio Creator 2 for VB Programmers - Creating a simple JSP page
(Page 3 of 5 )
JSPs are contained in a project, and it is necessary to create a project first. From File--> New Project you open the next screen, where you create a project.

Here you choose a WEB category which points to a default JSF Web application. In the WEB category you may import a project created in an earlier version or a JSR-169 portlet project. For this tutorial choose a JSF Web Application. A standard project can have all the features of building, running and debugging the project in the IDE. Now click the Next button; this takes you to the next window.

In this tutorial this project has been named MyFirst. Review the location of the project folder and files as well as the default package name. Now click on the Finish button.
The project gets created with all the standard required resources as shown. The project comes with an initial JSP page, Page1. For this newly created project, this also happens to be the start page. It also comes with a default theme. The page can be renamed by right clicking the page and choosing to rename. You may also change the theme. For this tutorial, the default page name was accepted and a green theme was chosen by right clicking a theme and choosing set as current theme. The page can now be accessed by running the project, which gets displayed at the URL address http://localhost:28080/MyFirst/.

Each JSP has associated with it three tabbed pages, one each for the design, Java, and JSP aspects of the page. The design is where you drag and drop and manipulate your controls, JSP is where you see the code for JSP with all the tags, and Java is where the Java coding of your project is made. The next window shows the tabbed page Design of Page1.jsp. Presently it is empty, but read carefully the text on this page, which describes what actions are to be taken to work on this canvass.

The next paragraph shows the tabbed page JSP of Page1.jsp. This is color coded for ease of readability. This is an xml file. Again it is empty of any components.
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:ui="http://www.sun.com/web/ui">
<jsp:directive.page contentType="text/html;charset=UTF-8"
pageEncoding="UTF-8"/>
<f:view>
<ui:page binding="#{Page1.page1}" id="page1">
<ui:html binding="#{Page1.html1}" id="html1">
<ui:head binding="#{Page1.head1}" id="head1">
<ui:link binding="#{Page1.link1}"
id="link1"
url="/resources/stylesheet.css"/>
</ui:head>
<ui:body binding="#{Page1.body1}" id="body1"
style="-rave-layout: grid">
<ui:form binding="#{Page1.form1}" id="form1"/>
</ui:body>
</ui:html>
</ui:page>
</f:view>
</jsp:root>
In this page you may insert a JSP tag by just inserting a < character, which opens a JSP Completion drop-down menu from which you can choose a variety of items; that includes JSP tags and other tags as shown.

Remove the < character now. Go to the menu item Build and from the drop-down click on Clean and build main project. This will produce an output as shown.

On the tabbed page, Java shows the code inserted during design as shown in the next picture (partially shown).

Next: Adding basic components to the page >>
More Java Articles
More By Jayaram Krishnaswamy