C.V.

 
 

       10.4.8 Servlet opcos.java

       Acest servlet functioneaza ca un demultiplexor si deleaga realizarea sarcinilor catre cosal.java, plata.java sau usrlg.java.

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.*;
import javax.servlet.http.HttpSession;
import java.util.*;

public class opcos extends HttpServlet {  

public void doPost(HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException {
  doGet(req,res);
}

public void doGet(HttpServletRequest req, HttpServletResponse res)
  throws ServletException, IOException {
  
  res.setContentType("text/html");
  HttpSession ses = req.getSession();
 
  String modif = req.getParameter("modif");
  String plata = req.getParameter("plata");
  String unou  = req.getParameter("unou");
  
  if(plata!=null){
    Connection con = (Connection)ses.getAttribute("connexion");
    try{
       Statement stmt;
       ResultSet rs;
       stmt = con.createStatement();
       rs = stmt.executeQuery("select count(codf) from clienti where codf=\"" + req.getParameter("cont")  
                          + "\" and pass=\"" + req.getParameter("pass") + "\"");
       if(!rs.getString(1).equals("0")){//cont existent
         rs.close();stmt.close();
         RequestDispatcher rd = req.getRequestDispatcher("plata"); 
         rd.forward(req,res);
      }
       else{
         rs.close();stmt.close();
         RequestDispatcher rd = req.getRequestDispatcher("cosal"); 
         rd.forward(req,res);
       }
    }
    catch(SQLException h){;}
  }
  if(modif!=null){
    RequestDispatcher rd = req.getRequestDispatcher("cosal"); 
    rd.forward(req,res);
  }	
  if(unou!=null){
    RequestDispatcher rd = req.getRequestDispatcher("usrlg");
    rd.forward(req,res);
  }
}
}



 
 
C.V.
 
Hosted by www.Geocities.ws

1