Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem loading css or js file

2890509Feb 23 2015 — edited May 11 2015

Hello,

I am relatively new in java and I am trying to do a simple CRUD with Servlets and JSP. I am working with netbeans 8, and I have a Servlet that call the JSP pages.

When I run the application, Servlet call a login.jsp and if validation is true, then it call index.jsp

The problem occurs when one jsp page want to load a css file, then jsp page doesn't load the css file!

I tried debugging with firebug page, but I don't found the problem.

Some idea because this malfunction?

I paste part of code of servlet:

@Override

    protected void doGet(HttpServletRequest request, HttpServletResponse response)

            throws ServletException, IOException {

        String accion = request.getParameter("accion");

        HttpSession sesion = request.getSession();

    if (accion != null) {

            if (accion.equals("login")) {

             logger.info("doGet - Login");

          setRespuestaControlador(accion).forward(request, response);

       }

       else if (accion.equals("inicio")) {

             logger.info("doGet - inicio");

          setRespuestaControlador("index").forward(request, response);

           }

           else if (accion.equals("insertIngEgr")) {

             logger.info("doGet - insertingegre");

        setRespuestaControlador(accion).forward(request, response);

        }

     }

     else {

         setRespuestaControlador("login").forward(request, response);

             logger.info("doGet - login por else");

     }

        try {

       con.close();

    }

    catch (SQLException e) {

        // Enviar a una vista de error

         logger.log(Level.SEVERE,"Error al cerrar conexion: " + e.getMessage());

    }

    }

   

    @Override

    protected void doPost(HttpServletRequest request, HttpServletResponse response)

            throws ServletException, IOException {

        String accion = request.getParameter("accion");

        HttpSession sesion = request.getSession();

       

        if (accion != null) {

       if (accion.equals("iniciarSesion")) {

          String usuario = request.getParameter("usuario");

              String contrasena = request.getParameter("contrasena");

               

          Login login = new Login(con);

               

          if (login.login(usuario, contrasena)) {

                 logger.info("dopost - iniciarsession");

                

                 sesion.setAttribute("id", new AdministradorDao(con).obtenerIdAdmin(usuario));

         setRespuestaControlador("index").forward(request, response);

          }

          else {

             logger.info("Error de login");

                

                 // genera una variable error

                 request.setAttribute("error", "Nombre de Usuario o Contraseña Incorrecta !");

                

                 // reenvia al formulario login                 

                 setRespuestaControlador("login").forward(request, response);

        }

           }

        }

    else {

            logger.info("dopost - login por que se yo");

        setRespuestaControlador("login").forward(request, response);

    }

       

    try {

       con.close();

    }

    catch (SQLException e) {

        // Enviar a una vista de error

         logger.log(Level.SEVERE,"Error al cerrar conexion: " + e.getMessage());

    }

    }

   

And part of jsp view that doesn't load css file:

<%@page contentType="text/html" pageEncoding="UTF-8"%>

<!DOCTYPE html>

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <link href="../css/jquery-ui.css" rel="stylesheet" type="text/css">

        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>

        <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

        <script type="text/javascript">

            $(document).ready(function() {

                $("#fecha").datepicker({

                    dateFormat: 'dd/mm/yy',

                    dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'],

                    monthNames: ['Enero', 'Febrero', 'Martes', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']

                });

            });

        </script>

    </head>

    <body>

I appreciate your willingness and time!

Fernando

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 8 2015
Added on Feb 23 2015
1 comment
2,137 views