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

Page 113

Advertising
background image

3.

Add the

<c:out>

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:

<h3 align="center"><c:out value="${now}"/></h3>

After modification, the

insert.jsp

file appears as:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ include file="/WEB-INF/jsp/include.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Spring Getting Started - EmpInfo Application</title>
</head>
<body>
<h2 align="center"> We
lcome to the EmpInfo Application </h2>
<br>
<h3 align="center"><c:out value="${now}"/></h3>
<br>
<p><B><font color = "003399">Enter Employee Details</font></B></p>
</body>
</html>

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

Adding Dependency JAR

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

Advertising
This manual is related to the following products: