ssharma
ssharma

Reputation: 349

JSP not printing the object correctly

I started learning Spring MVC and created a controller, added a dummy object in ModelAndView:

 modelAndView.addObject("pageContext", pageContext);

Tried to access it in JSP like this:

<div>${pageContext}</div>

But, it's printing an output like:

org.apache.jasper.runtime.PageContextImpl@3085ff7b

Shouldn't it print the exact object output? Using tomcat 9 and jdk8.

Could anyone please point out what might be missing?

Upvotes: 0

Views: 130

Answers (1)

codependent
codependent

Reputation: 24472

pageContext is the name of an implicit JSP object. Try naming something else the object you insert in the model.

modelAndView.addObject("someObject", theObject );

Upvotes: 1

Related Questions