Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pass parameter from jsp to jsp

 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i would like to ask you
if i have a home.jsp which contain 3 frame
header,and then bottom divide left menu and right content
i have resultset loop to diaply the data
<% while (rs.next()){ %>
<%=rs.getString(1);%>
<input type="hidden" value="<%=rs.getString("ID")%>" />
<% }>

how can i pass the parameter(rs.getString("ID")) to next.jsp when clicking the link.
in order i need the id to retrieve relvant data in next.jsp.
 
Amit Vinod Dali
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Web application development using JSP
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@OP

give the hidden field an ID, and use in next JSP page. Thats it.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
return value is NULL when i give the hidden field a name
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hidden input field values will only be passed if a form is submitted.
Forms are not submitted when hyperlinks are pressed.
If you want to pass parameters when a hyperlink is passed, you'll need to add them to the URL as querystring parameters.
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i use query, when the page is redirected from this link is nornally worked.
but when i call the nex.jsp not by the query.
then nullpointexception error occurs.
at <%request.getParameter("id")%>

how can i fix?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "call the nex.jsp" - how, exactly, does that work?
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry,let me explain more.
in home.jsp i have a link
<%=rs.getString("ID")%>" target="_self"><%=rs.getString("ID")%>


in next.jsp:
<% String id= request.getParameter("id")%>

it is ok when next.jsp is sent from home.jsp
but when the next.jsp is call from other page,does not apply query string 'id'
there is nullpointexception occurs as 'request.getParameter('id') does not extist.

how to prevent?? i try to code as belows,but it seens has error occurs:

if( request.getParameter("id").equals(null)){

request.getParameter("id").equals("");
}

to prevent null. but still has problem.

how to fix?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like

if (request.getParameter("id") != null) {
...
}
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i use javascript to pass parameter from popup window to opener window because i need to submit the opener window and close the popup from js.

so that opener window to get value by:

<%request.getParameter('id')%>
 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of setting/getting it as a parameter. Set it as an attribute (request.setAttribute()). This will be more convenient.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic