Results 1 to 12 of 12
Thread: Java Netbeans and HTML
- 02-03-2010, 12:34 PM #1
Member
- Join Date
- Feb 2010
- Posts
- 5
- Rep Power
- 0
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!
- 02-04-2010, 10:01 AM #2
Member
- Join Date
- Feb 2010
- Posts
- 4
- Rep Power
- 0
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.
- 02-08-2010, 01:09 AM #3
Member
- Join Date
- Aug 2009
- Posts
- 25
- Rep Power
- 0
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*
- 02-08-2010, 01:10 AM #4
Member
- Join Date
- Aug 2009
- Posts
- 25
- Rep Power
- 0
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.
- 02-10-2010, 06:02 AM #5
Senior Member
- Join Date
- Mar 2009
- Location
- USA
- Posts
- 127
- Rep Power
- 0
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.
- 02-10-2010, 09:30 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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...
- 02-10-2010, 10:42 AM #7
Member
- Join Date
- Aug 2009
- Posts
- 25
- Rep Power
- 0
@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
- 02-10-2010, 10:56 AM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
You only need them to display them on a page...so they go in the request.
- 02-10-2010, 05:02 PM #9
Senior Member
- Join Date
- Mar 2009
- Location
- USA
- Posts
- 127
- Rep Power
- 0
@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="....." />
- 02-10-2010, 05:20 PM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Sticking stuff in the session is a bad habit to get into. It doesn't scale.
- 02-10-2010, 10:35 PM #11
Member
- Join Date
- Aug 2009
- Posts
- 25
- Rep Power
- 0
agreed with trolls.
I know how to code a jsp page aseem , but thx for the explanation anywayz ^^
- 02-11-2010, 04:54 AM #12
Senior Member
- Join Date
- Mar 2009
- Location
- USA
- Posts
- 127
- Rep Power
- 0
Similar Threads
-
Netbeans 6.5.1 & embedding in html page
By dbashby in forum New To JavaReplies: 5Last Post: 04-06-2009, 03:58 AM -
HTML/Java
By Bomber_Will in forum New To JavaReplies: 5Last Post: 03-21-2009, 09:37 PM -
Using HTML in java
By hitmen in forum AWT / SwingReplies: 3Last Post: 02-26-2009, 05:58 AM -
NetBeans, html won't update
By yuriythebest in forum Java AppletsReplies: 14Last Post: 11-09-2008, 02:52 AM -
How can I include a html file in html textarea?
By surya_dks in forum New To JavaReplies: 2Last Post: 10-04-2008, 07:20 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks