Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

JOptionPane problem  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello boys and girls,
I have a jsp page that pops to me this error (I know it is about my JOptionPane)

HTTP Status 500 - Internal Server Error

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
root cause

java.lang.NullPointerException
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.1.1 logs.

GlassFish Server Open Source Edition 4.1.1


and the following is my code, let me know what I am doing wrong, a part form being born

<%@page import="BEAN.LoginBEAN"%>
<%@page import="DAO.LoginDAO"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form ACTION="Entraste.jsp" METHOD="POST">
            <h1>Iniciar Sesion</h1>
            USUARIO <input type="text" name="txtUsu" value="Ingresar Usuario">
            PASSWORD <input type="password" name="txtPas" value="">
            <input type="submit" name="btnClickPapa" value="Entrar">
        </form>
            <%
                String usuario = request.getParameter("txtUsu");
                String password = request.getParameter("txtPas");
                if(usuario.equals(null) || password.equals(null))
                {
                    %><font color="red">¡Usuario o Contraseña vacios!</font><%
                }
                else
                {
                    %><font color="red">¡Usuario o Contraseña incorrectos!</font><%
                }
                LoginBEAN hola = new LoginBEAN(usuario, password);
                LoginDAO bola = new LoginDAO();
            %>
    </body>
</html>
 
Rancher
Posts: 3596
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something in that Java code is null, probably either username or password.

This would have been easier to trace if that code had been in a servlet as it should be.
JSPs should not have Java scriptlets in them.

This:

is not the way to check for null.
If 'usuario' is actually null then this will cause your exception.
You need to do this instead:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!