Programación General > JSP/Servlets
Aplicacion JSP no funciona en servidor pero si en local
(1/1)
Dr0gNan:
Estoy haciendo una pequeña aplicacion de gestion. La he subido a un servidor de JSP pero una de las paginas (NuevoCliente.jsp) no funciona al ejecutar el evento del boton Guardar. Se queda con el parametro del servlet en la URL y con la pagina en blanco.
Os pongo el codigo a continuacion y la direccion de la pagina para que lo veais vosotros mismos:
Codigo servlet:
--- Código: Java ---package servlets; import java.io.IOException;import java.sql.ResultSet;import java.sql.SQLException; import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse; import classes.Conexion; /** * Servlet implementation class NuevoClienteServlet */public class NuevoClienteServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public NuevoClienteServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Conexion.Inicializar(); Conexion.Conectar(); //Carga de campos de la pagina JSP String nombreCliente = request.getParameter("txtNombre").trim(); String apellidosCliente = request.getParameter("txtApellidos"); String direccionCliente = request.getParameter("txtDireccion"); String telefonoCliente = request.getParameter("txtTelefono").trim(); String emailCliente = request.getParameter("txtEmail").trim(); if (!nombreCliente.isEmpty() || !apellidosCliente.isEmpty() || !direccionCliente.isEmpty() || !telefonoCliente.isEmpty() || !emailCliente.isEmpty()) { String sqlSentencia = "INSERT INTO cliente (nomcli, apecli, dircli, telcli, emailcli) VALUES ('" + nombreCliente + "' , '" + apellidosCliente + "' , '" + direccionCliente + "' , '" + telefonoCliente + "' , '" + emailCliente + "')"; //System.out.println(sqlSentencia); int errorSQL = Conexion.Actualizacion(sqlSentencia); if (errorSQL != 1) { System.out.println("Error de SQL"); } else { System.out.println("Registro insertado"); } } else { System.out.println("Campos vacios"); } if (request.getParameter("btnGuardarNuevo")!=null) { response.sendRedirect("NuevoCliente.jsp"); } else if(request.getParameter("btnGuardar")!=null) { try { ResultSet tabla = Conexion.Consulta("select auto_increment from `information_schema`.tables where TABLE_SCHEMA = 'informatica' and TABLE_NAME = 'cliente'"); while (tabla.next()) { //Restamos uno ya que el codigo que devuelve la consulta es el siguiente int codigoCliente = tabla.getInt("auto_increment")-1; String URL = "DetalleCliente.jsp?codCliente=" + codigoCliente; response.sendRedirect(URL); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Conexion.Cerrar(); }}
La parte que no funciona en el servidor es la siguiente:
--- Código: Java --- else if(request.getParameter("btnGuardar")!=null) { try { ResultSet tabla = Conexion.Consulta("select auto_increment from `information_schema`.tables where TABLE_SCHEMA = 'informatica' and TABLE_NAME = 'cliente'"); while (tabla.next()) { //Restamos uno ya que el codigo que devuelve la consulta es el siguiente int codigoCliente = tabla.getInt("auto_increment")-1; String URL = "DetalleCliente.jsp?codCliente=" + codigoCliente; response.sendRedirect(URL); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
La funcion que tiene que hacer la pagina es Guardar los datos en la BBDD (lo hace correctamente) y despues redireccionar a la pagina de detalle del registro que he creado. El redireccionamiento es lo que no hace.
Esta subido en esta direccion:
--- Código: Text ---dr0gnan.s23.eatj.com/NuevoCliente.jsp
Gracias, un saludo. :good:
arielb:
y has podido ver si está cargando DetallesCliente.jsp?, es decir si llega al código de dicha página.
Dr0gNan:
Si, si por URL le pasas el codigo de cliente lo muestra correctamente.
Ahora da error en el sitio debido a un cambio que hice.
Navegación
Ir a la versión completa