How to save a value in form jsp?

hi all,
i have a dropdown list in my struts web app,
i am having a form in which a bean is instatiated(bean has 2 properties "name" and "code").
i am using like this in the jsp:
<td><html:select property="item.code">
                         <logic:iterate id="itemType"
                              name="<%=WebConstants.getItemTypeListName()%>">
                              <option value='<bean:write name="ItemType" property="code"/>'><bean:write
                                   name="ItemType" property="name" /></option>                              
                         </logic:iterate>                         
                    </html:select></td>
each "itemType" has "code" and "name".
when the user clicks on the item name on the dropdown item beans "code" is populating.now i need to populate "name" aswell at the sametime using hidden property.
i want to save tha value of name in the jsp to use it later to populate "name" in my form using hidden property?
do anyone have idea how to save the value in jsp?
regards and thanks in advance

Thank you. I execute the program below. I can now retrive the data from the Lt.txt. But the value is limited to 3 digits. For example, the content of my file is 777888.
When I run the program, I only get 777. How can I retrive the whole exact number?               
import java.io.*;
               class Test {     
               public static void main(String args[]) {          
               try {               
               File inputFile = new File("Lt.txt");               
               File outputFile = new File("outagain.txt");                    
               FileReader in = new FileReader("Lt.txt");               
               FileWriter out = new FileWriter(outputFile);               
               char[] tmp = new char[3];               
               int cnt = in.read(tmp);                              
               System.out.print("\nRead: ");               
               for (int i = 0; i < cnt; i++) {                    
               System.out.print(tmp);               }               
               System.out.println(" ");               
               in.close();          }
               catch (IOException ex) {               
               System.out.println("IOException:"+ex.toString());          }     }}

Similar Messages

  • HOW to send a value to another jsp page

    HOW to send a value to another jsp page, like user name in one jsp page to another jsp page

    In the most simplest form...
    // pageA.jsp
    <html>
    <body>
    <form action="pageB.jsp" method="post">
    <b>First Name:</b> <input type="text" name="FNAME" value="Joe">
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
    // pageB.jsp
    <html>
    <body>
    <b>Name:<b> <%=request.getParameter("FNAME")%>
    </body>
    </html>

  • 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

  • How to get the values of form valuess

    Hi All,
    Good Morning,
    i create a page with some form valuesss
    that form values are based on view attributes(vo)
    i did some caluculations and store that values in form value variabless at the time of creating a row in table.
    now i want to open that row in edit mode.
    that time all text fields values are getting and displayed in text fieldss.
    but that record form values are not getting.the form values store the null values.
    how can u get the values of form value variables in the edit mode.
    Thanks

    Hi
    ohh ,ok ,then as u said that u r storing twenty values ,thats y i aksed earlier ,are these form values part of tbale ,or as u said 20 values are there ,for these u r creating 20 form values ???.
    My suggestion would be ,u do four calculation and put all your results in a hashmap ,and keep this hash map in to sesion ,using the following method
    pageContext.putTransactionTransientValue("HashMapName",myHashMap);
    and inside the PFR method when u want to display these values ,u can loop through your hashmap and can display these values.
    like this
    HasMap hm=pageContext.getTransactionTransientValue("HashMapName");
    thanx
    Pratap

  • How to change default value in form

    Hi,
    I want to change the default value in form..how can i do this?
    Fo exa...in purchasing when we go to auto create..in action tab we see create been defaulted whenever we open the form and also there is one more option called add to...so whenever i open this form..i want to see add to there..
    How can we get this?please advise?
    Thanks
    Mahendra

    You can do it using forms personalization.

  • How to save a value in a .txt n retrive back the exact value from the file?

    Well I have a number. Let's say 600. I need to save this value in a .txt file so that I can retrive this value. I tried using the below source code. It can be executed but I'll get num 49 everytime I execute it even though the value in my .txt is 600.
    try {
                   File inputFile = new File("Lt.txt");
                   File outputFile = new File("outagain.txt");
    FileReader in = new FileReader("Lt.txt");
    FileWriter out = new FileWriter(outputFile);
    int c;
              c = in.read();
              in.close();
    System.out.print("\nggggggggg"+c);
    in.close();
                   } catch (IOException ex) {
                   System.out.println("IOException:"+ex.toString());

    Thank you. I execute the program below. I can now retrive the data from the Lt.txt. But the value is limited to 3 digits. For example, the content of my file is 777888.
    When I run the program, I only get 777. How can I retrive the whole exact number?               
    import java.io.*;
                   class Test {     
                   public static void main(String args[]) {          
                   try {               
                   File inputFile = new File("Lt.txt");               
                   File outputFile = new File("outagain.txt");                    
                   FileReader in = new FileReader("Lt.txt");               
                   FileWriter out = new FileWriter(outputFile);               
                   char[] tmp = new char[3];               
                   int cnt = in.read(tmp);                              
                   System.out.print("\nRead: ");               
                   for (int i = 0; i < cnt; i++) {                    
                   System.out.print(tmp);               }               
                   System.out.println(" ");               
                   in.close();          }
                   catch (IOException ex) {               
                   System.out.println("IOException:"+ex.toString());          }     }}

  • How to save the value in Cedit control into a text file bu using measurement studio c++?

    Im using measurement studio c++ to create a application. How to save a randomly generated value which display in the CNumberEdit Control to a text file? how to do the coding part?

    You can use the CNiFile class to write the value out to a file. For example, create a new Measurement Studio C++ project and follow these steps:
    Add a CNiNumEdit to the dialog.
    Add a member variable for the CNiNumEdit called m_numEdit.
    Add a button to the dialog.
    Double-click the button to add a message handler for the button's BN_CLICKED message.
    Add the following code to the button's BN_CLICKED message handler:
    CNiFile file("C:\\Values.log", CFile::modeCreate | CFile::modeWrite | CFile::typeText);
    file << m_numEdit.Value << endl;
    file.Close();
    Run the application, edit the CNiNumEdit's value, and click the button. The value should be written to the Values.log
    file as specified in the code above.
    Hope this helps.
    - Elton

  • How to save controls value in labview

    hi
    i want to know how to save the controls value in PC. means if i assign 5  digital value to a control it should remain there even i restarts my PC.
    Solved!
    Go to Solution.

    This can mean two things. Will the default value always be 5? You could right click the control, select Data Operations, then Make Current Values Default. This can only be done at edit time and the value is saved with the vi. If you know you will always need the same default value then do this. If you need the user to be able to change the default value without editing and saving the vi then see the post by smercurio_fc above.
    =====================
    LabVIEW 2012

  • How to save a value ?

    Hello. I am making a program in Labview....and my problem is for example:at the end of a cicle i need to save the result that has been calculated in the cicle...so i can use it later in other cicle calculations....
    my question is how can i save that value in a variable (or register)  ? 
    thanks
    JOSE 

    Sorry i said cicles instead of loops. I understand that the value is in the wire that conect to other things outside the loop...i just canot save/store it in some 'variable' so i can use it later...i will try a shif register  
    thanks again for your anwsers
    JOSE

  • How can I share values between different jsp pages?

    Hi,
    I'm doing a jsp, bc4j application (JDeveloper 9.0.3), and I need to share some values between different jsp pages. To do this,
    I have used the tag <jsp:usebean.....></jsp:usebean> in this way:
    on pageone.jsp
    <jsp:useBean id="param" scope="session" class="MyPackage.Parameters" ></jsp:useBean>
    on pagetwo.jsp     
    <jsp:useBean id="param" scope="session" class="MyPackage.Parameters" ></jsp:useBean>
    and so on, in order to refer to the same instance of the class "Parameters".
    After deploying, the application works well only if the client is the same pc where the AS resides, otherwise the variables of "Parameters" are null.
    Please, could you help me?
    Thanks
    Nunzio.

    I am seeing an indication on 9.0.3 that static includes are not static, but instead always dynamic. The compiler generates a call to the included page, and doesn't include the content in the calling page as it should.

  • How to save a value in a byte array, retrieve it and display it?

    Hi,
    I am doing a project for my data structures class that involves saving a value (given in String format) in a byte array (our 'memory'). Initially I just tried casting character by character into the byte array and casting back to char[] for retrieval (using .toString() to return what's supposed to be the original string), but this did not work. I tried the .getBytes() method, applying it to the string and then trying to recover it by placing the contents of the 'memory' in a byte array and applying toString(), but that didn't work either. I looked a bit and found this class, CharsetEncoder and CharsetDecoder. I tried to use these but when I try the compiler tells me I cannot instantiate CharsetDecoder because it is an abstract class. At this point I'm at a loss as to what I can do. Is there any way to place a string in a byte array and then recover the string in it's original format? For example, I might save a value in my particular class of "456". But when I try to recover the value from my 'memory' i.e. the byte array, it comes out like [gnue@hnju.... or something similar. I need it to output the original string ("456").
    Below is my code as it is right now, for the methods setValue and getValue.
    Thanks!
    public void setValue(String value) throws InvalidValueException {
         //… stores the given value in the memory area assigned to the variable
              if(this.type.isValidValue(value)){
                   bytes = value.getBytes();
                   int i,j,k;
                   int l=0;//might be wrong?
                   int ad=address-(address%4);
                   mem.readWord(ad);
                   reg=mem.getDataRegister();
                   if((address%4)+bytes.length-1<4){
                        for(i=address%4;i<address%4+bytes.length;i++)
                             reg.setByte(i, bytes[i]);
                        mem.setDataRegister(reg);
                        mem.writeWord(ad);
                   else if((address%4)+bytes.length-1>=4){
                        if(address%4!=0){
                             for(i=address%4;i<4;i++){
                                  reg.setByte(i, bytes);
                                  l++;
                             mem.setDataRegister(reg);
                             mem.writeWord(ad);
                             ad+=mem.WORDSIZE;
                        while(ad<address+bytes.length-(address+bytes.length)%4){
                             for(j=0;j<4;j++){
                                  reg.setByte(j, bytes[j+l]);
                                  l++;
                             mem.setDataRegister(reg);
                             mem.writeWord(ad);
                             ad+=mem.WORDSIZE;
                        if((address+bytes.length)%4!=0){
                             mem.readWord(ad);
                             reg=mem.getDataRegister();
                             for(k=0;k<(address+bytes.length)%4;k++){
                                  reg.setByte(k, bytes[k+l]);
                                  l++;
                             mem.setDataRegister(reg);
                             mem.writeWord(ad);
                   else
                        throw new InvalidValueException("The value passed is not valid.");
         /** Gets the current value of the variable.
         @return current value converted to String
         public String getValue() {
              //… returns the current value stored in the corresponding memory area
              //… value is converted to String
              bytes=new byte[this.getType().getSize()];
              int i,j,k;
              int l=0;//might be wrong?
              int ad=address-(address%4);
              mem.readWord(ad);
              reg=mem.getDataRegister();
              if((address%4)+bytes.length-1<4){
                   for(i=address%4;i<address%4+bytes.length;i++)
                        bytes[i] = reg.readByte(i);
              else if((address%4)+bytes.length-1>=4){
                   if(address%4!=0){
                        for(i=address%4;i<4;i++){
                             bytes[i] = reg.readByte(i);
                             l++;
                        ad+=mem.WORDSIZE;
                   mem.readWord(ad);
                   reg=mem.getDataRegister();
                   while(ad<address+bytes.length-(address+bytes.length)%4){
                        for(j=0;j<4;j++){
                             bytes[j+l] = reg.readByte(j);
                             l++;
                        ad+=mem.WORDSIZE;
                   if((address+bytes.length)%4!=0){
                        mem.readWord(ad);
                        reg=mem.getDataRegister();
                        for(k=0;k<(address+bytes.length)%4;k++){
                             bytes[k+l] = reg.readByte(k);
                             l++;
              return bytes.toString();

    You can certainly put it into a byte array and then construct a new String from that byte array. Just calling toString doesn't mean you'll automatically get a meaningful string out of it. Arrays do not override the toString method, so the use the one inherited from object.
    Look at String's constructors.

  • How to save your position in a JSP page on submit

    I am building a web application based on JSP pages and servlets. One of the JSP pages is larger than the screen, so i have to scroll down. On the lower part of the page, i have a control that submits a form to a servlet that performs some logic and then returns to the same JSP page. When the JSP page is redisplayed, it is positioned at its top position again. I would like to save my positioning on the page and return to the exact same scroll position. How is this easiest done?

    Just use an onclick or onsubmit event to get the current scroll position using JS and send it along the request to the server side and let it set the value in an onload event of the page which comes with the response.
    I am not going to give you JS+DOM codes here. Just learn it and if necessary ask help at the appropriate forum. There are JS and DOM tutorials at w3schools.com and there are clientside development forums at webdeveloper.com and dynamicdrive.com.

  • How to save input values in a dialog?

    Hi there,
    I've got the following dialog with an EditText in it:
    var win, form; 
    form = "dialog {  \ 
        orientation: 'column', \ 
        alignChildren: ['fill','top'], \ 
        preferredSize: [305, 300], \ 
        text: 'Form', \ 
        margins: 15, \ 
        input_group: Panel { \ 
            text: 'Number', \ 
            orientation: 'row', \ 
            alignChildren: ['fill','top'], \ 
            margins: 15, \ 
            input_obj: EditText { \ 
                text: '' \ 
    win = new Window(form);
    Once the dialog is closed, I want it to save the EditText values, so when I open it again it already has it filled.
    How do I create this behaviour?
    Thanks!

    Alternatively, you could use customOptions:
    var win, form;   
    form = "dialog {  \
        orientation: 'column', \
        alignChildren: ['fill','top'], \
        preferredSize: [305, 300], \
        text: 'Form', \
        margins: 15, \
        input_group: Panel { \
            text: 'Number', \
            orientation: 'row', \
            alignChildren: ['fill','top'], \
            margins: 15, \
            input_obj: EditText { \
                text: '' \
        btn: Button { \
            text: 'Click me' \
    win = new Window(form);
    win.btn.onClick = function () {
        var desc = new ActionDescriptor();
        desc.putString(0, win.input_group.input_obj.text);
        app.putCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8", desc, true);
        win.close();
    try {
        var desc = app.getCustomOptions("77F66FF5-EFAD-49B7-AFE3-8A1403376CB8");
        win.input_group.input_obj.text = desc.getString(0);
    } catch (e) {
        win.input_group.input_obj.text = "predefined value";
    win.show();
    Cheers,
    Davide Barranca
    www.davidebarranca.com
    www.cs-extensions.com

  • How to convert text values acceses from jsp page into an xml file?

    /* this is the jsp page which i want to convert it into an xml file
    please help me , i thank in advance*/
    <html>
    <head>
    <title> xml test</title>
    </head>
    <body>
    <form action="testxml2.jsp" method = post>
    <ul>
    <li>
    <ul>NAME:
    <br>
    <li>First Name:<INPUT NAME="firstName" TYPE=text SIZE=20><br>
    <li>Middle Name:<INPUT NAME="middlename" TYPE=text SIZE=20><br>
    <li>Last Name:<INPUT NAME="lastname" TYPE=text SIZE=20><br>
    <li>t Name:<INPUT NAME="tname" TYPE=text SIZE=20><br>
    </ul>
    <br>
    <ul>Role:</b><p><input type="radio" name="role" value="buyer">Buyer<p>
              <input type="radio" name="role" value="seller">Seller<p>
              <input type="radio" name="role" value="thirdparty">Third Party<p>
    </ul>
    <ul>
    Qualification:<br>
    <li>Highest Degree:<INPUT NAME="degree" TYPE=text SIZE=20><br>
    <li>Percentage: <INPUT NAME="percentage" TYPE=text SIZE=20><br>
    </ul>
    <ul> Adress:
    <li> streetName:<INPUT NAME="street" TYPE=text SIZE=20><br>
    <li>cityName:<INPUT NAME="city" TYPE=text SIZE=20><br>
    <li>StateName:<INPUT NAME="state" TYPE=text SIZE=20><br>
    </ul>
    </ul>
    <b>
    <INPUT TYPE=SUBMIT VALUE="ENTER" >
    </body>
    </html>

    hi there,
    In the MCV there is a part about struts, this is a descent way to do this.
    how to do it:
    create an actionform containing all the properties of the page.
    then when you submit your form use an method in the actionforms (that you have written) that makes sets your data in a xml file.
    this works very quickely and i use it in production...
    you can choose if you want the xml to generaded hard coded or via a parser.
    greetings

  • How to get the values from form calls in user exit?

    Hi all,
    I am not getting a specific value readily in an user exit.
    ?Can any one tell me how to find what are the fields,tables available in various form calls(visible while debugging) in an user exit.
    For example sapxkl is one ofthe callls...(sapxkl)<table>[] will hold some data.how to find what r the values available for <table>.
    Thanks.
    Edited by: sanjay_ask on Apr 16, 2010 10:43 PM

    HI ,
    Use this line of code
      field-symbols: <l_fs> type any.
      data: l_value type char20.
    Get Plant
      l_value =  '(SAPLCEI0)GV_WERKS'. " Here give the program name and variable name
      assign (l_value) to <l_fs>.
      v_werks = <l_fs>.         " Instead of V_werks use you internal table
    Thanks
    Subhankar

Maybe you are looking for

  • Security settings on this doc prevent signing

    I created a form with interactive fields. 1) in security settings it says "no security" 2) under Advanced, I "enabled usage rights in Adobe Reader" 3) opening the pdf in Reader X I clicked on the "Sign" button at the top 4) I get the "The security se

  • Help Quicktime Pro will not Activate

    I purchased the full version of Quicktime Pro 7 on December 28th last year, and I wish to reinstall it on a fresh new iMac, but every-time I enter the activation codes and my name (which are exactly as Apple supplied them in the original sale receipt

  • Oracle VM Server 2.2.2

    Hi Experts, I have installed Oracle VM server 2.2.2 but there is no directories under /OVS i was trying to install Oracle VM Templates for Oracle RAC in the readme they have mentioned extract the files in the seed_pool directory but there is no seed_

  • BW Statistics Queries & Dashboards

    Hello All, I have a required to build a BW Statistics Dashboard (cockpit). I already activated the BW Statistics and daily deltas are loading to the cubes. Now i am in the process of creating BW Dashbords. My question is what Reports/Queries/Charts a

  • How to re-install PSE7? [was: lost disc]

    Hi, I can't find my PS Elements 7 disc (yes, I know it's old but good enough for me) and tried unsuccessfully to use my serial number to activate a downloaded copy.  Is there a way around this without having to pay for another copy?