html:select and html:options simple question  - please help

Hi Friends,
I am having a problem, please help me .I want to run a query and display all the lastnames of all the users in my database.Here are my files:
UserForm.java
public class UserForm extends ActionForm{
     private name firstName;
     private name lastName;
     //all getter and setters
viewuser.jsp
<html:select property="lastName">
    <html:options collection="users" property="lastName" labelProperty="lastName" />
</html:select>
and my Java Utility class method
public ArrayList getusers() throws Exception {
         ArrayList aList = new ArrayList();     
          Connection con = ConnectionUtil.getConnection();
          PreparedStatement stmt = null;
          try {
               stmt = con.prepareStatement("select last_name from USERS);     
               ResultSet rs = stmt.executeQuery();
                  if (rs.next()) {
                      aList.add(rs.getString(1));
                  }else {
                       return null;
                  rs.close();
                  return aList;
          } catch (SQLException e) {
               e.printStackTrace();
               throw new ServiceProcessingException(e.getMessage());
          } finally {
               ConnectionUtil.closeStatement(stmt);
               ConnectionUtil.closeConnection(con);
     }My problem is what i need to do in my Action class,so that it sets the "users" variable
properly and i would be able to read that variable in my jsp and display the lastname
of all the users.I am tryin this but failing badly:
public class UserAction extends Action{
  ArrayList userssList = Utility_class_obj.getUsers();
  request.getSession().getServletContext().setAttribute("users", usersList);Please Please help,I would really appreciate your help.
Thanks

Thanks a lot friend...this time i made it work my style,next time i will use tha mehod.But I think I am not doing it the right way,please correct me:
This is the method in my utility class where i run the query and I doubt I am not doing it right here:
PreparedStatement stmt = null;
ViewForm vForm = null;
try {
stmt = con.prepareStatement("SELECT LAST_NAME FROM   USERS_ADD");     \
ResultSet rs = stmt.executeQuery();          
while(rs.next()) {
       vForm = new ViewForm(rs.getString(1));          
      aList.add(vForm);          
   rs.close();
   return aList;          }
}And I made this constructor in my viewForm class:
public ViewForm(String lastName){          this.setLastName(lastName);     }I do this in my Action class then:
ArrayList pList = csDAO.getUsers();  
     if(pList  != null){         
     request.getSession().getServletContext().setAttribute("plist", pList);      
}And finally this in my jsp:
    <html:select property="lastName"> 
    <html: options collection="plist" property="lastName" labelProperty="lastName" /> And it works,but i don't think I can keep adding constructors to my form class like that,and moreoever if I want to search by first name ,there would be a conflict between 2 constructors,so can someone please tell me the right way to do this.
Thanks
Mick

Similar Messages

  • A very simple question, please help.

    How would I output/print out a string in color rather then the standard black?
    If anyone can help me or point me in the right direction would be greatly appreciated.
    For example for extra clarification, if I want to print out a string "Hello World", how can I print it out in different colors such as in blue or red.
    Output to a JApplet ( TextArea)
    Thanks!
    Edited by: ff4930 on Nov 30, 2007 9:18 AM

    You can change the colour of all the text in a JTextArea by setting its foreground property:
    yourComponent.setForeground.setColor(Color.RED);If you just want have multiple colors in one JTextArea, that's not possible. You will have to use a more advanced component, like JEditorPane or JTextPane:
    http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
    In basic cases, if the text doesn't have to be editable by the user, you can use a JLabel and pass it simple html:
    String text = "<html><font color='red'>red text</font> " +
    "<font color='green'>green text</font> " +
    "<font color='blue'>blue text</font></html>";
    yourLabel.setText(text);

  • A simple question please help.

    Hi
    I have 2 textfields and a button. I want to input a number( diameter) in the first textfield  ( inputField) and by clicking on the button (myButton), I want to get the result (circonference) in the second textfield ( inputField1). diameter*3.14. I know it is a simple question, but it comes from a very simple mind. So have mercy on me.
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    import flash.events.MouseEvent;
    var inputField:TextField = new TextField();
    var myFormat:TextFormat = new TextFormat();
    myFormat.size = 44;
    inputField.defaultTextFormat = myFormat;
    inputField.restrict = "0-9";
    inputField.maxChars = 6;
    inputField.multiline = false;
    inputField.textColor = 0x000000;
    inputField.border = true;
    inputField.width = 150;
    inputField.height = 50;
    inputField.x = 75;
    inputField.y = 50;
    inputField.borderColor = 0xFF0000;
    inputField.type = "input";
    addChild(inputField);
    var inputField1:TextField = new TextField();
    var myFormat1:TextFormat = new TextFormat();
    myFormat1.size = 44;
    inputField1.defaultTextFormat = myFormat;
    inputField1.maxChars = 1;
    inputField1.multiline = false;
    inputField1.textColor = 0x000000;
    inputField1.border = true;
    inputField1.width = 150;
    inputField1.height = 50;
    inputField1.x = 275;
    inputField1.y = 50;
    inputField1.borderColor = 0xFF0000;
    addChild(inputField1);
    myButton.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
       trace("Mouse clicked");

    use:
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;
    import flash.events.MouseEvent;
    var inputField:TextField = new TextField();
    var myFormat:TextFormat = new TextFormat();
    myFormat.size = 44;
    inputField.defaultTextFormat = myFormat;
    inputField.restrict = "0-9";
    inputField.maxChars = 6;
    inputField.multiline = false;
    inputField.textColor = 0x000000;
    inputField.border = true;
    inputField.width = 150;
    inputField.height = 50;
    inputField.x = 75;
    inputField.y = 50;
    inputField.borderColor = 0xFF0000;
    inputField.type = "input";
    addChild(inputField);
    var inputField1:TextField = new TextField();
    var myFormat1:TextFormat = new TextFormat();
    myFormat1.size = 44;
    inputField1.defaultTextFormat = myFormat;
    inputField1.maxChars = 1;
    inputField1.multiline = false;
    inputField1.textColor = 0x000000;
    inputField1.border = true;
    inputField1.width = 150;
    inputField1.height = 50;
    inputField1.x = 275;
    inputField1.y = 50;
    inputField1.borderColor = 0xFF0000;
    addChild(inputField1);
    myButton.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
    function fl_MouseClickHandler_2(event:MouseEvent):void
    inputField1.text=String(Math.PI*Number(inputField.text));

  • Help with Forte: very simple question, please help!

    I recently downloaded the community version of Forte (Sun One) but can't seem to get any new empty class programs to execute properly. I know something is probably not set up right, which is why I really need a little help to get started. Regardless of the code I try to execute, the output error is always:
    "java.lang.NoClassDefFoundError: (name of program)
    Exception in thread "main" "
    Please let me know what I'm not doing right. I would really appreciate anybody's thoughts on this problem because I would love to get Forte working so I can start learning Java. Thanks for your input!

    I would tell you that Forte is not a tool for the beginner. you should look at something simpler. Forte is a fully integrated development environment. I would look at a simple editor like emacs, available at gnu.org. The commands of this editor are quite difficult to get use to.
    As for setting the class varialbe. It depends on the O/s that you are using. win98/me is different than NT/xp. Need to know one or the other before explaining.
    email me if you have question. email address is in my profile.

  • Simple question, please help

    I just need to know right now can SSL be used for secure FTP to send commands and data over separate channels, and if so, how? I want to replace a simple FTP socket connection with a secure one, nothing fancy. I don't want to use HTTP unless I absolutely have to. Any advice would be appreciated.

    Has anyone evaluated all the different options available and found the better alternatives? I have found SSH Communications Security's SSH Secure Shell, RSA Security's BSafe SSL-J, ValiCert's SecureTransport (a.k.a. FileDrive) and others. I haven't compared them in detail yet and was hoping to get some advice from others out there who are doing the same sort of thing.

  • Have 4 apps in waiting mode after I did update all, have done hard reset, deleted the apps setting general usage now I don't see them and no option to delete please help

    I have iphone 4s sprint, i did update all for 4 apps and they got stuck, I have tried to hard reboot and did delete the apps from usage under settings but they came back and there is no way to delete and even if i try to install it says installing so can't do anything..
    Please help

    Todd, have you "thrown the switch" to tell Palm Desktop to direct the data to Outlook?
    Start Button/All Programs/Palm/PIM Conduit Sync/Sync with Outlook.
    You said you're "using the Outlook 2007 Conduit" -- does this mean you installed the Outlook 2007 Update on top of Palm Desktop 6.2.2?  If so, that may be a problem as 6.2.2 comes with 2007 compatibility built into it!   
    I have read several posts recently where a user made the same mistake, and it caused some problems.  If throwing the switch above does not fix things, I'd uninstall/reinstall Palm Desktop, but do NOT install the Outlook 2007 patch.
    WyreNut
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • I am a new in jbuilder 4, a simple question, please help me.

    I want to combine the scroll bar with textarea. I mean that If the content in textarea is very large, I can scroll bar to see it.
    I write the code like this:
    JTextArea jTextArea1 = new JTextArea();
    JScrollBar jScrollBar1 = new JScrollBar(jTextArea1); But the error message is :"Frame1.java": Error #: 300 : constructor JScrollBar(javax.swing.JTextArea) not found in class javax.swing.JScrollBar at line 21, column 32
    The following is the full code:
    public class Frame1 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JTabbedPane jTabbedPane1 = new JTabbedPane();
      JPanel jPanel1 = new JPanel();
      JPanel jPanel2 = new JPanel();
      JPanel jPanel3 = new JPanel();
      BorderLayout borderLayout2 = new BorderLayout();
      JTextArea jTextArea1 = new JTextArea();
      JScrollBar jScrollBar1 = new JScrollBar();
      JPanel jPanel4 = new JPanel();
      JButton jButton1 = new JButton();
      BorderLayout borderLayout3 = new BorderLayout();
      JTextArea jTextArea2 = new JTextArea();
      JScrollBar jScrollBar2 = new JScrollBar();
      JPanel jPanel5 = new JPanel();
      JButton jButton2 = new JButton();
      /**Construct the frame*/
      public Frame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      /**Component initialization*/
      private void jbInit() throws Exception  {
        //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
        contentPane = (JPanel) this.getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(513, 399));
        this.setTitle("File Integrity Check Tool");
        jPanel1.setLayout(borderLayout2);
        jButton1.setToolTipText("");
        jButton1.setText("Register Files");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButton1_actionPerformed(e);
        jPanel2.setLayout(borderLayout3);
        jButton2.setText("Check Files");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            jButton2_actionPerformed(e);
        jTextArea1.setEditable(false);
        jTextArea1.setMaximumSize(new Dimension(513, 399));
        jTextArea2.setEditable(false);
        contentPane.add(jTabbedPane1, BorderLayout.CENTER);
        jTabbedPane1.add(jPanel1, "Register Checkfile");
        jPanel1.add(jTextArea1, BorderLayout.CENTER);
        jPanel1.add(jScrollBar1, BorderLayout.EAST);
        jPanel1.add(jPanel4, BorderLayout.SOUTH);
        jPanel4.add(jButton1, null);
        jTabbedPane1.add(jPanel2, "Check Files");
        jPanel2.add(jTextArea2, BorderLayout.CENTER);
        jPanel2.add(jScrollBar2, BorderLayout.EAST);
        jPanel2.add(jPanel5, BorderLayout.SOUTH);
        jPanel5.add(jButton2, null);
        jTabbedPane1.add(jPanel3, "Help");
      /**Overridden so we can exit when window is closed*/
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
      }

    yes, I done like this:
    package untitled1;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Frame1 extends JFrame {
      JPanel contentPane;
      BorderLayout borderLayout1 = new BorderLayout();
      JTabbedPane jTabbedPane1 = new JTabbedPane();
      JPanel jPanel1 = new JPanel();
      BorderLayout borderLayout2 = new BorderLayout();
      JTextArea jTextArea1 = new JTextArea();
      JScrollPane jScrollPane1 = new JScrollPane( jTextArea1);
      JPanel jPanel2 = new JPanel();
      JButton jButton1 = new JButton();
      /**Construct the frame*/
      public Frame1() {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      /**Component initialization*/
      private void jbInit() throws Exception  {
        //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
        contentPane = (JPanel) this.getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        this.setTitle("Frame Title");
        jPanel1.setLayout(borderLayout2);
        jTextArea1.setText("jTextArea1");
        jButton1.setText("jButton1");
        contentPane.add(jTabbedPane1, BorderLayout.CENTER);
        jTabbedPane1.add(jPanel1, "jPanel1");
        jPanel1.add(jTextArea1, BorderLayout.CENTER);
        jPanel1.add(jPanel2, BorderLayout.SOUTH);
        jPanel2.add(jButton1, null);
        jPanel1.add(jScrollPane1, BorderLayout.EAST);
      /**Overridden so we can exit when window is closed*/
      protected void processWindowEvent(WindowEvent e) {
        super.processWindowEvent(e);
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          System.exit(0);
    }But it is still not show the scroll bar on the right of textarea.
    what is the problem.

  • Installing HTML Server and HTML DB

    I am installing the HTML server and HTML db. I get to the screen to enter the HTML DB information and an failing with an error ORA-01017:Invalid username and password. I have checked my SYS password by logging into the database I am using. From the instructions I though the HTML DB Password would be created on install. I have gotten this error before when my tnsnames.ora file was not correct, but I am using it with not problems for database links.
    Does anybody have a suggestion
    Thanks

    Thanks for the response.
    I have a running Oracle 10g Enterprise running in /var/oracle/product/10.1.01.E.on a test Linux system. I have started the install of the companion disk, and when the install screen comes up I enter Name=>MasterProjEntHTML (MasterProjEnt is the name of the database I am using). I enter a new directory for path ( as per the Companion CD Install Instruction that said you need to install the HTML server in a new oracle home directory), /var/oracle/product/companion_1. I then press next and wait for it to load. I select Oracle Database 10g Companion Products. I select Apache Standalone and HTML DB from the Available Products Components screen. Next comes up the Enter HTML DB Congif screen. I enter host name, port, DSN as mral.home.com ( as listed in global naming parameter and tnsnames.ora), I enter my sys password and then the HTML DB password. When I hit next, if get the following. "ERROR: SQLException occured while connecting to the database. Please check the connection details of the database you specifiec and retry. ORA_01017:Invalid username/password, logon denied"
    At this point I went to my desktop and remote logged in using my user password and name. I was able to connect. Next I went back on the server and logged in as sys with the password and was able to connect. So at this stage I think my sys password is ok.
    Did I misunderstand the instructions about the directory for the HMTL server?
    Any help would be appreciated as I am working on my masters and this is necessary to complete the project.
    Thanks again

  • Hi I live in Iran and I forgot the answer to the security question please help me thanks

    Hi I live in Iran and I forgot the answer to the security question please help me thanks

    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.
    This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

  • Helo , my secret question and apple id was blocked, please help me repair my apple id , i want to keep using this my apple id

    dear ...
    please help meeee.... my my secret question and apple id was blocked, please help me repair my apple id , i want to keep using this my apple id.
    please helppppp meeeeeee......
    <E-mail Edited by Host>

    Dendyhebatz wrote:
    dear ...
    please help meeee.... my my secret question and apple id was blocked, please help me repair my apple id , i want to keep using this my apple id.
    please helppppp meeeeeee......my email & apple id XXXXXXX
    Try changing your Apple ID password at iforgot.apple.com first.
    Also:
    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.  This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

  • I updated imovie and I Used to be able to save as Quicktime file, now not an option & files are so large when I save as mpeg4 and just rename them. Please help!

    I updated imovie and I used to be able to save as Quicktime file, now not an option & files are so large when I save as mpeg4 and just rename them. Please help!

    Actually it is easier than I thought. It is H264 but the wrapper is m4v. You can just change that in the finder to .mov and drop it into iDVD. iMovie will send it to iTunes so just right click on it in iTunes and select reveal in finder and then copy/paste to desktop and change to .mov. Then drag into iDVD. Really easy.

  • What is the difference between HTML DB and HTML DB Studio?

    What is the difference between HTML DB and HTML DB Studio?

    Doug,
    Oracle HTML DB is a feature of the Oracle 10g Database which allows you to quickly & securely create web applications based on your data in Oracle.
    Please see our homepage on OTN for more details: http://otn.oracle.com/htmldb
    Oracle HTML DB Studio is a site where you can download HTML DB applications, utilities & tip and tricks for use with HTML DB.
    Thanks,
    - Scott -

  • HT2968 I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    I can not update several of my apps that i have purchased a while back in my Apps Store on my MacPro. Because it keeps using my old @me account for iTunes and i don't remember the password or security question, Please help?

    Hi AlphaCentori,
    If you are having issues accessing the Apple ID that was used to originally purchase those apps, you may find the following article helpful:
    Apple Support: Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Regards,
    - Brenden

  • Hi, I have traveled the country and have forgotten my security questions please help me thank you

    Hi, I have traveled the country and have forgotten my security questions please help me thank you

    Call Apple to help reset your Security Question.
    http://support.apple.com/kb/HT5699

  • HT201363 Hello, I have my pass word, I have my Apple ID, but itunes think I am buying a song for the first time and is asking me 2 security questions, please help, what should i do?

    I cannot remember the answeres to my security questions, please help.

    You need to ask Apple to reset your security questions; this can be done by phoning AppleCare and asking for the Account Security team, or clicking here and picking a method, or if your country isn't listed in either article, filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (105959)

Maybe you are looking for