Meaningless Drivel is fun!
The moose likes Spring and the fly likes Bind JSP values to controller Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Bind JSP values to controller" Watch "Bind JSP values to controller" New topic

Bind JSP values to controller

Su nan

Joined: Jun 19, 2012
Posts: 4
I am working on a spring 3.1 app. I have a jsp where I display a list of projects (displayed as links) - Project name is displayed which is one of the fields in Project entity.
On click of any of these projects, I need to fetch that project name in the controller(If possible the whole Project entity) and display fruther details of same project.

Problem is, I am not able to retrieve the Project name that is clicked on by the user:
Below is the snippet from my JSP and controller where I am trying to fetch:

<form action="viewDashboard" class="simple_form" id="tProject" name="tProject" method="post">
<c:forEach items="${projList}" var="tProject" >
<tr> <td>
<a href="./viewDashboard" id="tProject.prjName" name="tProject.prjName" value="${tProject.prjName}"> ${tProject.prjName} </a>
</td> </tr>

public class DashBoardController {

DashBoardService dashBoardService;

@RequestMapping(method = RequestMethod.GET)
// @ModelAttribute("projList")
public String displayDashboardTProject tProject, BindingResult bindingResult) {
System.out.println("Proj Name:" + tProject.getPrjName()); //This displayes null now
return "Dashboard";


Can someone please point what is wrong here or if Iam completly not making any sense !!!
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

You could just add it to the end of the URL as a request parameter





In your controller method that takes that request have a parameter for the projectName like

public blah myMethod(@RequestParam(projectName) String projectName) {


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Su nan

Joined: Jun 19, 2012
Posts: 4
Thanks Mark. But If I use @requestParam in my controller as mentioned, it throws "The request sent by the client was syntactically incorrect ()" error.
This is how I am doing:

public String displayDashboard(@RequestParam("prjName")String prjName, BindingResult bindingResult) {

Also is there any other way since we are trying not to pass it in the url.. Can the annotation @modelAttribute be used.
If Yes, how do I make use of it?
I agree. Here's the link:
subject: Bind JSP values to controller
It's not a secret anymore!