Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

pass parameter from jsp to jsp

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Web application development using JSP
 
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
return value is NULL when i give the hidden field a name
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like

if (request.getParameter("id") != null) {
...
}
 
Li Jenny
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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')%>
 
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic