• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

How do I pass a variable from one jsp to another?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For example: Say I've set the ID of btnDelete equal to the variable custID. When I click btnDelete I'd like to push that variable to the next page.



To shed some light on why I'm not simply using request.getParameter: I'm filling a table with data from a database (Something similar to a data grid in ASP.NET) One of my columns has a 'Delete' button; when I select any given delete button I want to delete that row of data. This is how I've built my table:

So while I build my table I can set the custID variable to something like the id of the 'Delete' button or in a hidden text box.

I don't know, maybe this is all real "Hokey" but it's the best that I can come up with....
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put a hidden input with the value in the form.

Two other things:
  • Putting a button inside a label is really weird.
  • Java in a JSP is a very very poor practice that's been discredited for almost 10 years now. Time to get down with modern techniques...

  •  
    Bradly Fackrell
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Bear Bibeault wrote:

  • Java in a JSP is a very very poor practice that's been discredited for almost 10 years now. Time to get down with modern techniques...



  • Scarry since that is how my instructor is teaching it....

    Anyway, I've been working on this to the point where I can't think straight. From what I've read; it seems like I should be doing this through a function but I haven't been able to put that together.
     
    Bear Bibeault
    Sheriff
    Posts: 67754
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Bradly Fackrell wrote:Scarry since that is how my instructor is teaching it....


    oi!

    Oh well, when you're out on your own, know that things have moved on quite a bit...

    From what I've read; it seems like I should be doing this through a function but I haven't been able to put that together.


    Can't think of any reason that you need anything but a hidden input.
     
    Bradly Fackrell
    Greenhorn
    Posts: 13
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I don't know why I was fighting the hidden field route. After some sleep I tried that again with success.

    Thanks Bear!
     
    reply
      Bookmark Topic Watch Topic
    • New Topic