How to pass the value from controller to jsp page ?

How to pass the value from controller to jsp page ?

HI

I need to pass the value from controller to jsp.

I use the way like this

Controller

request.setAttribute("msg", "Successfully Login");

In jsp

${msg}

and then i didn't see the message . then i changed the jsp as

<%= request.getAttribute("msg") %>

again the msg didn't see.

when i set the controller as request.getSession().setattribute("msg", "Successfully Login");

jsp as

${msg}

Then the message shown.

but when refreshingor reloading its still there. means its not refreshing that message

any solution?

View Answers

October 19, 2011 at 4:51 PM


October 20, 2011 at 2:01 PM

It is resolved

Previously the code in controller as:

request.setAttribute("msg", "Successfully Login"); ModelandView modelAndView =new ModelandView("login.html");//login.jsp resolved as login .html

return modelAndView ;

and in login.jsp as:

${msg}

but not showing the message.

now code is changed in controller as:

request.setAttribute("msg", "Successfully Login"); return showForm(request, response, errors);

Now it is working fine.









Related Tutorials/Questions & Answers:

Ads