Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Parameter passing problem

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
My problem is that I want to pass a parameter from a.jsp to b.jsp. I want to store my variable in e hidden input, and when I submit a link, the a.jsp will send the parameter to b.jsp.

a.jsp
==============================================
<form action="gekozenKind.jsp" method="post" name="submitKind">
<a href="gekozenKind.jsp">
<%= v_naam.get(i) %></a>
<br>
<%= v_gebDatum.get(i) %>
<br>
<%= v_afkomst.get(i) %>
<input type="hidden" name="weesID" value="<%= v_id.get(i) %>">
</form>

b.jsp
==============================================
<%= request.getParameter("weesID") %>

I tried this code but the <%= request.getParameter("weesID") %> returns always a null.

Could someone help me to fix this prob?

Abu Romaysa,
 
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
You're not submitting the form.
Either replace the link with a submit button.
<input type="submit".....

or use the onclick event in the anchor tag to submit the form instead of excecuting the link.
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not want to use a button, because then I'll get a page with more then 21 buttons. I tried it with the button and it works great, but don't know how to do that with a link cuse that's what I wanna do.

Thanks
Abu Romaysa
 
author & internet detective
Posts: 40722
827
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Azz,
You can also pass the parameter in the link itself. Note that it will be a GET request rather than a POST request:


If you realy need a post, you can intercept the user's click through javascript. Have the onClick handler call a user defined function which submits the form.
 
Ben Souther
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


If you're repeating this in a loop, you'll want to build the form's id attribute dynamically. The "return false" statement in the onclick event keeps it from actually behaving like a link (probably redundent in this case but it makes for clearer code.).

I know this works in Mozilla/Firefox and MSIE 6 and up. You'll have to test on legacy (pre DOM) browsers if you plan on supporting them.

I had to mispell onklick to get this top post in this forum. Change the 'k' to a 'c' to get it working.
[ December 26, 2004: Message edited by: Ben Souther ]
 
Where does a nanny get ground to air missles? Protect this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic