Adding jstl and jsp related dependency jars, Enhancing the controller – HP Integrity NonStop H-Series User Manual
Page 113

3.
Add the
tag to display the current date and time retrieved from the model passed
to the view, which will be rendered using the JSTL.
For example:
After modification, the
insert.jsp
file appears as:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
"http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/WEB-INF/jsp/include.jsp" %>
We
lcome to the EmpInfo Application
Enter Employee Details
Adding JSTL and JSP Related Dependency JARs
Add the following JSTL and JSP dependency JAR files to the EmpInfo project in Eclipse:
Table 5-2 JSTL and JSP Dependency JAR Files
Source Location
Dependency JAR Files
<Spring Home>/lib/j2ee
jstl.jar
<Spring Home>/lib/jakarta-taglibs
standard.jar
To add the dependency JAR files in the project library path and to resolve the J2EE module
dependency on these JARs, follow the instructions described in the
Files in the Project Library Path
section.
Enhancing the Controller
To add more functionality to the controller class, complete the following steps:
1.
Update the
EmployeeController.java
by setting the resource reference of the view to
its new location
EmpInfo/WebContent/WEB-INF/jsp/insert.jsp
. Set the key/value
pair for the current date and time value in the model with the key identifier:
"now"
and the
string value:
'now'
as shown below:
Before modification:
logger.info("Returning hello view");
return new ModelAndView("insert.jsp");
After modification:
String now = (new Date()).toString();
logger.info("Returning view with " + now);
return new ModelAndView("WEB-INF/jsp/insert.jsp", "now", now);
2.
Add the following
import
statement:
import java.util.Date;
After modification, your controller file
EmployeeController.java
appears as:
package com.hp.empinfo.web;
import org.springframework.web.servlet.mvc.SimpleFormController;
Overview of EmpInfo
113