Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

jsp and bean problem

Ads

 
 

Share on Google+Share on Google+

Boolaky Priya
jsp and bean problem
0 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners

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

Ads
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
bean - JSP-Interview Questions
bean  what is use bean in jsp?  Hi Friend, Please visit the following links: http://www.roseindia.net/jsp/using-bean-counter.shtml http://www.roseindia.net/jsp/java-bean-example-jsp.shtml Hope
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
login problem in java bean - Java Beginners
login problem in java bean  login.jsp no longer redirects to the appropirate page. my bean code is correct and while seeing in error logs... immediately  Hi friend, Please give in details of problem
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 Problem - JSP-Servlet
JSP Problem  Hi, I have problem,this is my senario I have one jsp,this jsp having the 3 fields.let me take 3fields userName,emailAddress... for more information, http://www.roseindia.net/jsp Thanks
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... working but my problem is size of image. so can u just help?? code
jsp problem - JSP-Servlet
jsp problem  here is a code for Retrieving image from mysql database through jsp. but i cann't set size of image when it was display so what should... working but my problem is size of image. so can u just help?? code
jsp usebean problem - Struts
popupwindow jsp below code run.. ...here iam getting the problem..in the below... bean class... first of all i didn't put jsp:usebean..it didn't access the dto(bean...jsp usebean problem   --Select
jsp problem - JSP-Servlet
jsp problem  hi, i am working on a project of developing a shopping cart for online book store.can it be done using jsp?if yes, can u please help me doing so?  Hi Friend, Please visit the following link: http
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
problem in programming - JSP-Servlet
problem in programming  Hi! I am new with jsp. I am facing a problem in programming to calculate the time interval between login time and logout time of user
problem in jsp programming - JSP-Servlet
problem in jsp programming  Write a JSP program which displays a webpage containing arrival of new items within a particular month in the different... in solving the problem : Connection with mysql database
jsp code problem - JSP-Servlet
jsp code problem  Hi, I have employee details form in jsp. After... have a problem with open the next form. plz, help me. thanks,  Hi.... http://www.roseindia.net/jsp/ Thanks
Session Problem in JSP - JSP-Servlet
Session Problem in JSP  I have developed a online feedback form in JSP platform. I have created normal session in JSP page. It is running in my... normally from Remote machine by only writing JSP code.  Hi friend
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 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
logout problem?? - JSP-Servlet
logout problem??  sir, the logout code which u have send is not the proper solution coz,by using this code the browser get closed which shuold.../Logout.shtml http://www.roseindia.net/jsp/loginstatus.shtml Thanks
logout problem.. - JSP-Servlet
logout problem..  hi... first of all thanks for ur... but their is some problem with the the logout,i m not able to logout when... done in the code i have used session object in project's servlet and jsp
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
Using Bean Counter in JSP
Using Bean Counter in JSP       In this section you will learn how the counter bean can be used... bean with a jsp. Here is an example which explains the purpose.     Code
coding problem - JSP-Servlet
coding problem  dear sir i m very new to JSP sir i m getting problem in dynamically changing the option of combobox from database(ms acess) .and after that option being selected for that the record from the databse should
jsp problem - Java Server Faces Questions
jsp problem  step by step processing of bean and forms processing in jsp
jsp image problem - JSP-Servlet
jsp image problem  hi everyone, How to display multiple images from mysql database to jsp page. please help me