0
@RequestMapping(value = "",method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
    model.addAttribute("message", doctorDetails);
    return "doctorchannelling/index";
}

I have added this controller in my SpringMVC project now I need to access the element doctorDetails in a java code which is inside a jsp

how can I call this doctorDetails inside <% %> Mark

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Prakhash
  • 644
  • 2
  • 9
  • 20

2 Answers2

-1

You can simply use the EL to print them as,

${message}

If it is a String set in the request. For Model objects use ,

${message.fieldName}

See Also

Community
  • 1
  • 1
Santhosh
  • 8,181
  • 4
  • 29
  • 56
  • I'm getting error saying cannot resolve symbol "message". that variable message is defined inside the controller. in usual cases when I deal with jsp & servlets i have used the code segments which you mentioned but here I’m not able to retrieve the value – Prakhash Dec 18 '14 at 05:23
  • what is `doctorDetails` and are you redirecting it to the page you have the EL code ? – Santhosh Dec 18 '14 at 05:30
  • @DownVoter Can you pls leave a comment ? – Santhosh Dec 18 '14 at 05:32
  • @sanDecruz can you pls remove my downvote also, it is an accepted answer – Ankur Singhal Dec 18 '14 at 05:34
  • doctorDetails contains String value.. No I didn't I have used the below code & now i'm getting the aswer <% String message = (String)request.getAttribute("message"); %> Thanks a lot – Prakhash Dec 18 '14 at 05:36
-1

Something like below

<% String message = (String)request.getAttribute("message"); %>

or

<%
    String message = ${message};
%>
Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116