Lajisha p
How to pass the value from controller to jsp page ?
2 Answer(s)      3 years and 9 months ago
Posted in : Framework

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?

Advertisement
View Answers

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: