Adv Java 1.4 Exercise Guide - JSP Syntax
Adv Java 1.4 Exercise Guide - JSP Syntax
2. On the desktop, double-click the Eclipse icon to open Eclipse IDE. (You may have to scroll down
using the right side scroll to see the Eclipse icon.) Click Launch Anyway if a warning box appears.
3. In the Eclipse IDE Launcher window, click Launch to select the default workspace.
4. When Eclipse opens, click File > New > Dynamic Web Project.
7. Expand Apache.
9. In the next window, click Browse and select the location of Tomcat installation Other Locations >
Computer > tmp > apache-tomcat-10.1.10 and click Open (you may have to scroll down to see
the Open button).
13. On the Web Module page, select the box for “Generate web.xml deployment description” and
click Finish.
15. Now that you see your project in the Project Explorer pane, expand MyJSP App > src > main >
webapp.
16. Right click on webapp and select New > JSP File.
18. Right click on webapp and select New > JSP File.
21. The new jsp files open to the right of the Project Explorer pane of Eclipse. (Note: You can close the
Welcome pane and the Outline pane to give yourself more room if you like.)
22. Click on the index.jsp file tab for the next part of this lab.
1. In the index.jsp file, import the "java.util.Date" class using the @page directive by typing the
following code on line 3:
2. Move down to the bottom of the <body> and add a scriptlet to display the current date on the
page, and add a line break:
3. Just after the <body> tag, add the following @include directive to include a header.jsp file:
<h3>Hello World!</h3>
<%=”Welcome to JSP”%>
<br>
5. Now, add more scriptlets to print numbers from 1 to 5. On the line after the line break, enter:
<p>
<% // Start of Scriptlet
for (int I = 1; I <= 5; i++) {
%>
<p><%=i%></p>
<% // End of for loop scriptlet
}
%>
6. Use the @include directive at the end of the body to include the footer.jsp file:
10. Inside the body, add a level 1 header that says “THIS IS THE HEADER.”
11. Click the Save icon in the toolbar to save your changes.
14. Inside the body, add a level 1 header that says “THIS IS THE FOOTER.”
15. Click the Save icon in the toolbar to save your changes.
18. Select a server: Expand Apache and select Tomcat v10.1 Server and click Finish (you may have to
scroll down to find the Finish button).
19. After the script runs, a Firefox window will open, displaying your index.jsp page. Your output
should look like the following image:
**End of lab