not able return the list in the jsp

Posted on 2014-04-13
Medium Priority
Last Modified: 2014-04-28

I have a piece of code  in a  controller which  has a  method to display the list of item
 from the data base  i.e i could see the data in the sop but not able to display the data
in the jsp .  

 what could be the reason...

Thank you
 java code
//Display listExistingRights(/) 
	@RequestMapping(value = "tile/list")
	public ModelAndView existRights
	( Model model, HttpServletRequest request) {

		List<WebdUserRight> maintainrights = new ArrayList<WebdUserRight>();

		EntityManager em = DataAccess.emf.createEntityManager();

		try {
			maintainrights = WebdUserRight.findAll(em);
			model.addAttribute("maintainrights", maintainrights);
			for (WebdUserRight rights : maintainrights) {
				System.out.println("rights: " + rights.getCode() + ", drsc: "                                          +  rights.getDescrip());

		} finally {
		return new ModelAndView( "tile/mainRights", "maintainrights", maintainrights);

Open in new window

in jsp i use

    <c:forEach var="rights" items="${maintainrights}" varStatus="idx">
		<tr data-right-id="${rights.code}" >
			<td style="width:30px;text-align: center;">
        	    <img class="addEditRights" style="cursor:pointer;" src="/asset/image/silk/edit.png" />

Open in new window

on click event when i call  the above jsp page it donot display anything

$( "#MaintainRights").click( function() {

document.location.href = "/tile/mainRights.html?maintainrights="+maintainrights;

Open in new window

Question by:roy_sanu
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 20

Expert Comment

by:chaitu chaitu
ID: 39997442
you should call your controller and in turn it will redirect to the jsp page..

see this example

call the servlet like this.



public class MemberController

    public ModelAndView registerNewMember()
          List<Member> maintainrights = new ArrayList<Member>();
          Member m = new Member();
          m.setId(new Long(1));
          Member m1 = new Member();
          m1.setId(new Long(2));

          return new ModelAndView( "index", "maintainrights", maintainrights);


      <c:forEach items="${maintainrights}" var="member">
                                                            <td><a href="<c:url value="/rest/members/${member.id}"/>">/rest/members/${member.id}</a></td>
LVL 20

Expert Comment

by:chaitu chaitu
ID: 39997445
apart from that you cannot send the object in the url

$( "#MaintainRights").click( function() {

document.location.href = "/tile/mainRights.html?maintainrights="+maintainrights;

Author Comment

ID: 39997563
There is no problem with the controller sending to the jsp.. As with the debug i could see the  value... but  i think the issue is how am i going to pass the object to url  

"it should happen on click of the button, but this does not work even i change to below code.. It goes to the url but do not give me any data
$( "#MaintainRights").click( function() {

document.location.href = "/tile/mainRights.html"

Open in new window

LVL 20

Expert Comment

by:chaitu chaitu
ID: 39998209
where should it go?should it go to controller or jsp?first it should go to controller and then should redirect to jsp right,..

LVL 16

Accepted Solution

Valeri earned 2000 total points
ID: 39998564
I think that
@RequestMapping(value = "tile/list")
shoud be changed to
@RequestMapping(value = "/tile/mainRights")
then your link in JS should be changed to:
document.location.href = "/tile/mainRights";

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question