Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

pass paramter between jsp page  RSS feed

 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i pass the parameter to another jsp from jsp based on the clicking linkage.

as i retrieve data from the resultset,so the linakage should be
<% while rs.next()){%>
<%=rs.getString("ID")%>
<%}%>

when the user click on the link, then pass the ID value to second.jsp accordingly.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got Java code in a JSP? Doing database access?

You should really read up on modern JSP. Putting java code in a JSP has been a discredited practice for over 8 years now.

In any case, regardless of where the data comes from, the answer is the same: put the value as a request parameter in the query string of the link URL.

The <c:url> JSTL tag can help you properly format and encode the URL.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as the page is already in the frame of another page.
so when the user click on the linkage, the target should be _self.
the URL still be the page file contain this frame.
no change of the url when user click the linkage.

by the way, if i don't get the resultset and then read it on jsp.
what should i do?

one of the advantage using jsp is it can be conbime java and html.
why not.

sorry, i am beginner to use jsp,so i ask more about this programming language.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66188
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ll Gii wrote:one of the advantage using jsp is it can be conbime java and html.
why not.

No, that is a distinct disadvantage and leads to a horrible horrible mess.

Modern JSP best practices dicate no Java on JSP pages. If you are just leaning JSP, you should learn how to do it correctly, right off the bat.

You might want to read this article and this article.

Back to your question: what do you mean by "no change of the url when user click the linkage". If you cannot change the URL, you cannot accomplish your goal.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a home.jsp containing 3 frame in the page(top ,left, and then right)
the page content.jsp is in the right frame contain the following code:

just change the

if i change to
<%=rs.getString("ID")%>+"'" target="_self">

the url at the browser will not be change ,still is home.jsp after clicking the link.

so how to get that ID value from aaa.jsp pass from content.jsp
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!