|
Dit topic is 40 pagina's lang: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
||||
Auteur: |
|
|
quote: Wat ik heb gehad is discrete wiskunde in de vorm van groepen theorie en recurrente betrekkingen e.d. ook nog wat Wiskunde B achtige zaken met bijvoorbeeld Fourier transformaties. Verder mbt tot logica zover als lambda calculus, typed lambda, polymorphisme etc. etc. Wat in de lamba cube voorkomt. Daarbij ook nog wel eens wat over protocol validatie met uCRL, maar daar heb ik allemaal niet zoveel aandacht aan besteed. Dat is meer de Theoretische informatie. Daar zit ik echt niet op te wachten. "This one is older than shit, heavier than time!" |
|
quote:Met de introductie van PHP5 is PHP al wel meer die kant opgegaan maar ze zijn er natuurlijk nog lang niet en ik verwacht ook zeer zeker niet dat het ooit nog zover gaat komen dat PHP Java gaat inhalen op dat terrein. PHP is een uitstekende taal voor kleine tot middelgrote webapplicaties, als het echt gaat om grote complexe systemen dan is het enkel wellicht leuk in de front-end. |
|
Deze uitleg kreeg ik op het Sun-forum: Hi there, I'll give you the steps and then you can try those steps with code - 1) Create a JavaBean that represents one record of your data. The collection of this JavaBean will be stored in an ArrayList which will be read in the JSP page using jsp:useBean tag and JSTL corEach loop. For example com.beans.Producten.java The above bean must have an empty default constructor. It must also have private propreties that correspond to all columns in the database table, and corresponding getters and setters for those properties - conforming to JavaBeans notation. 2) We try to move the JDBC code to the Application layer. First create a normal Java Class under the data access layer package. For example com.dataaccess.DataAccess.java create a public method which returns a java.util.List <Producten> (This is a List of Producten JavaBeans - which will be used in the JSP page to iterate and create a HTML table) copy only the database related code from Connection con = null; ......... up until ResultSet rs = statement.executeQuery(sqlOpdracht); Also copy while ( rs.next() ) { int ProductID = rs.getInt("ProductID"); int ProducentID = rs.getInt("ProducentID"); int CategorieID = rs.getInt("CategorieID"); } Just before the above loop have this statement List<Producten> productenList = new ArrayList<Producten>(); to initialize producteList , which holds Producten JavaBeans Also have this statement above the loop. Producten producten = null; Then inside the loop add this producten = new Producten(); producten.setProductId(productId); and so on.... add all the columns from the ResultSet row into the properties of the Producten JavaBean. After adding all the columns, store the Producten JavaBean into the ArrayList productenList.add(producten ); <-------- this line is also in the ResultSet loop . Now you finished creating the arraylist of Prodcuten objects , Close ResultSet, Statement and Connection Return the ArrayList. That's it, the JDBC code is done. 3) Then write a Servlet , store the mapping for the servlet in your projects web.xml Inside the servlet's doGet or doPost method , create an instance of the above Java Database class. And get the List of Producten objects Store the List obtained above into HttpRequest object request.setAttrybute(producttenList); Then using RequestDispatcher , forward the request to a JSP page. 4) Inside the JSP page make use of jsp:useBean tag , specify scope="request" , and get the ArrayList 5) Install and configure JSTL 1.1.x 6) In the same JSP page use JSTL's corEach tag , and iterate over the array list obtained in step 4 above. 7) Wrap the corEach loop with HTML Table, but inside corEach create an HTML table row , inside that row add HTML table columns 8) Inside the HTML table colums use ${produtenList.productId} , to display the value stored in that colum. That's it you're done. Note that , in the JDBC layer it is better to use Connection Pooling -- Connection Pooling helps in 1) Optimizing your database connection Here is an overview of how to try connection pooling and work with it in the right manner: http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html But the above is a little advanced for you now, so get the basic stuff set up and then you can take a look at JDBC Connection Pooling. Hij heeft het over JSP + Servlets + Beans, klopt dat? |
|
Zo te zien wel ja. Hoezo? |
|
Omdat ik in de veronderstelling was dat je een keuze moest maken tussen EJB en Servlets. |
|
Hier weet Snaack wel meer over volgens mij |
|
Heb her en der wat leesfouten gemaakt, hehe. Zo dacht ik dat EJB hetzelfde is als JavaBeans enzo, maar dat zit allemaal weer anders. Enfin. Ben nu op weg met beans, maar heb hetzelfde probleem als gister. /WebshopBeanTest.jsp:1: Can't find class 'connections.ConnectionBean' Die .class-file moet aangemaakt worden zodra de .java-file wordt aangeroepen door de JSP-pagina. Bean 'connection' zit in de map 'connection' en zou dus nu een .class-file met de naam 'ConnectionBean' moeten aanmaken.
[Dit bericht is gewijzigd door WhiteRider op 30-03-2007 13:09] |
|
een .class wordt gemaakt tijdens compilatie Ofwel je zal dat moeten compilen voordat je het zaakje gaat runnen op de server. Dat is wat ik eruit opmaak met mijn geringe ervaring [Dit bericht is gewijzigd door 0Tolerence op 30-03-2007 21:53] "This one is older than shit, heavier than time!" |
|
ehh ja een class die met runtime gemaakt wordt is normaliter een beetje gek Born to bleed. Fighting to succeed. Build to endure what this world throws at me.. Mag ik u verder een boeketje haagsche bloemen aanbieden? |
|
Eergister maakte hij automatisch die .class-file aan, hehe. |
|
Dat kan wel, als je webserver zo geconfigureerd is dat hij de bestanden van de apps die op de server gedeployed zijn constant scant op veranderingen. "Dynamic context loading" heet dat op Tomcat. Als er iets in de context verandert, worden de sources opnieuw gecompileert en wordt de context herladen. Tijdens ontwikkelen retehandig, want dan hoef je je app bij kleine aanpassingen niet steeds te builden en opnieuw te deployen, maar het kost natuurlijk wel flink resources. Voor kleine apps zonder al te veel dependencies kan het wel, voor complexere systemen is het echt een no go. Dan gebruik je een build tool, bijvoorbeeld MAVEN. |
|
Aah, vandaar, thankx! |
|
Fukcz0rz, ben een inlogsysteem met levels aan het maken. if (logincode==persoon && hexString.equals(password) && level == 2){ Waarom kom ik uit bij m'n 'else'? Ik heb voor de zekerheid natuurlijk alle variabelen getest (logincode, persoon, hexString en password), output is: 1001 1001 32e6eb142601d344c188b94a8fe5f2cd 32e6eb142601d344c188b94a8fe5f2cd Dus die zijn gewoon gelijk. Waarom kom ik altijd bij mijn 'else'? [Dit bericht is gewijzigd door WhiteRider op 08-04-2007 22:12] |
|
quote: Wat voor type variabele zijn logincode/persoon? Misschien moet je daar ook een 'equals' ipv een '==' gebruiken. Ik zou bij dit soort problemen de verschillende statements uit je if-statement afzonderlijk testen, dan zie je veel sneller waar het probleem zit. Ahora kién, kién es el asesino. Ahora kién, kién mata sin razón. Ahora kién, utiliza las torturas.... |
|
Dat ga ik maar eens doen ja... Persoon/logincode zijn ints, trouwens. |
|
quote: Ik besefte me niet dat een StrinBuffer iets anders is dan een String, daar lag het probleem. |
|
Bij het vergelijk van Strings altijd equals of equalsIgnoreCase gebruiken. Anders vergelijk je alleen de pointers waar de variabelen naar toe wijzen en niet de inhoud van de Strings. Vaak zal het wel werken want java houdt een soort cache bij van alle Strings en hergebruikt strings als ze weer opnieuw worden aangemaakt. Alleen dit is geen garantie en kan en zal dus vaak fout gaan. |
|
Klopt, maar een StringBuffer valt sowieso niet met een String te vergelijken, hehe. Nu werkt het wel gelukkig. |
|
Hell jawel! Ik mag gaan low-level programmeren het komende blok! |
|
NERD, wie heeft daar uberhaupt zin in. Programmeren is sowieso al kut "This one is older than shit, heavier than time!" |
|
Ik heb morgen een assesment voor microprocessoren 2. Onder andere over architectuur, CISC, RISC, datapad, ALU, machinecode en de Von Neumann-cyclus. Nu hebben we niet alleen in C geprogrammeerd, maar ook nog eens in assembly, daar zal het ook wel voor een groot gedeelte over gaan. |
|
oops ik heb de verkeerde topic geklikt... [Dit bericht is gewijzigd door koekenbier op 11-04-2007 21:44] |
|
quote:*checkt dictaat voor aankomend blok* Same shit here. RISC en CISC is dan al in het eerste blok aan bod gekomen maar daar had ik vrijstelling voor. Of die vrijstelling wel zo terecht was bewtijfel ik nu ernstig |
|
quote: Vrijstellingen zijn dan ook niet altijd handig. Wat voor opleiding volg je? |
Dit topic is 40 pagina's lang: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
Index / Algemeen | Vorige pagina | Volgende pagina |