<%@ page language="java" %> <%@ page session="true" %> <%@ page import="java.util.*"%> <%@ page import="javax.servlet.jsp.*"%> <%@ page import="javax.servlet.jsp.tagext.*"%> <%@ page import="java.sql.*" %> <%@ page import="listeners.SessionBean.*"%> <%! Connection Conexao; Statement stmt; ResultSet rc; String SQL; %> <% String url = request.getRequestURL().toString(); int slash = url.indexOf('/', 8); if(slash == -1) { slash = url.length(); } String baseURL = url.substring(0, slash); // user agent String UA = request.getHeader("user-agent"); if(UA == null) { UA = ""; } UA = UA.toLowerCase(); String accepted = request.getHeader("accept"); if(accepted == null) { accepted = ""; } // determine user agent boolean isWindows = (UA.indexOf("windows") != -1); boolean isPalm = (UA.indexOf("palm") != -1 || UA.indexOf("blazer") != -1); boolean isUp = (UA.indexOf("up.b") != -1 || UA.indexOf("up/") != -1); boolean isKlondike = (UA.indexOf("klondike/") != -1); boolean isNokia = (UA.indexOf("nokia") != -1 || UA.indexOf("6590/") != -1); boolean isRainbow = (UA.indexOf("rainbow") != -1); boolean isMotorola = (UA.indexOf("motorola/") != -1 || UA.indexOf("mot-/") != -1); boolean isSansung = (UA.indexOf("samsung/") != -1 || UA.indexOf("sec-/") != -1); boolean isLg = (UA.indexOf("lg-/") != -1); boolean isSonyericsson = (UA.indexOf("sonyericsson/") != -1); boolean isSiemens = (UA.indexOf("sie-/") != -1); %> NutriWay - Login dos Softwares
 


 
 


Informe qual software deseja utilizar, o código de usuário e a senha para acesso !

 

Escolha o software

Login

Senha

      Voltar    Esqueci a minha senha   
 

<% //00 Se vier de um celular if (isWindows) { } else { //System.out.println("Redirecionar para Celular ..."); response.sendRedirect("lognc2.jsp"); } String Login = request.getParameter("Login"); String Senha = request.getParameter("Senha"); String selectedPage = request.getParameter("selectedPage"); String erro = request.getParameter("erro"); listeners.SessionBean ses = new listeners.SessionBean(); //System.out.println("login/login = " + Login ); //System.out.println("login/senha = " + Senha ); //System.out.println("login/selectedPage = " + selectedPage); //System.out.println("login/erro = " + erro); Conexao = Conectar.AbreConexao(); if(Conexao == null){ System.out.println("login >> Conexao is null"); Conectar.FechaConexao(Conexao); %> <% } if ( erro == null || erro.equals("nok") ) { } else { stmt = Conexao.createStatement(rc.TYPE_SCROLL_SENSITIVE,rc.CONCUR_UPDATABLE); try { SQL = "SELECT COUNT(*) FROM cadastro WHERE Login = '" + Login + "' and Senha = '" + Senha + "'"; ResultSet rc = stmt.executeQuery(SQL); rc.next(); if (rc.getInt(1) == 0) { if (Login != null) { %>
Login ou Senha inexistente !
<% } }else{ try { SQL = "SELECT * FROM cadastro WHERE Login = '" + Login + "' and Senha = '" + Senha + "'"; //System.out.println("login/senha/SQL = " + Login + "*" + Senha + "*" + SQL); rc = stmt.executeQuery(SQL); while(rc.next() ) { //01 Carrega na session session.setAttribute("Login", (String) rc.getString("Login") ); session.setAttribute("Senha", (String) rc.getString("Senha") ); session.setAttribute("CPF", (String) rc.getString("CPF") ); session.setAttribute("Nome", (String) rc.getString("Nome") ); session.setAttribute("Sobrenome", (String) rc.getString("Sobrenome") ); session.setAttribute("Receitas","Fechadas"); //02 Cria o Map de Usuarios e já adiciona o usuário ServletContext ctx = getServletContext(); Map existe = (Map)ctx.getAttribute("usuarios"); if(existe == null) { //System.out.println("login/Criar Map e adicionar Usuario " + Login + " em Usuarios!" ); Map usuarios = new TreeMap(); ctx.setAttribute("usuarios", usuarios); usuarios.put(Login, new java.util.Date()); } else { boolean teste3 = existe.containsKey(Login); if (teste3 == true) { out.println("login/Usuário " + Login + " já está logado! " ); //System.out.println("login/Usuário " + Login + " já está logado! " ); } else { //out.println("login/Adicionando Usuario " + Login + " em Usuarios!"); String Logdata = Login + " em " + selectedPage; //System.out.println("Logdata " + Logdata); existe.put(Logdata, new java.util.Date()); } } //02 Cria o Map de Usuarios e já adiciona o usuário Beancbo.setNdcborefindex(""); Beancbo.setNdcboreftexto(""); Beancbo.setNdcborefvalue(""); Beancbo.setNdlistrefindex(""); Beancbo.setNdlistreftexto(""); Beancbo.setNdlistrefvalue(""); Beancbo.setNdcbomainindex(""); Beancbo.setNdcbomaintexto(""); Beancbo.setNdcbomainvalue(""); Beancbo.setNdlistmainindex(""); Beancbo.setNdlistmaintexto(""); Beancbo.setNdlistmainvalue(""); Beancbo.setSql( "" ); Beancbo.setCbo( "" ); if (selectedPage.equals("NutriDiabetes") ) { session.setAttribute("qualsoft", "NutriDiabetes"); } else if (selectedPage.equals("NutriCalorias") ) { session.setAttribute("qualsoft", "NutriCalorias"); } else if (selectedPage.equals("NCMobile") ) { session.setAttribute("qualsoft", "NCMobile"); } response.sendRedirect("comuns/nw+separa.jsp"); } } catch ( SQLException sqle ) { // 2. try String msg = "Catch do resgate do login/SQL : " + " : " + sqle.getMessage(); throw new Exception(msg); } finally { if(stmt != null) stmt.close(); Conectar.FechaConexao(Conexao); } } // if } catch ( SQLException sqle ) { // 1. try String msg = "Catch da pesquisa o login/SQL : " + " : " + sqle.getMessage(); throw new Exception(msg); } finally { if(stmt != null) stmt.close(); Conectar.FechaConexao(Conexao); } } // if erro %>