Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  44] [ 2]  / answers: 1 / hits: 6267  / 10 Years ago, fri, august 1, 2014, 12:00:00

I have a jsp page with multiple links created inside a loop. All the links go to exactly one another jsp page. In the second jsp page I need to find out which link was clicked in the first jsp page. How can I do that ? Is there any way after clicking a link in the first jsp page I can set an attribute instantly, so that in the second page I can get that attribute to determine which link was clicked ?



Here is my code of the loop with the links -- http://pastebin.com/J3JGu5jD



<%  
System.out.println(Going inside loop);
for(int i = 0; i < n_row ; i++)
{
course_name = dbManager.get_course_name(teachers_course_id_list[i]);
course_id = teachers_course_id_list[i];
%>
table = '<tr><td> <a href=MarkDistribution1.jsp?course_id_QSparam
='+<%=course_id%>+'>'+ <%=course_id%> + ': ' + <%=course_name%>+'</td>
</a></tr>'
document.write(table);
<%
}
%>


PS: Another question. I have a string variable link. is this the proper way to assign it to the javascript variable --- javascript_variable = <%=link%> ?


More From » jsp

 Answers
15

This is weird. I solved the problem by changing the code like this,



<%  
String link;
System.out.println(Going inside loop);
for(int i = 0; i < n_row ; i++)
{
course_name = dbManager.get_course_name(teachers_course_id_list[i]);
course_id = teachers_course_id_list[i];
link = <tr><td> <a
href=MarkDistribution1.jsp?course_id_QSParam=+course_id+>+course_id+:
+course_name+</td></a></tr>;
%>
table = '<%=link%>'
document.write(table);
<%
}
%>


Assigned java variable link inside the java script variable table using single quote. Thanks anyway guys.


[#43431] Thursday, July 31, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bryantc

Total Points: 455
Total Questions: 96
Total Answers: 110

Location: San Marino
Member since Thu, Jun 30, 2022
2 Years ago
bryantc questions
Fri, Aug 13, 21, 00:00, 3 Years ago
Tue, Mar 30, 21, 00:00, 3 Years ago
Fri, Jun 5, 20, 00:00, 4 Years ago
Wed, May 27, 20, 00:00, 4 Years ago
;