Browse Source

Servicios

master
DANIEL IVAN ESTRADA MORANDO 6 months ago
parent
commit
3a172de031
  1. 4
      InventarioJakartaJIN-war/src/java/mx/edu/tsj/chapala/sistemas/jin/seguridad/Listener.java
  2. 87
      InventarioJakartaJIN-war/src/java/mx/edu/tsj/chapala/sistemas/jin/servicios/ProductosServlet.java
  3. 8
      InventarioJakartaJIN-war/web/vistaLogin.xhtml

4
InventarioJakartaJIN-war/src/java/mx/edu/tsj/chapala/sistemas/jin/seguridad/Listener.java

@ -36,7 +36,7 @@ public class Listener implements PhaseListener {
//Revisar que no sea la pafina index y que no estes logueado //Revisar que no sea la pafina index y que no estes logueado
//para redireccionar //para redireccionar
if (!paginaActual.contains("vistaLogin.xhtml") && Login.getEstatus() == false) { if (!paginaActual.contains("vistaLogin.xhtml") && Login.getEstatus() == false) {
FacesContext.getCurrentInstance().getExternalContext().redirect("faces/vistaLogin.xhtml?faces-redirect=true"); FacesContext.getCurrentInstance().getExternalContext().redirect("faces/vistaLogin.xhtml");
NavigationHandler nh = event.getFacesContext().getApplication().getNavigationHandler(); NavigationHandler nh = event.getFacesContext().getApplication().getNavigationHandler();
nh.handleNavigation(event.getFacesContext(), null, "vistaLogin"); nh.handleNavigation(event.getFacesContext(), null, "vistaLogin");
@ -54,4 +54,4 @@ public class Listener implements PhaseListener {
return PhaseId.RESTORE_VIEW; return PhaseId.RESTORE_VIEW;
} }
} }

87
InventarioJakartaJIN-war/src/java/mx/edu/tsj/chapala/sistemas/jin/servicios/ProductosServlet.java

@ -0,0 +1,87 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
*/
package mx.edu.tsj.chapala.sistemas.jin.servicios;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author estra
*/
@WebServlet(name = "ProductosServlet", urlPatterns = {"/ProductosServlet"})
public class ProductosServlet extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet ProductosServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet ProductosServlet at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}

8
InventarioJakartaJIN-war/web/vistaLogin.xhtml

@ -32,13 +32,13 @@
<div class="ui-input-icon-left"> <div class="ui-input-icon-left">
<span class="ui-input-icon-left" style="width: 370px; padding-top: 15px; padding-bottom: 15px;" > <span class="ui-input-icon-left" style="width: 370px; padding-top: 15px; padding-bottom: 15px;" >
<i class="pi pi-angle-right" style="padding-bottom: 12px;"></i><input id="contra" name="contraseña" type="password" <i class="pi pi-angle-right" style="padding-bottom: 12px;"></i>
class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" <input id="contra" name="contraseña" type="password" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all"
placeholder="Contraseña" required="true" requiredMessage="La contraseña es requerida"/> placeholder="Contraseña" required="true" requiredMessage="La contraseña es requerida" />
</span> </span>
</div> </div>
</h:panelGrid> </h:panelGrid>
<p:commandButton value="Entrar" update="growl" icon="pi pi-sign-in" styleClass="ui-button-raised ui-button-secondary" action="#{login.login()}"/> <p:commandButton value="Entrar" update="growl" icon="pi pi-sign-in" styleClass="ui-button-raised ui-button-secondary" action="#{login.login()}" />
<h:messages styleClass="error-message" /> <h:messages styleClass="error-message" />
</div> </div>
</h:form> </h:form>

Loading…
Cancel
Save