代写 html Java javascript Go Division of Applied Science and Technology, Community College of City University AST20201 Web Programming

Division of Applied Science and Technology, Community College of City University AST20201 Web Programming
AST20201 Web Programming Lab 7 – JSP
A. Objectives
1. Developing JSP application in NetBeans IDE.
2. Understanding Basic JSP programming technique.
B. Setup of Runtime Environment
1. Go to thislink: https://netbeans.org/downloads/index.html
Download either the Java EE or All version of the NetBeans IDE Bundles. Both of them contain the GlassFish server and Apache Tomcat server, which are the JSP/servlet containers that we need to run JSP pages.
Note: Apache Tomcat 8.0.27 is included in the Java EE and All download options but it is not installed by default from either of these options. To install Apache Tomcat, select the appropriate option below:
 from the Java EE download, launch the installer and select the Apache Tomcat 8.0.27 checkbox at the Welcome page;
 from the All download, launch the installer and select Apache Tomcat 8.0.27 in the Customize Installation dialog box.
(The All version is recommended because you can then use Netbeans to develop HTML5 and JavaScript as well.)
Page1of6

Division of Applied Science and Technology, Community College of City University AST20201 Web Programming
2. Install the NetBeans IDE with the GlassFish Server. We strongly recommend that you should install the Apache Tomcat server as well because this will simplify future deployment when you deploy your web app to some web hosting service, e.g. Redhat OpenShift used Tomcat in their containers.
3. After the installation, start the NetBeans IDE.
4. To start the GlassFish server, open the Services tab by Window > Services.
Page2of6

Division of Applied Science and Technology, Community College of City University AST20201 Web Programming
5. Expand Servers and right-click the GlassFish Server. Select Start option from the pop-up menu.
C. First JSP
Create a new project
1. File > New Project to display the New Project dialog box
Click the Java Web category Choose Web Application Press the Next > button
2. Type in the name of project (i.e. lab7) and then specify the location. Press the Next > button
3. Make sure GlassFish Server is selected.
7
4. Skip the Framework section and click Finish.
Page3of6

Division of Applied Science and Technology, Community College of City University AST20201 Web Programming
5. The Web application framework with index.html will be launched.
7
6. Save the file as index.jsp and delete the index.html.
7. Make the following modification:
– Change the title of page to “AST20201 Lab Exercise “.
– Change the content in the div to “

AST20201 Lab Exercise 7

“.
8. Choose Run > Run Project, or press F6.
If there are no errors, you are switched to the execution workspace and the output from the compiled JSP page is displayed in the web browser.
9. Adding the following code inside the div tag.
10. Execute the application again.
Today is <%= new java.util.Date() %>
Your computer’s address is: <%= request.getRemoteAddr() %>
Page4of6

Division of Applied Science and Technology, Community College of City University AST20201 Web Programming
D. Request method
1. Create a lab7d.jsp that prints the request and header information like the following images:
Page5of6

Division of Applied Science and Technology, Community College of City University AST20201 Web Programming
E. JSP Login Page
1. Create a lab7e.jsp that handle the request from the login page produced in the last lab exercise (lab6 – about Ajax). In the lab7e.jsp (server-side script), you are to get the student’s name, student id and password entered from the request received. The JSP will determine whether the password is correct or not in the result – the correctness is simply based on comparing the password entered against a hardcoded string “ast20201lab7”.
2. Copy lab6.html and save as lab7e.html (client-side HTML with jQuery Ajax code to send a POST request to the JSP). Modify the link to use lab7e.jsp instead of the last PHP script to do the login checking:
F. Submission
You are required to name your files as lab7d.jsp, lab7e.html and lab7e.jsp (for our convenience of marking, no other creative names please).
Zip all the files together, name the zip file as lab7.zip and submit it to the Canvas.
-End-
Page6of6