beautypg.com

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

Page 98

background image

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" %>



Spring Getting Started with EmpInfo Application


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 2 JSTL and JSP Dependency JAR Files

Source Location

Dependency JAR Files

<Spring Dependency Home>/javax.servlet/
com.springsource.javax.servlet.jsp.jstl/
1.1.2

com.springsource.javax.servlet.jsp.jstl-1.1.2.jar

<Spring Dependency
Home
>/org.apache.taglibs/

com.springsource.org.apache.taglibs.standard-1.1.2.jar

com.springsource.org.apache.taglibs.standard/
1.1.2

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

“Adding Dependency JAR Files in

the Project Library Path” (page 89)

.

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, the controller file EmployeeController.java appears as:

package com.hp.empinfo.web;
import org.springframework.web.servlet.mvc.SimpleFormController;

98

Getting Started with Spring

This manual is related to the following products: