Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:forward

 
Lucky Singh
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I go from A.jsp to B.jsp by clicking on a hyperlink in A.jsp?
where A.jsp displays-
John Economics
Mary Computer Science
George History
<%

for(int i=0;i<array.length;i++)
out.println("<A HREF=jsp:forward page="B.jsp"?StudNumber=abc.getStudentNumber>" +
abc.getStudentName(array[i])+ "</A>" + abc.getStudentDepartment(array
[i]));
%>
Is this syntax correct? On clicking a link, for a student I pass the pasrticular student's student id to B.jsp?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're confusing JSP syntax with HTML syntax.
JSP is (usually) used as a mean to generate HTML code. In your case, within A.jsp, you just want to create a regular HTML link:

and that is all you need to provide for a person to click on it and be taken to B.jsp.
 
Lucky Singh
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But I ALSO WANT TO PASS THE STUDENT NUMBER AS A PARAMETER TO b.JSP.
 
Jose Zaleta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a sample code on what you want. Hope it helps. Good luck.
<%
String strLinkOpen = "<A HREF=\"B.jsp?StudNumber=";
String strLinkClose = "</A>";
for(int i=0;i<array.length;i++) {
out.println(strLinkOpen + abc.getStudentNumber() + "\">" +
abc.getStudentName(array[i])+ "</A>" + abc.getStudentDepartment(array[i])));
}
%>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic