Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Framework How to pass the value from controller to jsp page ?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Lajisha p
How to pass the value from controller to jsp page ?
2 Answer(s)      3 years and 2 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:
 

 

 

DMCA.com