This document discusses converting HTML files to JSP files and utilizing JSP implicit objects and tags. It explains creating register.jsp by copying the code from register.html. It also discusses adding code below the <div> tag to get messages from the RegisterServlet, and creating strings.java to manage strings. It shows the output of an error when the MySQL server is off and redirection to the login page when registration is successful.
This document discusses converting HTML files to JSP files and utilizing JSP implicit objects and tags. It explains creating register.jsp by copying the code from register.html. It also discusses adding code below the <div> tag to get messages from the RegisterServlet, and creating strings.java to manage strings. It shows the output of an error when the MySQL server is off and redirection to the login page when registration is successful.
This document discusses converting HTML files to JSP files and utilizing JSP implicit objects and tags. It explains creating register.jsp by copying the code from register.html. It also discusses adding code below the <div> tag to get messages from the RegisterServlet, and creating strings.java to manage strings. It shows the output of an error when the MySQL server is off and redirection to the login page when registration is successful.
This document discusses converting HTML files to JSP files and utilizing JSP implicit objects and tags. It explains creating register.jsp by copying the code from register.html. It also discusses adding code below the <div> tag to get messages from the RegisterServlet, and creating strings.java to manage strings. It shows the output of an error when the MySQL server is off and redirection to the login page when registration is successful.
ADVANCED PROGRAMMING AND TECHNOLOGIES Week 4 Introduction on JSP
ADVANCED PROGRAMMING AND TECHNOLOGIES Prithivi Maharjan
Tutorial Task In this tutorial we will convert the html files into JSP. After that we will utilize JSP Implicit Objects and JSP Tags
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 2
Creating JSP file Create a new JSP file inside pages folder with name register.jsp
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 3
Creating JSP file • As we can see we have created a new file named register.jsp
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 4
Creating JSP file • Now copy all the codes of register.html and paste it below the line number directive tag - <%@ … %> (starting from line number 3 where <!DOCTYPE html> is located).
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 5
Creating JSP file • Now we can delete the register.html file (Fig 1) • Similarly create JSP file for login and welcome HTML files and utilize the html code to JSP as we have done before. (Fig 2) Fig 1: Current Files Fig 2: Updated Files
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 6
Creating JSP file In register.jsp file add the code shown below the <div class=“container”>. • By this approach we can get the message from Java Servlet file
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 7
ResigterServlet.java As we can see we can send message according to our needs to the different pages with the help of request and response.
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 8
String Utilization Now we will add all the strings used in our RegisterServlet.java file to StringUtils.java
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 9
String Utilization Put all the string parameters in the StringUtils.java file so that we can easily manage and reuse them when needed.
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 10
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 15
Output Error message when MySQL server is off
Step 1: Stopping MySQL server.
Step 2: Error message shown as expected on submit.
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 16 Output Successfully redirected to login page when server is started Step 2: Adding data Step 3: Redirected to login after success.
Step 1: Starting Server
ADVANCED PROGRAMMING AND TECHNOLOGIES August 7, 2022 | 17