Results 1 to 12 of 12
  1. #1
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Default Java Netbeans and HTML

    Hi,

    I am developing a web application using HTML and Netbeans. I have the database connection set up between MySQL and Netbeans but the output is not printing on the HTML pages as of yet i.e. it is only printing in Netbeans.

    On one of the HTML pages there is a drop down box. I want to populate this drop down box with data from the MySQL database but I can't figure out how. Once the user selects an item from the drop down box then the text boxes on the HTML should also be populated with the corresponding data in the database.

    Would really appreciate some help!

  2. #2
    RFClover is offline Member
    Join Date
    Feb 2010
    Posts
    4
    Rep Power
    0

    Default

    You can use a browser, or preview in netbeans!

    I have heard that a PHP script inserted into HTML code will be useful and something called DB control language may be used.

  3. #3
    steelshark is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default

    real post is under this one, accidently hit enter:p
    Last edited by steelshark; 02-08-2010 at 01:12 AM. Reason: accidently hit enter *lol*

  4. #4
    steelshark is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default

    in your program, you should read all the needed files from ur DB , and create a bean class for them.So u can create an object for every record in your DB.That way you can keep an array of objects as the representation for your DB.You can access every record that way.
    good luck with it.

  5. #5
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

    Default

    Lets say,
    you developed front end in html or jsp(better use jsp)---->servlet----->database.
    So, servlet makes connection to database and pull out records. So, data is still in servlet until now.

    now use
    session.setAttribute("session variable",data pulled from db); to store data in session variable. Once you store in session variable.

    go to jsp where where your combo box is.
    in the option tag of combo box you can do: <%=request.getAttribute("session variable")%>
    you should be getting the value in combo box.
    Do import the java servlet class in ur jsp page using page directive.

    Hope this helps.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    Not in the session.
    No no no.
    You should store as little as possible in the session, and definitely not store stuff that is clearly request scoped stuff...

  7. #7
    steelshark is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default

    @Aseem: Wouldnt you get data acces and bean classes between your servlet and database?
    It's not very nice to combine data acces methods with businiss logic and basic entitities in one class.Seems logical to me that you create objects of the records in your database.

    @Tolls: Where do you suggest storing the records then?

    Regards, bas

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    You only need them to display them on a page...so they go in the request.

  9. #9
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

    Default

    @steelshark

    i assume since you are using combo box, there wont be many data. So session was suggested. Yes, you can use bean.


    Using this technique to pass beans, a request dispatcher (using either “include” or forward ” ) can be called. This bean will disappear after processing this request has been completed.

    Servlet: request.setAttribute( “theBean”, myBean );

    RequestDispatcher rd = getServletContext( ).getRequestDispatcher( “Thepage.jsp” );
    rd.forward(request, response);

    JSP PAGE:

    < jsp: useBean id="theBean" scope="request" class="....." />

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,931
    Rep Power
    19

    Default

    Sticking stuff in the session is a bad habit to get into. It doesn't scale.

  11. #11
    steelshark is offline Member
    Join Date
    Aug 2009
    Posts
    25
    Rep Power
    0

    Default

    agreed with trolls.
    I know how to code a jsp page aseem , but thx for the explanation anywayz ^^

  12. #12
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

Similar Threads

  1. Netbeans 6.5.1 & embedding in html page
    By dbashby in forum New To Java
    Replies: 5
    Last Post: 04-06-2009, 03:58 AM
  2. HTML/Java
    By Bomber_Will in forum New To Java
    Replies: 5
    Last Post: 03-21-2009, 09:37 PM
  3. Using HTML in java
    By hitmen in forum AWT / Swing
    Replies: 3
    Last Post: 02-26-2009, 05:58 AM
  4. NetBeans, html won't update
    By yuriythebest in forum Java Applets
    Replies: 14
    Last Post: 11-09-2008, 02:52 AM
  5. How can I include a html file in html textarea?
    By surya_dks in forum New To Java
    Replies: 2
    Last Post: 10-04-2008, 07:20 AM

Posting Permissions

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