Results 1 to 3 of 3
  1. #1
    kader_sit is offline Member
    Join Date
    Jun 2010
    Rep Power

    Default how to pass parameter from one jsp to another jsp

    how pass parameter from one jsp to another jsp using button onclick??

    i use this one..

    in the above how can i pass parameter???

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    in this case, i assume that this is on a different page than the getpass.jsp and we want to on click make it go to to this getpass.jsp.

    for an onClick() event handler, this is entirely a client-side javascript operation here. that is to say, this is not JSP specific.

    perhaps you could use a HTML <form> with a hidden field(s) that you would stuff full of the parameters you would want to send to the second page. And then, have the onClick() post this form, instead of adjusting the location.href.

    For example.

    Java Code:
    <form name="submitToGetPassForm" action="getpass.jsp">
      <input type="hidden" name="param1" value="someValue"/>
      <input type="hidden" name="param2" value=""/>
    <script type="text/javascript">
      function doGetpass() {
        var form = document.forms['submitToGetPassForm'];
        // stuff some value into the form field
    <span onClick="doGetpass();">Bla bla bla</span>
    You could also have the option of making this be a POST or GET style request.

    Note its been a while since i've had to do JavaScript, so this is probably terrible coding:).

  3. #3
    Sno's Avatar
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Rep Power


    This is how I do my passing,
    var Customer Number = 273;

    the param CN for Customer Number


    or put it in a variable


    than it will get carried to the next page where you will put this function at the top of your page,

    Java Code:
    function gup( name ){  
    name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");  
    var regexS = "[\\?&]"+name+"=([^&#]*)";  
    var regex = new RegExp( regexS ); 
     var results = regex.exec( window.location.href );  
    if( results == null )    return "";  
    else    return results[1];};

    var newpageCustomerNumber = gup ( 'CN' );

    to get the variable
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

Similar Threads

  1. Replies: 2
    Last Post: 09-29-2009, 04:33 PM
  2. I can't seem to pass a file through a parameter
    By daletron3030 in forum New To Java
    Replies: 5
    Last Post: 01-15-2009, 07:07 AM
  3. Can a method take itself as parameter?
    By bukake in forum New To Java
    Replies: 10
    Last Post: 09-06-2008, 10:26 PM
  4. Replies: 1
    Last Post: 08-22-2008, 07:28 PM
  5. How to pass two parameter in struts-config using dynaActionForm
    By 82rathi.angara in forum Web Frameworks
    Replies: 2
    Last Post: 06-10-2008, 03:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts