Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JSP and the fly likes How to set table values as parameters (present on one page) and pass it into another jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to set table values as parameters (present on one page) and pass it into another jsp" Watch "How to set table values as parameters (present on one page) and pass it into another jsp" New topic
Author

How to set table values as parameters (present on one page) and pass it into another jsp

Sarah Choudhary
Greenhorn

Joined: Sep 05, 2012
Posts: 11
hi


I'm getting list of values from database and printing this list in a table on a jsp like this


courseId CourseName GPA


part of the code is:




Now, I want to add 'edit functionality' for course instructor. A hyperlink with text 'edit' will be present on this page while the edit functionality will be on another page. If instructor wants to edit a particular record, he may click on it and he will be redirected to a new page where the clicked record's values will be automatically shown through get parameter. e.g. a student has taken several courses and the instructor want to edit the record of a particular course, when he clicks on that record, all the three parameters should be set and get into the next jsp.

can anybody help me in this regard?

Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
For implementing edit functionality you shouldn't pass params from one page to another. Its bad programming.
Infact you should create new jsp for editing record and new action for edit and just pass id of the entity which needs to be edited.

Which technology/framework are you using?

Refer to some CRUD operation sample before you proceed ahead with your application. That will help you.

Thanks,
Ashwini Kashyap | www.infocepts.com
Sarah Choudhary
Greenhorn

Joined: Sep 05, 2012
Posts: 11
Ashwini Kashyap wrote:For implementing edit functionality you shouldn't pass params from one page to another. Its bad programming.
Infact you should create new jsp for editing record and new action for edit and just pass id of the entity which needs to be edited.


| www.infocepts.com


I am trying to do the same thing. There is a new jsp for editing the record. I just want to get id and gpa of that student which is clicked by the instructor. That's what I want to get.



Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Ok then great.
But which technology/framework are you using?

Sarah Choudhary
Greenhorn

Joined: Sep 05, 2012
Posts: 11
Ashwini Kashyap wrote:Ok then great.
But which technology/framework are you using?



Actually, This code is the part of webservice and JSPs are basically built on servlets.


I am using NetBean IDE 7.2 for this.
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Ok.
Create action of your edit hyperlink and make use of query string like:
editActionName?studentId=--&gpa=--

Thanks,
Ashwini
Sarah Choudhary
Greenhorn

Joined: Sep 05, 2012
Posts: 11
Ashwini Kashyap wrote:Ok.
Create action of your edit hyperlink and make use of query string like:
editActionName?studentId=--&gpa=--

Thanks,
Ashwini



Ok, I have tried but I am getting error. As I have mentioned earlier that parameters will be set from the table row which is clicked.

The error is on the "edit.jsp", it returns null value. I think, the problem lies in the setting the attributes. Since I am printing the ArrayList through iterator so string query is unable to understand which row data is clicked.
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
In that case, what you can do is:
With the help of JavaScript or JQuery, on the click of that edit link, pass the id and so on params and then submit the form to the server.

Go through some examples of JSP, Servlets and JavaScript/Jquery CRUD examples it will help you.

Thanks,
Ashwini Kashyap | www.infocepts.com

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to set table values as parameters (present on one page) and pass it into another jsp
 
Similar Threads
groovy's html builder....
How to reference a Map<String, List<String>> via ValueExpression
Fetch 10K rows from table
Disable HTML frame using Javascript