aspose file tools*
The moose likes JSP and the fly likes jsp:forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:forward" Watch "jsp:forward" New topic
Author

jsp:forward

Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
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

Joined: May 29, 2003
Posts: 1258
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.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
Lucky Singh
Ranch Hand

Joined: Jan 19, 2004
Posts: 125
But I ALSO WANT TO PASS THE STUDENT NUMBER AS A PARAMETER TO b.JSP.
Jose Zaleta
Greenhorn

Joined: Mar 04, 2004
Posts: 15
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])));
}
%>


SCJP, SCWCD, SCEA
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: jsp:forward