jsp and bean problem

Ads
 

jsp and bean problem

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

View Answers

Ads









Related Tutorials/Questions & Answers:
jsp and bean problem
jsp and bean problem  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
How to get Output for a Bean problem
How to get Output for a Bean problem  Hello Kindly tell me a simple Program on Bean to get the Output using JSP code
Advertisements
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Problem in jsp.
Problem in jsp.  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table..." action="http://localhost:8080/examples/jsp/insertdata.jsp"> <table> <
Jsp problem
Jsp problem  Hello friends.I want to share my jsp problem.I want to show all of my database(mysql) tables except two(user,manufacturer) in a jsp page.plssss help me
jsp problem
jsp problem  problem:::::::: On JSP form ,when i insert data in text field........at that time action is perform and data is retriev from data base and get assign to other field on that form........ when data is assign to other
jsp problem
jsp problem  Hello Friends, I want to show one page for 5 seconds and after that i want to redirect the page to another URL
jsp problem
jsp problem  Hi every one plz give me answer for below question ASAP I created one JSP(used pre defined javascript in jsp to get rtf format in browser) which creats RTF Format in browser to enter data. MY question is after i
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
jsp reload current page problem
jsp reload current page problem  Hi, i am facing problem while reloading the JSP page
JSP code problem - JSP-Servlet
JSP code problem  HI.. I have a DB2 stored procedure wich return a result set. I have made a report basing on this procedure using Crystal Reports. How to pass parameters to this procedure with java code in a JSP page
JSP bean get property
JSP bean get property   ... in JSP page. The JSP page uses bean get property and return the value stored... to locate and search an instance of the bean. Attributes used in <jsp
Radio Button Problem in jsp.
Radio Button Problem in jsp.  I have a small doubt in my application, my requirement is to get a "single selectible row", I generated a radio button... radio button values from jsp to action using javascript
Statistical charts in JSP - problem
Statistical charts in JSP - problem  hey! i get this error when i run... org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred... An error occurred at line: 11 in the jsp file: /BarChart.jsp
JSP run problem
JSP run problem  type Exception report message description... this request. exception org.apache.jasper.JasperException: Exception in JSP...) root cause java.lang.NullPointerException org.apache.jsp.bb_jsp
Problem in record viewing in jsp - JSP-Servlet
Problem in record viewing in jsp  hai i have developed the application using jsp,servlets in eclipse ide i have to insert,delete,update and view . no problem all are working but in view part alone some problem i dont know what
Java bean example in JSP
Java bean example in JSP     .... The next step is to create a JSP page. This JSP page uses My bean package . Let.... scope - This is used to specify that bean can be called in any jsp page
JSP bean set property
JSP bean set property   ... you a code that help in describing an example from JSP bean set property...:useBean> -  The  < jsp:use Bean> instantiate a bean class
problem in record viewing in jsp - JSP-Servlet
problem in record viewing in jsp  hai i send the code can you please find where is the problem it is not showing any error but i cannot able to view the record after eclipse ide is closed and reopen it i have used the jsp
How to get the output of JSP program using Bean
visit the following link: http://www.roseindia.net/jsp/using-bean-counter.shtml...How to get the output of JSP program using Bean  Hi Kindly go...; <jsp:useBean id="counter" scope="session" class="CounterBean" /> <
how to create bean using jsp and servlet
how to create bean using jsp and servlet  public class SampleBean... the following links: http://www.roseindia.net/jsp/usingbeansinjsp.shtml http://www.roseindia.net/jsp/loginbean.shtml
problem in jsp using ms-access
problem in jsp using ms-access  after starting server(tomcat) wen v...)Your DSN will get created. 6) Restart your server and run your jsp code. Here... will get created. 6) Restart your server and run your jsp code. Here is your
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
How to get the output of jsp program using Bean
; Next i created JSP program for the above one by using Bean and i opened...How to get the output of jsp program using Bean  Hello my Roseindia..." %> <HTML> <HEAD> <TITLE>Use Bean Counter Example <
Java Servlet Problem - JSP-Servlet
method. Please help!!  Hi friend, Please explain problem in details for complete solution and send code the where are you problem. Thanks
how to Use jsp:setProperty to set one bean in other bean while to be set bean is of type java.util.List<beantype>
how to Use jsp:setProperty to set one bean in other bean while to be set bean...; private int numOfPages; // Getters and Setters I have a single jsp (a.jsp) containing input fields for all the 3 classes, and action of that jsp
problem at the time of execution - JSP-Servlet
problem at the time of execution  when i was running web applications the exception i.e 404 resource is not available what it means and where it occures what is the solution   Hi Friend, This error occurs when
problem on jsp, inserting data into table(mysql).
problem on jsp, inserting data into table(mysql).  hello friends, I have a problem in jsp.I want to insert data, which is given by user through a html page into a table.And the table name also is given by the user.My database
Jsp/java-script, spring combination problem
Jsp/java-script, spring combination problem   Hi Friends....... I am developing one application using jsp,spring,java script,hibernate,Pojo There is one Jsp form on that I want data as location and ward wise; There is two
problem of static in jsp page by multiple user access
problem of static in jsp page by multiple user access  hi , i am continuing my online exam project,but i have a Singleton class which i am invoking from my jsp page , ths page can access by more number of users .every user

Ads