Hi i have the following jsp code... Can you plz help me in separating the code to bean? I'm new to bean and need it for my project...Plz help...Its quite urgent... Regards Priya
<%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <head> <link rel="stylesheet" type="text/css" href="cintel.css"> <title>Category1</title> </head> <body> <% try { String connectionURL = "jdbc:mysql://200.0.0.153:3306/snms"; Connection connection = null; ResultSet rs=null; ResultSet rs1=null; Statement statement=null; // Load JBBC driver "com.mysql.jdbc.Driver". Class.forName("com.mysql.jdbc.Driver").newInstance(); connection = DriverManager.getConnection(connectionURL, "root", "root"); int updateQuery = 0; //Connection con=null; // check weather connection is established or not by isClosed() method //if(!connection.isClosed()) statement = connection.createStatement(); // sql query to retrieve values from the secified table. //rs = statement.executeQuery(QueryString); int v_TS = 1; String v_RGPC; String v_CETR; String v_DR; String v_CS; String v_CP; String v_TOp; String v_Ddeb; String v_COEIE; String v_CAtt; String v_IDAtt; String v_NI; String v_UP; String v_Centre; String v_CodeO; String v_CGest; String v_TEq; String v_Dfin; String v_Zone; String v_CTrx; String v_NChan; String v_Code; String v_QtL; String v_Large; String v_Haut; String v_Des; String v_Maj; String v_Qt; String v_Cout; String v_Tot; String v_codeProduit; %> <form method="post" action="insertdata.jsp"> <h2>Saisie Attachement</h2> <table width="1300"> <tr> <th colspan="2" scope="col">Attachement Sur l'OT/L'OEIE: ATT_GDP_01</th> <th colspan="3" scope="col">Etat1</th> <th colspan="3" scope="col">Flux</th> </tr> <tr> <th width="242" scope="row">Type de Situation</th> <td colspan="4"> <select name="selSit"><option value=""><---Select---></option> <% PreparedStatement psmnt = connection.prepareStatement("select * from xx_situation "); ResultSet results = psmnt.executeQuery(); while(results.next()){ String name = results.getInt(1)+" "+results.getString(2); int id = results.getInt(1);%> <option value="<%= name %>"> <% out.println(name); %> </option> <%} results.close(); psmnt.close(); %> </select> <%String option=request.getParameter("selSit"); if(option==null){ } else{%> <input type="text" name = "txtTS"value="<%=option%>"> <% } %> </td> </tr> <% String QueryString = "SELECT co.codebase,co.codeproduit,co.agentetl,co.CommentaireADO,co.numint,co.refot,cm.libellecommutateur,ui.codeui,zi.LibelleZoneIntervention FROM code_ot co,commutateur cm, ui,Zone_intervention zi ,Equipement eq WHERE cm.equipementid=co.codere AND ui.uiid=co.uiid AND co.codere = eq.equipementid AND zi.Zone_InterventionID = eq.Zone_InterventionID AND co.code_codeot=12"; rs = statement.executeQuery(QueryString); while (rs.next()) { v_RGPC = rs.getString("codebase"); v_CETR = rs.getString("agentetl"); v_codeProduit = rs.getString("codeproduit"); if (v_codeProduit == "FTH") { v_DR = "RF"; } else { v_DR ="L"; } if (rs.getString("CommentaireADO")==null) { v_CS = ""; } else { v_CS =rs.getString("CommentaireADO").substring(2, 5); } v_CP = "";//A saisir v_TOp = "";//DCA ou DGC. Comment determiner laquelle des 2 valeurs? v_Ddeb = "";//rs.getString(2); if (rs.getString("CommentaireADO")==null) { v_CodeO = ""; } else { v_CodeO =rs.getString("CommentaireADO").substring(5, 11); } v_COEIE = "";//A saisir v_CAtt = "";//A saisir v_IDAtt = "";//?? v_NI = rs.getString("NUMINT"); v_UP = "";//A saisir v_Centre = rs.getString("libellecommutateur");//rs.getString(63); v_CGest = "";//"Y a t'il une aide a la saisie (Code -> libelle)Je me renseigne sur cette partie." if (v_codeProduit == "FTH") { v_TEq = "D"; } else { v_TEq ="CU"; } v_Dfin = "";//rs.getString(2); v_Zone = "";//rs.getString(2); if (rs.getString("CommentaireADO")==null) { v_CTrx = ""; } else { v_CTrx =rs.getString("CommentaireADO").substring(12, 16); } v_NChan = "";//rs.getString(2); v_Code = "";//rs.getString(2); v_QtL = "";//rs.getString(2); v_Large = "";//rs.getString(2); v_Haut = "";//rs.getString(2); v_Des = "";//rs.getString(2); v_Maj = "";//rs.getString(2); v_Qt = "";//rs.getString(2); v_Cout = "";//rs.getString(2); v_Tot = "";//rs.getString(2); %> <tr> <th scope="row">Reference GPC</th> <td width="150"><input type="text" name="txtRGPC" value="<%=v_RGPC%>"/> </td> <th width="189">Numint</th> <td width="151"><input type="text" name="txtNI" value="<%=v_NI%>"/></td> </tr> <tr> <th scope="row">Code ETR</th> <td><input type="text" name="txtCETR" value="<%=v_CETR%>"/></td> <th>Unite de Production</th> <td><input type="text" name="txtUP" value="<%=v_UP%>"/></td> </tr> <tr> <th scope="row">Domaine Reseau</th> <td><input type="text" name="txtDR" value="<%=v_DR%>"/></td> <th>Centre</th> <td><input type="text" name="txtCentre" value="<%=v_Centre %>"/></td> <th width="133">Zone</th> <td width="146"><input type="text" name="txtZone" value="<%=v_Zone%>"/></td> </tr> <tr> <th scope="row">Code Secteur</th> <td><input type="text" name="txtCS" value="<%=v_CS%>"/></td> <th>Code OEIE</th> <td><input type="text" name="txtCodeO" value="<%=v_CodeO%>"/></td> <th>Famille Cat de Tvx</th> <td><input type="text" name="txtCTrx" value="<%=v_CTrx%>"/></td> <th width="94">No Chantier</th> <td width="159"><input type="text" name="txtNChan" value="<%=v_NChan%>"/></td> </tr> <tr> <th scope="row">Code Prometee</th> <td><input type="text" name="txtCP" value="<%=v_CP%>"/></td> <th>Code de Ch de Gestion</th> <td><input type="text" name="txtCGest" value="<%=v_CGest%>"/></td> </tr> <tr> <th scope="row">Type d'Operation</th> <td><input type="text" name="txtTOp" value="<%=v_TOp%>"/></td> <th>Type d'Equipement</th> <td><input type="text" name="txtTEq" value="<%=v_TEq%>"/></td> </tr> <tr> <th scope="row">Date de Debut</th> <td><input type="text" name="txtDdeb" value="<%=v_Ddeb%>"/></td> <th>Date de Fin</th> <td><input type="text" name="txtDfin" value="<%=v_Dfin%>"/></td> </tr> <tr> <th scope="row">Commentaire de l'OEIE</th> <td colspan="2"><input type="text" name="txtCOEIE" size="57" value="<%=v_COEIE%>"/></td> </tr> <tr> <th scope="row">Commentaire de l'Attelem</th> <td colspan="2"><input type="text" name="txtCAtt" size="57" value="<%=v_CAtt%>"/></td> </tr> <tr> <th scope="row">Indicateur du dernier Attelem</th> <td><input type="text" name="txtIDAtt" value="<%=v_IDAtt%>"/></td> </tr> <tr></tr> <tr></tr> </table> <br> <table width="1300"> <tr> <th colspan="8" scope="col">Saisie de Code de travaux et/ou materiels associes</th> </tr> <tr> </tr> <tr> <th>Code</th> <td><input type="text" name="txtCode"/></td> <th>Qt/Long</th> <td><input type="text" name="txtQtL"/></td> <th>Large</th> <td><input type="text" name="txtLarge"/></td> <th>Haut</th> <td><input type="text" name="txtHaut"/></td> </tr> <tr> <td colspan="8" rowspan="2">Lignes ASP et Materiel</td> </tr> </table> <br> <table width="1300"> <tr> <th colspan="10">Saisie de lignes des factures</th> </tr> <tr> <td colspan="10"> </td> </tr> <tr> <th>Designation</th> <td><input type="text" name="txtDes"/></td> <th>Maj</th> <td><input type="text" name="txtMaj"/></td> <th>Qt</th> <td><input type="text" name="txtQt"/></td> <th>Cout</th> <td><input type="text" name="txtCout"/></td> <th>Total</th> <td><input type="text" name="txtTot"/></td> </tr> <tr> <td colspan="10"> </td> </tr> <tr> <td colspan="3.9"><input type="submit" name="btnsub"></td> <td colspan="3.9"> </td> <td colspan="4"> </td> </tr> </table> <% } // close all the connections. rs.close(); statement.close(); %> </form> <%connection.close(); } catch (Exception ex) { out.println("Error :" + ex); } %> </body> </html>
Plz help me else i'll fail my project...Thx a lot