Help with getting values from request. Very Strange!!

Hello,
My very strange problem is the following.
I have created three dynamic list boxes. When the user select
the first list box, the second becomes populated with stuff
from a database. The third becomes populated when the second
is selected. Now, I have used hidden values in order for
me to get the selected value from the first listbox. The
following code is my first listbox:
<SELECT NAME="resources" onChange="document.hiddenform.hiddenObject.value = this.option [this.selectedIndex].value; document.hiddenform.submit();">
<OPTION VALUE =""> Resource</OPTION>
<OPTION VALUE ="soil"> Soil </OPTION>
<OPTION VALUE ="water"> Water </OPTION>
<OPTION VALUE ="air"> Air </OPTION>
<OPTION VALUE ="plants"> Plants </OPTION>
<OPTION VALUE ="animals"> Animals </OPTION>
</SELECT>
I use the getRequest method to get the value of hiddenObject.
At this time I am able to get the value of hiddenObject to populate
the second list box.
But, when the user selects an item from the second list box
and the second form is also submitted,
I lose the value of hiddenObject. Why is this??
The code to populate my second listbox is the following:
<SELECT NAME ="res_categories" onChange="document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value; document.hiddenform2.submit(); ">
<OPTION VALUE ="" SELECTED> Category</OPTION>
Here I access a result set to populate the list box.
Please help!!

Form parameters are request-scoped, hence the request.getParameter("hiddenObject"); call after the submission of the second form returns a null value because the hiddenObject parameter does not exist within the second request.
A solution would be to add a hiddenObject field to your second form and alter the onChange event for res_categories to read
document.hiddenform2.hiddenObject.value=document.1stvisibleformname.resources.option[document.1stvisibleformname.resources.selectedIndex].value;
document.hiddenform2.hiddenObject2.value = this.options[this.selectedIndex].value;
document.hiddenform2.submit();You will then come across a similar problem with your third drop-down if indeed you need to resubmit the form...
A far better approach would be to create a session scoped bean, and a servlet to handle these requests. Then when the servlet is called, it would set the value of the bean property, thus making it available for this request, and all subsequent requests within the current session. This approach would eliminate the need for the clunky javascript, making your application far more stable.

Similar Messages

  • Help: cant get values from a resultset

    i have a class that contains all my MySQL statement and i am trying to use the results found from one of my select statements to pass on into another class which displays the results in a gui form. Here is my query:
    public void profile(String user)
            try
                 Class.forName(driver);
                 Connection con = DriverManager.getConnection( url,db_user, db_pass);
                 String username, name, email, dob, bio, gender, homepage, number;
                 //find username and select all details
                 String find = "SELECT Username, Full_name, Email, dob, Biography, Gender, Homepage, Contact_number FROM users WHERE Username = ? ";
                 PreparedStatement ps1 = con.prepareStatement(find);
                 ps1.setString(1, user);
                ResultSet rs = ps1.executeQuery();
                while(rs.next())
                    //retreive information from the server
                    username = rs.getString(1);
                    name  = rs.getString(2);
                    email  = rs.getString(3);
                    dob = rs.getString(4);
                    bio = rs.getString(5);
                    gender = rs.getString(6);
                    homepage = rs.getString(7);
                    number = rs.getString(8);
                    User_Profile profile = new User_Profile(username, name, email, dob, bio, gender, homepage, number);
                    JOptionPane.showMessageDialog(null, username + bio + email, null, JOptionPane.ERROR_MESSAGE);
                  con.close();
            catch( Exception e )
                     e.printStackTrace();
                     JOptionPane.showMessageDialog(null, "error," + e.getMessage(), null, JOptionPane.ERROR_MESSAGE);
        }As you can see, i am trying to pass on the variables username, name, etc to a new instance of my user_profile class but it doesnt for some reason. i dont get any comple errors so thats ok. i created messege dialog box from within the while statement above to see if a value is stored, and yes their is a value stored in my variables
    below is the user profile class which shows my constructor that suppose to get the values from the query class in this code entered above       User_Profile profile = new User_Profile(username, name, email, dob, bio, gender, homepage, number);
        protected String username;
        protected String FullName;
        protected String Email;
        protected String DOB;
        protected String Biography;
        protected String Gender;
        protected String Homepage;
        protected String Con_Number;
        protected String crnt_user;
    public User_Profile(String user, String name, String email, String dob,
                                String bio, String gender, String homepage, String number)
            initComponents();
            addWindowListener( this );
            //get values from sql query and store them here.
            this.username = user;
            this.FullName = name;
            this.Email = email;
            this.DOB = dob;
            this.Biography = bio;
            this.Gender = gender;
            this.Homepage = homepage;
            this.Con_Number = number;
         }the code below is used to display one of the values received from the query class, in this case returns null..
    txt_name.setText(username)

    Does the user String match the database String
    exactly?
    Some databases are case sensative.Sorry posted before done.
    Also, ensure you do not have trailing spaces in one or both. I remember Oracle had this problem a few years ago using the Type 4 driver but not through ODBC.

  • Help with getting links from HTML page

    Hello all. I found the sun tutorial for getting HREF values from a tags in an HTML document at <http://java.sun.com/developer/TechTips/1999/tt0923.html>. My question now is how would a person add the ability to get the text of the link to this code?
    For example:
    Provided the HTML code:<a href="link.html">example</a>Returned is: href=link.html text=example

    I think the TechTip you've linked too is quite old (1999). I would write a simple SAXParser that uses TagSoup (http://www.ccil.org/~cowan/XML/tagsoup/) as its input source. In your handler, simply set a flag and reset a StringBuffer to collect the contents of any <a>...</a> element. Simplified:
        public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
            if ("a".equals(localName)) {
                currentHref = attributes.getValue("href");
                if (currentHref != null && currentHref.length() > 0) {
                    inLink = true;
                    //reset the string buffer
                    buffer.setLength(0);
        public void characters(char[] ch, int start, int length) throws SAXException {
            if (inLink) buf.append(ch, start, length);
        public void endElement(String uri, String localName, String qName) throws SAXException {
            if ("a".equals(localName) && inLink) {
                inLink = false;
                //add link to the stack
                links.add(new Link(currentHref, buffer.toString()));
        }Completely untested, of course... .Good luck...

  • Need Help to get value from MessageChoice and pass it to another MesgChoice

    Hi All,
    How to get a value from a messageChoice1 in CO into a variable. Once the messageChoice1 is selected i need to pass this variable into a VO whereClause and the page get refreshed, so that another messageChoice2 in the same page will have the values based on the messageChoice1 value.
    Kindly give me your suggestions.
    Thanks and Regards,
    Myvizhi

    I think you want to do a nested loop within each Item in the data provider, to pull out each child's (series1, series2, etc). "label" attribute.

  • Help on getting value from string

    Hello can someone please help me with my code?
    I would like to know how to get a value in a string as an integer type
    This is what I have so far
    String x = "12345";
    for(int f=0; f<5; f++){
    int c = stringDigits.charAt(f);     
    sum += c;                
    However the sum does not turn out to be 1+2+3+4+5 = 15 because the value of c will always turn out to be 48 more than it is supposed to be
    for example when f = 1 then c would = 49
    f = 2 then c would = 51
    Thank you very much for your help

    int i = Integer.parseInt(x);
    Will convert the String to an integer.The original poster was looking for a way to convert a single digit in a string to its numeric value, not to convert the whole string to an integer.
    I forgot to mention that this is contained in the
    java.text package, so you will need to
    import java.text.*;Integer is in the java.lang package, so no import is necessary.

  • Please help with retrieving values from object stored in a vector

    hi..
    i have a class Magazine with 2 varibles name and price like this
    class magazine
    String name;
    int price;
    i have created a vector called selectedmag which stores objects of Magazine class... now each object will contain the name and price rite...
    i want to print the values stored in vector ie i want to print the vector elements...like
    Name: Mag1
    Price: 10
    which wil be present in object1...
    and then
    Name: Mag2
    Price:15
    which wil be present in object2...
    and so on...
    plz help...
    if i give selectedmag.elementAt(position) i am not able to get the above output...plz help me.....
    thanks,
    Akshatha

    hi,
    Yes i have used a for loop to print the values... it goes like this
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    class Magazine
         String title;
         int price;
    public class sessiontrack1 extends HttpServlet
         public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
              res.setContentType("text/html");
              PrintWriter out=res.getWriter();
              HttpSession session=req.getSession(true);
    // This is my vector          
    Vector myshoppingcart=(Vector)session.getAttribute("ShoppingCart");
              if(myshoppingcart==null)
                   myshoppingcart=new Vector();
              Magazine selectedMag=new Magazine();
              selectedMag.title=req.getParameter("Title");
              selectedMag.price=Integer.parseInt(req.getParameter("Price"));
    //Putting Magazine object into the vector myshoppingcart
              myshoppingcart.addElement(selectedMag);
              session.setAttribute("ShoppingCart",myshoppingcart);
              out.println("<html><body>U have selected these magazines");
              out.println("<br>");
         //Enumeration vEnum=myshoppincart.elements();
    //here a am trying to print output the values
              for(int i=0;i<myshoppingcart.size();i++)
    out.println("Name:" + (Magazine)myshoppingcart.elementAt(i));
                   out.println("<br>");
    out.println("Price:" + (Magazine)myshoppingcart.elementAt(i));
                   out.println("<br>");
              out.println("</body></html>");
    this is a servlet program.... plz suggest me how to print the values... in the following format
    Name: Book1
    price: Rs 10
    Name:Book2
    price:Rs 15
    Akshatha

  • Help with Reading values from static table in a .pdf file

    Hi guys,
    Pls try to clear this doubt of mine.
    I basically have 2 files. Both are .pdf extension and they have tables in them. I need to compare certain values in one file with the corresponding values in the other table in the second file.
    I need to do this programatically in c# . net
    I have tried using packages like pdfbox and stuff which convert the pdf file into text. But cant I get the table as an object or something using which I can access the required rows and columns?
    Also, these tables are static information. They are not a part of a form or anything like that.
    Please help me with this.
    Thanks.

    The document is corrupt. Try a backup.

  • Need help with getting variable from static

    Hello,
    What I am building is an application that prompts for username/password before it shows the main screen. Once they have successfully logged in, I need to assign the username that they used, in order to use it for a button event if the make any updates.
    Here is the code that I have tried to use.
    public String username;
    ///This set's the public variable username
    public void setUserName(String UserName){
    username = UserName;
    /////////////////Here is where they login, and assign the name to setUsername
    public static void main(String args[]) throws SQLException {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    JFrame frame = new JFrame();
    JTextField userName = new JTextField();
    JTextField passWord = new JTextField();
    Object[] options = {"OK","CANCEL"};
    Object[] msg = {"UserName:", userName, "Password:", passWord};
    final JOptionPane op = new JOptionPane(msg, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION){};
    JDialog dialog = op.createDialog(frame, "Please Login");
    dialog.show();
    int result = JOptionPane.OK_OPTION;
    try {
    result = ((Integer)op.getValue()).intValue();
    }catch(Exception uninitializedValue){}
    if(result == JOptionPane.OK_OPTION) {
    String userID = userName.getText();
    String passID = passWord.getText();
    Main myMain = new Main();
    myMain.setUserName(userID);
    if(!userID.equals("") && !passID.equals("")) {
    new Main().setVisible(true);
    }else {
    // user cancelled
    ////here is the button event that also will need the username
    private void selButtonActionPerformed(java.awt.event.ActionEvent evt) {
    Connection conn = null;
    Statement stmt3 = null;
    Statement stmt4 = null;
    ResultSet rset3 = null;
    ResultSet rset4 = null;
    String usernum = null;
    String xemu = null;
    String loc = null;
    String ustat = null;
    String manager = null;
    String dept = null;
    String Add = "Add";
    String Update = "Update";
    String groupID = "9999";
    Vector columnNames = new Vector();
    Vector data = new Vector();
    String Manager_info[] = {"managerindex", "managers", "managername"};
    String Account_info[] = {"acctypeindex", "acctype", "acctypedesc"};
    String Group_info[] = {"groupnum", "groups", "groupcode"};
    String System_info[] = {"systemindex", "systems", "systemname"};
    String Dept_info[] = {"departindex", "departments", "departname"};
    String Xemu_info[] = {"xemuindex", "xemulator", "xemudesc"};
    String Location_info[] = {"locindex", "location", "locdesc"};
    String Ustatus_info[] = {"ustatusindex", "userstatus", "ustatusdesc"};
    Date myDate = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
    String today = formatter.format(myDate);
    System.out.println(username);
    I am trying to set the public username variable to what the person enters, however since I am creating a seperate instance of it, I don't believe it will work. Any help would be very much appreciated.
    Thanks.
    Josh

    I am developing in Netbeans. If I try to remove the static keyword from main(), netbeans canno't find a main to run. I have created the User class.
    Here is the main again to show what I have done.
    public static void main(String args[]) throws SQLException {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    User user = new User();
    JFrame frame = new JFrame();
    JTextField userName = new JTextField();
    JTextField passWord = new JTextField();
    Object[] options = {"OK","CANCEL"};
    Object[] msg = {"UserName:", userName, "Password:", passWord};
    final JOptionPane op = new JOptionPane(msg, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION){};
    JDialog dialog = op.createDialog(frame, "Please Login");
    dialog.show();
    int result = JOptionPane.OK_OPTION;
    try {
    result = ((Integer)op.getValue()).intValue();
    }catch(Exception uninitializedValue){}
    if(result == JOptionPane.OK_OPTION) {
    String userID = userName.getText();
    String passID = passWord.getText();
    user.setName(userID);
    user.setPassword(passID);
    if(!userID.equals("") && !passID.equals("")) {
    //Auth.setUserName(userID);
    //Auth.setPassword(passID);
    new Main().setVisible(true);
    }else {
    // user cancelled
    This set's the variables
    Here is the beginning of the evt that I am using to try and get the data.
    private void selButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
    Connection conn = null;
    Statement stmt3 = null;
    Statement stmt4 = null;
    ResultSet rset3 = null;
    ResultSet rset4 = null;
    String usernum = null;
    String xemu = null;
    String loc = null;
    String ustat = null;
    String manager = null;
    String dept = null;
    String Add = "Add";
    String Update = "Update";
    String groupID = "9999";
    Vector columnNames = new Vector();
    Vector data = new Vector();
    User user = new User();
    String User = user.getName();
    System.out.println(User);
    String Manager_info[] = {"managerindex", "managers", "managername"};
    String Account_info[] = {"acctypeindex", "acctype", "acctypedesc"};
    String Group_info[] = {"groupnum", "groups", "groupcode"};
    String System_info[] = {"systemindex", "systems", "systemname"};
    String Dept_info[] = {"departindex", "departments", "departname"};
    String Xemu_info[] = {"xemuindex", "xemulator", "xemudesc"};
    String Location_info[] = {"locindex", "location", "locdesc"};
    String Ustatus_info[] = {"ustatusindex", "userstatus", "ustatusdesc"};
    Date myDate = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yy");
    String today = formatter.format(myDate);
    String [] str = {
    "EmpID", "Account", "System", "Type", "Status", "UserID", "Group"
    This gives me a null on the println, how can I get the data that was entered in main()?
    Thanks,
    Josh

  • A little help with getting varaibles from another class

    hey,
    so i have these two classes and they both are GUI's. the first main class is called GUI (very original) and he second is called adder. so when i click a button on GUI it creates and shows the adder GUI wich gets user input, when the user clicks the done button on the adder gui it does this this:
          * method to dispose of the gui without deleting the object
         public void close()
             addWindow.dispose();
          * method for when the done button is clicked
         private void buttonClicked()
         personName = ename.getText();
            personPin = epin.getText();
            personAddress = address.getText();
            close();
        }then we go to the GUI class and do this:
    public void addPart2()
            lm.addElement(adder.personName + "-" + adder.personID + "-" + adder.personAddress + "-" + adder.personPin );
        }(all varibless are public by the way), so when i go and have a method directly call adderPart2 right after the adder gui is closed it comes up with all variables bieng null, but if i go in and manualy call the method without doing anything else it works, can anyone explainthis and/or hellp me?

    so does anyone have a solution for this problem or at least know what is happening?
    Thanks a-bundle,
    Mike M

  • Help with getting input from the console

    Hey Experts , wish you are good ? .... i have a problem and wish you figure it out for me , well tell me how can store the input values in a text file and pass the file from the command line ? , i have compiled the program so well , but i could not using text file , thats the code :
    import java.util.Scanner ;
    class TestScanner {
    public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    System.out.print("Enter an interger : ");
    int intValue = scanner.nextInt();
    System.out.println(" You entered an interger " + intValue);
    System.out.print("Enter a double value : ");
    double doubleValue = scanner.nextDouble();
    System.out.println("You entered a double value " + doubleValue);
    System.out.print("Enter a string without space: ");
    String string = scanner.next();
    System.out.println("You entered the string " + string);
    }and i created a file with value like that :
    file name is input
    5
    23.55
    Java
    true
    i just want to know the correct order to compile it .
    thanks in advance

    The Java Tutorials: [_Basic I/O_|http://java.sun.com/docs/books/tutorial/essential/io/index.html]
    db

  • Get value from Direct Database Request

    Hi Experts,
    I have report based on Direct Database Request which returns one row. I have to use value from this report in other one.
    So, I have to get value from query and set into some variable but I don't know there is any way to do it.
    Thanks in advance for any suggestion
    Regards,
    Esk

    Thank you for your reply, but I don't want to use variable in Direct Database Request in clausal 'WHERE' or 'IN'.
    I want value which returns query. For example if my Direct Database Request is : 'Select ID from table1', then
    I wand this 'ID' in variable to use it in other report.
    regards
    Esk
    Edited by: Eskarina on 21-may-2012 2:16

  • Getting values from application context

    I want to set an input box with the value from the jsp getRemoteHost() in jsf page..
    In my page i have this
    <h:inputText value="#{sok.Searchstring}">...
    where the reference sok is a java bean
    public class sok
         private String Searchstring;
         public sok()
              // I want to set the Searchstring = getRemoteHost()
         public String getSearchstring()
            return this.sokVerdi;
        public void setSearchstring(String data)
            this.sokVerdi = data;
    }How can this be done? Should I avoid using http request.. couldn't I get it from the application context, and how do I do that?? I'am kinda empty on ideas to solve this very issue.

    I getting the getRemoteHost to work perfectly.. and as for getParameter() too.. but when I try doing getRemoteUser(), it gives me null.. I also did getRemoteUser() in the jsf file, and there I do get the right output..
    How come? Why do I not get the correct value from the java bean?
    public sok()
              ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
              HttpServletRequest httpServletRequest = (HttpServletRequest)externalContext.getRequest();
              sokVerdi = "h: " + httpServletRequest.getRemoteUser();
              //sokVerdi = "g: " + httpServletRequest.getParameter("fardin");
                   //sokVerdi = "g: " + httpServletRequest.getRemoteHost();
         }

  • Getting values from a datagrid to an ArrayCollection

    Hi, I have a drag and dropable datagrid. I fill it with rows of data from another datagrid. Finally, my application demands savings the data from the datagrid into an array collection along with the index of each row. How do i get values from a datagrid into an arrayCollection variable? Please help me..!

    Whatever is dropped into the DataGrid automatically goes into its dataProvider property, typically an ArrayCollection. Just access the data grid's dataProvider property to see the values.

  • LoaderInfo get values from EMBED and OBject Tag (not FlashVars)

    hi
    i try get values from object and embed tags like bgColor and
    allowFullScreen
    but i cant find how i can it
    loaderInfo.parameters return only flashVars
    if some body know it please help
    thank you
    Sonettic Cinema
    Project

    <forward name="success" path="/jsp/success.jsp" redirect="true" />
    but when success.jsp page gets called its not displaying the username and usertype values on page.The request has been redirected to success.jsp(*redirect="true"*) and hence the attributes stored in request object will not be available in success.jsp. Use Session to store login user information instead.

  • Need help with NULL values in Crosstables

    Hello everybody,
    I need some help with NULL values and crosstables. My issue is the following:
    I have a query (BW - MDX-Query) that gives me turnover measures for each month. In Crystal Reports I choose crosstable to display this whereby I put all month in columns and all turnover-measures in rows. Each month that has a value (measures are not empty) is chown in the crosstables rows. So far so good. The problem occures when there are month that actually have no values (measures are empty). In that case these months are not chown in columns. But I need CR to display these columns and show the value 0. How can I do that?

    Hi Frank,
    Cross tab shows the data based on your column and these column fields are grouped and based on the group it will show your summaries. 
    If there is no data for any of your group it will not display that group.  In this case you will have to create a standard report which should look like cross tab and to get zero values you need to write formulas .
    Example if you want to display Moth wise sales :
    if Month() = 01 Then
    sum() else 0
    Now this formula will check if your month is Jan, then it will sum up the values else it will display zero value. 
    This is possible only through standard report not with Cross Tab.
    Thanks,
    Sastry

Maybe you are looking for

  • What is Transfer posting

    What is Transfer Posting? How it is done? Suppose if i want to transfer a line item from one GL account to another GL account how can i do this? How can i post this following entry in SAP Salaries Account Dr.           To Salaries Payable Account (de

  • Updating the reason of rejection for line item in sales order

    Hi I am updating the reason of rejection field (ABGRU) using the function module VERKBELEG_WRITE_DOCUMENT. there is no error that is thrown but the field is also not getting updated. I have populated the VBAP old and new structure. where the differen

  • DB view in Pub schema

    If I create a view in db of Pub Schema to display some data related to some products do I need to have the asset version, workspace id et al. related columns in the view as well ?

  • Database security with PUBLIC EXECUTE privileges for Application Express

    I recently tried installing APEX into an existing database containing a data warehouse. Security on this database is quite controlled and PUBLIC EXECUTE to SYS owned objects had been removed. Ie there was no PUBLIC EXECUTE on: DBMS_LOB UTL_HTTP UTL_F

  • HT1386 get itunes music library onto iPhone

    My iPhone app purchases are syncing fine to my laptop, but I can't get my laptop's music library in iTunes to sync onto the iPhone.  Help?