PDA

View Full Version : Problem is displaying the data in JSP using spring



ashish261080
Dec 15th, 2006, 12:49 AM
Hi everyone,

I am facing a problem displaying the user name and login time on successful login. I have tried hard but fail to figure out the problem. Below is my controller class which redirects to the successfulLogin.jsp page also listed below-

/**
* The Class LogonSimpleFormController.
*/
public class LogonSimpleFormController extends SimpleFormController {

/**
* Default Constructor
*/
public LogonSimpleFormController() {
System.out.println("in LogonSimpleFormController constructor");
}

/**
* On submit.
*
* @param command
* the command
*
* @return the model and view
*
* @throws ServletException
* the servlet exception
*/
public ModelAndView onSubmit(Object command) throws ServletException {
User user = (User) command;
System.out.println("in LogonSimpleFormController onSubmit="
+ user.getUsername());
Map myModel = new HashMap();
String now = (new java.util.Date()).toString();

myModel.put("user", user);
myModel.put("now", now);
return new ModelAndView(new RedirectView(getSuccessView()), "model",
myModel);
}
}


And my jsp page is -

<%@ include file="/WEB-INF/jsp/include.jsp"%>
<%@page import="java.util.HashMap, com.dev.model.User" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Logged In</title>
</head>
<body>
<%
System.out.println("in succeesfullogon.jsp=" + request.getParameter("model"));
%>
<h1>You have sucessfully logged in as <core:out value="${model.user.username}"/> at <core:out value="${model.now}"/> </h1>
</body>
</html>


but the jsp does not show the value of "now" and "username" although the System.out.println shows that the model object is there in the jsp page and also the username is getting printed on the console from the controller's onSubmit method.

What gets displayed on the jsp page is

You have sucessfully logged in as at
and the querystring is
http://localhost:8080/spring/successfulLogin.htm?model=%7Bnow%3DFri+Dec+15+11%3 A12%3A49+IST+2006%2C+user%3Dcom.dev.model.User%40e 01873%7D


Any idea what the issue might be?

Thanks,
Ashish Abrol

Arjen Poutsma
Dec 15th, 2006, 07:16 AM
You will probably get an answer for this question in the Web forum: http://forum.springframework.org/forumdisplay.php?f=25