How to get the value in one JSP page to another?

Hi,
I have problems in passing the value around in JSP. I have two JSP pages as below:
test1.jsp
I try to get the vaule from my textbox by using:
String strUser = request.getParameter ("strUserName");
Then i print out by using: out.print(strUser); then i can get the value and put on my page (For example, i get ABC on my page).
test2.jsp
Next, i want to get the value from strUser (which mean that the one i already display on page in test1.jsp, ABC) to insert into my table by using INSERT INTO statement. Then i try by using
String strUser1 = request.getParameter ("strUser");
Is it possbile for me to do that? I cannot get anything to insert into my table. Then i tried out.print(strUser1); then i found that i get NULL value.
Could you please give me some guidance?
Thanks you very much for any advise you may give me.
Kimsan

Hi,
Thank you very much for your help. It's working fine if i just get a one value to another page, however, i have problem while i pass the value in my loop to another page because i always get the last record. I try with the following code:
logged_page.jsp
<html>
<head>
<title>Welcome to the online Auction...</title></head>
<body>
<%@ page language ="java" import = "java.io.*, java.lang.*, java.sql.*" %>
<% try
     String strUsername = request.getParameter("username");
     session.setAttribute("myUserName", strUsername);     
     String strPassword = request.getParameter("password");
     Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
     String strSQL = "SELECT [UserName], [Password] FROM tblUserDetails where [UserName] = ? and [Password] = ?";
     PreparedStatement statement = myConn.prepareStatement(strSQL);
     statement.setString(1, strUsername);
     statement.setString(2, strPassword);
     ResultSet myResult = statement.executeQuery();
     if(myResult.next())
     //out.println("Login Succesful! A record with the given user name and password exists");
     out.print("<center><h1>");
     out.print("Welcome  ");
     out.print(strUsername);
     out.print("</h1></center>");
     out.print("<center>");
     out.print("<BR><BR>");
     out.print("<font font face = Viner Hand ITC size= 5>Products on sales</font>");
     out.print("<BR><BR>");
     Statement myStatement = myConn.createStatement ();
     ResultSet myResult1 = myStatement.executeQuery("SELECT * FROM tblProduct");
     ResultSetMetaData myResultSet = myResult1.getMetaData();
     out.println("<font face=Tahoma>");
     out.print("<table border=1 CELLSPACING=0>");
     out.print("<TR>");
     out.print("<TD width = 200> Item Title");out.print("</TD>");
     out.print("<TD width = 200> Description");out.print("</TD>");
     out.print("<TD width = 200> Current bid");out.print("</TD>");
     out.print("<TD width = 200> Available Time");out.print("</TD>");
     out.print("<TD width = 200> Place Bid");out.print("</TD>");
     out.print("</TR>");
     out.print("</table>");
     while(myResult1.next())
          String strProName = myResult1.getString(1);
          session.setAttribute("myProName", strProName);          
          out.print("<table border=1 CELLSPACING=0>");
          out.print("<TR>");
          out.print("<TD width = 200>");
          out.println(strProName);
          out.print("</TD>");
          out.print("<TD width = 200>");
          out.println(myResult1.getString(3));
          out.print("</TD>");
          out.print("<TD width = 200>");
          out.println(myResult1.getString(2));
          out.print("</TD>");
          out.print("<TD width = 200>");
          out.println(myResult1.getString(4));
     out.print("</TD>");
     out.print("<TD>");
          out.print("<form action=bid_page.jsp method=post>");
          out.print("<input type=text name=place_bid>");
          out.print("<input type=submit name=okfunc value=Bid>");
          out.print("</TD>");
          out.print("</form>");
          out.print("</TR>");
          out.print("</table>");
          out.println("</font>");
          out.print("</center>");          
     else
          out.print("<center>");
          out.print("Sorry ");
          out.print("<font color = RED size = 5>");
          out.print(strUsername);
          out.print("</font>");
          out.print(" could not be found.");
          out.print("</center>");
     myResult.close();
     statement.close();
     myConn.close();
     catch(SQLException e)
     out.println(e);
%>
</body>
</html>
bid_page.jsp
<HTML>
<HEAD>
<TITLE>Welcome to the online Auction...</TITLE>
</HEAD>
<BODY>
<%@ page language ="java" import = "java.io.*" import = "java.lang.*" import = "java.sql.*" %>
<% try
     String thisUserName = (String) session.getAttribute("myUserName");
     String thisProName = (String) session.getAttribute("myProName");
          Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
     Connection myConn = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/Auction/Auction.mdb");
     PreparedStatement myStatement = myConn.prepareStatement("INSERT INTO tblHistory VALUES ('"+thisUserName+"', '"+thisProName+"', '"+request.getParameter("place_bid")+"')");
          myStatement.executeUpdate();
          myConn.commit();
          myStatement.close();
          myConn.close();
          catch(Exception e){}
%>
</BODY>
</HTML>
When i click on the BID button in the logged_page.jsp then i always get the last record and save into my table and that is not what i want to. i want to get the result on the same row as the BID button that just click and save to my table.
Could you please advise?
Thanks you very much for your time and any consideration you may give me.
Best Regard,
Kimsan

Similar Messages

  • How to change the value from one input control to another input control?

    Hi Experts,
    I want to change the value from  one input control to another input control. For Example if i change month in first tab. it should reflect in second tab also. How should we acheive through input control or some other option.
    Here I attached screen shot.Please help me for this

    Hi,
    It is not possible to have Input controll in all tabs that will be set from another .
    But There is one workaround .
    Follow the link below .
    http://davidlai101.com/blog/2013/08/13/web-intelligence-input-control-that-affects-all-tabs/

  • How to Get the values from Dynamic jasp page

    Hi,
    I have a jsp form page wherein i input the data form the user and get these values on the action servlet.
    But now i have added a feature to Add and Delete the Elements using javascript and this creates a dynamic form on the jsp page. I want to Get the values of these all elements at the Action servet.
    Please suggest the solution.
    Thanks,
    JavaQueue

    getParameterMap() returns a Map[1] with all parameters; the parameter name is the key and the value is the value of the parameter in the form of String arrays.
    You have to iterate over the Map and get values as you see fit. Search for a tutorial/ example/ sample for using Maps. I'm sure you'll find loads that will do a better job at explaining.
    [1] http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.html
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    ----------------------------------------------------------------

  • How can i get the values from one JSP to another JSP

    Hi All,
    I am very new to JSP technology, I have one jsp having radio button, i want to accecc the state of this radio button to another JSP page, How can i do this.
    Could anybody help me.
    with Regards
    Suresh

    Try page import <%@ page import ="index.jsp" %> or include <%@include file="index.jsp" %> methods perhaps they might work.

  • How to get the value from one Popup lov column to another popup lov column

    Hi,
    I am new to oracle apex development and having the below issue.
    In my application, there is a tabular form with 15 columns ( c1.. c15).
    I have to populate the value of column C5 based on the selected(from popup lov) value of column C3, tried to use onchange, but didn't help much.
    Any help please.
    Thanks and Regards,

    Oh boy, this is a fun one.
    onchange should work theoretically (in this example, assume that f05 is the target column that should be set and "this" is the source item whose value is to be transferred to f05 on the same row (row 2)):
    onchange=$s('f05_0002',$v(this));
    BUT the catch is of course that needs to be different for every row (can't hardcode the '2'), so you need something to dynamically create the row number component.
    I wrote this for an app I'm working on that uses master-detail forms heavily (I also wrote a lot more code to read the fmap array that is in v4 so that I can reference my cells via their column name and not the numeric position (so "f05 can be determined w/o hard coding), insulating against columns moving around, columns being made display-only etc. but I won't bore you with that here unless you really need to know).
    function getRow(pObj)
    { //Pass in an object reference to a tabular form cell and get back an integer
      //derived from the object ID.
      var vRow=pObj.id.substr(pObj.id.indexOf("_")+1);
      if (isNaN(vRow))
        return (null);
      return (parseInt(vRow,10));
    function formatRow(pRow)
    { //Pass in an integer and it'll be returned as the tabular form cell ID suffix
      //(e.g.: pass in 1 and get back string "_0001").
      //Used in building ID references to tabular form cells.
      if((isThingEmpty(pRow)) || (isNaN(pRow)))
        return(null);
      var vRow=pRow.toString();
      while(vRow.length<4)
        vRow="0"+vRow;
      return("_"+vRow);
    }Therefore:
    onchange=$s('f05_'+formatRow(getRow(this)),$v(this));
    So in essence, pass in "this" which will be a reference to the current item, largely to determine what row we're on. getRow will return 1, 2, 3, etc. formatRow will take that and return 0001, 0002, 0003, etc. Once that is done, it'll concatenate with the f05 and f04 to refer to the correct columns (determining f05, f04, etc. dynamically is another matter if you really need to but I didn't want to complicate this answer too much at once).
    Note: above I also use a isThingEmpty() function that I wrote. It does nothing other than check the item for an empty string, if the item is null, etc. Just do your own evaluation of empty-string, no-value, etc. there.
    It would indeed be nice though if Apex had a better way to delclaratively access the tabular form items though. Despite all the v4 enhancements, tabular forms were not entirely upgraded to the same full functionality of page items.

  • How to get the action-mapping in jsp page in struts

    Hi,
    I want get, in my login.jsp, the name of action mapping that call my
    login.jsp.
    Is possible?
    suppose abc.do called my login.jsp
    now i need to know the name of action-mapping here abc
    Thanks,

    Depending on what you need, I believe Struts 1.3 creates a request attribute called "org.apache.struts.globals.ORIGINAL_URI_KEY". In your case, it looks like this would be set to the string "/abc.do". There should also be a request attribute called "org.apache.struts.action.mapping.instance" that contains an instance of ActionConfig. I think both of those keys are defined by the Globals class.

  • How to get the values of 2 dynamic comboboxes in one jsp to another jsp?

    I have 2 comboboxes and one submit button on my jsp page.I select a value in 1st combobox then the values in the second combobox populated from the database. next i select 2nd combobox and then submit the button.After submit the button call the next jsp page. In that page i want to display the values of two comboboxes. but my problem is , in that page only 2nd combobox value is displayed.1st combobox is displayed as null. plz tell me, how to get the values of two comboboxes at a time?
    Select.jsp:
    <%@ page language="java" import="java.sql.*" %>
    <%!
         Connection con = null;
         Statement  st  = null;
         ResultSet  rs  = null;
         String     sql = null;
         void addItems(javax.servlet.jsp.JspWriter out, String sql)
           try{     
              rs = st.executeQuery(sql);
              while( rs.next() )
                   out.println("<option>" + rs.getString(1) + "</option>");               
         }catch(Exception e)
                   System.out.println(e);
    %>
    <HTML>
    <HEAD>
    <TITLE>JSP WITH  MULTIPLE FORMS</TITLE>
    <script language="javascript">
              function checking()
                        form1.submit();
         </script>
    </HEAD>
         <body>
             <center>
             <b><font size="5" color="#333399">Staff ID:</font></b></center>
                     <FORM NAME="form1" METHOD="POST" ACTION="Select.jsp">
                         <p align=center>
                         Details of Staff :  
                       <SELECT 1 NAME="type" onchange="checking();">
                                    <option> Administrator </option>
                              <option> OfficeAssistent </option>
                              <option> Clerk </option>
                                  </SELECT 1>
                          </p>
    </FORM>
                      <FORM NAME="form2" METHOD="POST" action="welcome1.jsp">
                      <center>
                          <TABLE><TR><TD>Staff ID:</TD>
                                 <TD><SELECT 2 NAME="staff_id">
                    <%    
            String type = request.getParameter("type");
            try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection("jdbc:odbc:java","system","manager");
            catch (ClassNotFoundException ex) {
                   System.out.println(ex);
            catch (SQLException ex)
                System.out.println(ex);
         st  = con.createStatement();
         sql = "select staff_id from "+type+"";
         addItems(out, sql);
    %>
              </SELECT 2>
           </TD>
         </TR>
    </table></center>
    <h2> Details of <%= type + "s" %> </h2>
                         <center><input type=submit value=ok onclick="submit();"></center>
                  </FORM>
         </BODY>
    </HTML>
    welcome1.jsp
    <center><h1>WEL COME</h1></center>
    <%    
            String type = request.getParameter("type");
            String sid = request.getParameter("staff_id");
    %>
    <h2> Details of <%= type + "s" %> </h2>
    <h2> Details of <%= sid %> </h2>

    <SELECT 1 NAME="type" onchange="checking();">
                                    <option value = "0"> Administrator </option>
                              <option value = "1"> OfficeAssistent </option>
                              <option value = "2"> Clerk </option>
                                  </SELECT 1>

  • How we can get the values  from one screen to another screen?

    hi guru's.
         how we can get the values  from one screen to another screen?
              we get values where cusor is placed but in my requirement i want to get to field values from one screen to another screen.
    regards.
      satheesh.

    Just think of dynpros as windows into the global memory of your program... so if you want the value of a field on dynpro 1234 to appear on dynpro 2345, then just pop the value into a global variable (i.e. one defined in your top include), and you will be able to see it in your second dynpro (assuming you make the field formats etc the same on both screens!).

  • How to get the value of a variable defined in javascript in JSP

    how to get the value of a variable defined in javascript in/through JSP????

    In Javascript you can use the DOM to access the input element and set it's value before submitting the form. Then it's value will just be passed.

  • How to get the form reference in .js page from .jsp page

    hi
    i have written one form in jsp page omething like:-
    <html:form action="/shopping" onsubmit="return false;">
    can anybody tell me,how to get the form reference in .js page from .jsp page ,
    i have tried:-
    var formRef = document.forms[0];
    butits not working.
    Thanks.

    Its very simple......y cant u prefer google...Bad
    c this example...
    function submit()
    alert("textbox"+ document.forms[0].name.value);//to get textbox value in js
    document.forms[0].submit();//to submit jsp page using js
    <html:html>
    <html:form action="/shopping" onsubmit="submit()">
    <html:text property=name>
    learn to search in google..
    </html:form>
    </html:html>

  • How to get the values from popup window to mainwindow

    HI all,
       I want to get the details from popup window.
          i have three input fields and one search button in my main window. when i click search button it should display popup window.whenever i click on selected row of the popup window table ,values should be visible in my main window input fields.(normal tables)
       now i am able to display popup window with values.How to get the values from popup window now.
       I can anybody explain me clearly.
    Thanks&Regards
    kranthi

    Hi Kranthi,
    Every webdynpro component has a global controller called the component controller which is visible to all other controllers within the component.So whenever you want to share some data in between 2 different views you can just make it a point to use the component controller's context for the same. For your requirement (within your popups view context) you will have have to copy the component controllers context to your view. You then will have to (programmatically) fill this context with your desired data in this popup view. You can then be able to read this context from whichever view you want. I hope that this would have made it clear for you. Am also giving you an [example|http://****************/Tutorials/WebDynproABAP/Modalbox/page1.htm] which you can go through which would give you a perfect understanding of all this. In this example the user has an input field in the main view. The user enters a customer number & presses on a pushbutton. The corresponding sales orders are then displayed in a popup window for the user. The user can then select any sales order & press on a button in the popup. These values would then get copied to the table in the main view.
    Regards,
    Uday

  • How to get the value assigned in dropdowmlistbox as well as radio button

    Hi Everybody,
       Please help me to find the solution for the following:
       1. How to get the value assigned in dropdowmlistbox?
       2. How to get the value assigned in radio button?
      I am waiting for the answer and reply...
      Thanks & Regards,
      ShanthaKumar.KA.

    The radio button has a name attribute. That name attribute should be the same as the bean property. Then you just need a
    <jsp:setProperty name="mybean" property="*"/>
    and the bean's set method will be called for the value of that radio button.
    so...
    <input type="radio" name="doit"/>
    class MyBean
    public void setDoit( boolean yes )
    //do whatever here
    }

  • How to get the value from a JavaScript and send the same to Java file?

    Hi.
    How to get the value from a JavaScript (this JS is called when an action invoked) and send the value from the JS to a Java file?
    Thanks and regards,
    Leslie V

    Yes, I am trying with web application.
    In the below code, a variable 'message' carries the needed info. I would like to send this 'message' variable with the 'request'.
    How to send this 'message' with and to the 'request'?
    Thanks for the help :-)
    The actual JS code is:
    function productdeselection()
    var i=0;
    var j=0;
    var deselectedproduct = new Array(5);
    var message = "Are you sure to delete Product ";
    mvi=document.forms[0].MVI;
    mei=document.forms[0].MEI;
    lpi=document.forms[0].LPI;
    if(null != mvi)
    ++i;
    if(null != mei )
    ++i;
    if(null != lpi)
    ++i;
    if(null != mvi && mvi.checked)
    deselectedproduct[++j]="MVI?";
    if(null != mei && mei.checked)
    deselectedproduct[++j]="GAP?";
    if(null != lpi && lpi.checked)
    deselectedproduct[++j]="LPI?";
    if( 0!=j)
    if(i!=j)
    for (x=0; x<deselectedproduct.length; x++)
    if(null != deselectedproduct[x])
    message =message+ "-" +deselectedproduct[x];
    alert(message);
    else
    //alert(" You cannot remove all products!");
    return false;
    return true;
    }

  • How to get the value from databank

    Hi,
    How to get the value from databank? and how to set the same value to visual script object?
    thanks,
    ra

    Hi,
    You can use GetDatabankValue(HeaderName, Value) to get the value from databank and SetDataBankValue(HeaderName, Value) to set the value to databank.
    You can refer to the API Reference to see list of associated functions and techniques we can use with related to Data Bank.
    This is the for OFT but if you are using Open Script then you have direct access for getting the databank value but when it comes to setting a value you have to use File operation and write you own methods to do the set operation.
    Thanks
    Edited by: Openscript User 100 on Nov 13, 2009 7:01 AM

  • How to get the values from html:select? tag..?

    i tried with this, but its not working...
    <html:select styleClass="text" name="querydefs" property="shortcut"
                 onchange="retrieveOptions()" styleId="firstBox" indexed="true">
    <html:options collection="advanced.choices" property="shortcut" labelProperty="label" />
    </html:select>
                        <td align="left" class="rowcolor1">
                        <script language="javascript" type="text/javascript">
                              function retrieveOptions(){
                             var sel = document.querydefs.options;
                             var selectedOption = sel[sel.selectedIndex].value;
                             document.write(selectedOption);
                           </script>

    <td align="left" class="rowcolor1">
                        <script language="javascript" type="text/javascript">
                              function retrieveOptions(){
                             var sel = document.querydefs.options;
                             var selectedOption = sel[sel.selectedIndex].value;
                             document.write(selectedOption);
                           </script>This java script is not working at all..its not printing anything in document.write();
    This is code..
    <td class="rowcolor1" width="20%">
    <html:select styleClass="text" name="querydefs" property="shortcut"
                             onchange="retrieveSecondOptions()" styleId="firstBox"
                             indexed="true">
                             <html:options collection="advanced.choices" property="shortcut"
                                  labelProperty="label"  />
                        </html:select>i tried with this also. but no use..i'm not the getting the seleced option...
    function retrieveOptions(){
    firstBox = document.getElementById('firstBox');
                             if(firstBox.selectedIndex==0){
          return;
        selectedOption = firstBox.options[firstBox.selectedIndex].value;
    }actually , how to get the values from <html:select> ...?
    my idea is to know which value is selected from the combo box(<html:select> ) if that value is equal some string i have enable a hyperlink to open a popup window

Maybe you are looking for

  • In idoc to file scenario, if XI system is down where do idocs pile up?

    In idoc to file scenario, if XI system is down where do idocs pile up (get stuck) what tcode can I use to reprocess it?

  • Adobe Media Encoder wont Render from Beginning

    Hi there I am trying to render a After Effects Project but when i try to render in Media Encoder it will only render from 1.47.26sec into my project ot the start, i have tried to adjust the Source range in Encioder as well as make sure the work area

  • How to read a CSV File

    Hi All, I am new to the forum so i dont know if i can post this message in this section or not but i did not find any related section in the menu so i am posting it here. I want to read a .CSV (comma separated file) in a particular location and see i

  • Mail Crash after 10.4.4 - Log

    Hi, I'm using an imap account. After the 10.4.4 update, Mail crashes when I try to open specific Mails .. like the ones from Apple Newsletter and some other HTML Mails. Mail works fine with plain text mails. Any idea what's going on ? Here is my log

  • Seeking a solution for synchronization of sequences in expdp

    Hi all, When i am exporting tablespaces from a live database, first the tables are being exported and then the sequences. and while these sequences are being exported, as this is the live database, the sequences are getting modified because of new in