Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8314405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:48:29+00:00 2026-06-08T20:48:29+00:00

This is my first attempt in exchanging values between 2 JSP pages, the index.jsp

  • 0

This is my first attempt in exchanging values between 2 JSP pages, the index.jsp page has a log in form, and the login.jsp page will validate this login, if login is unsuccessful, it will redirect to the index.jsp along with a parameter called valid, with a value of 0, if its successful, the value will be 1.

index.jsp

<%@page import="javax.enterprise.inject.spi.Bean"%>
<%@page import="myDatabase.Login"%> //this is class that I created
<%@page import="myDatabase.JavaDB"%> //this is a class that I created
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="indexCSS.css" />
        <title>Chat</title>

    </head>
    <body>
        <jsp:include page="login.jsp">
        <jsp:param name="valid" value="1"/>
        </jsp:include>  
        <% String valid = request.getParameter("valid");%>
        <div class="mainPage">
            <div id="header">
                <div id="pageTitle">
                    Chat
                </div>
            </div>
            <div id="loginBox">
                <form name="login" action="login.jsp" method="POST">

                    <div id="loginItems">
                        <div id="loginTitle">
                            Log in
                        </div>
                        <hr style="color:green;">
                        <div style="margin-top:17px; overflow:hidden;">
                            <label for="id">
                                ID
                            </label>
                            <span id="idError" class="error">
                                    <% if(valid.equals("0")) { %>is not valid<% } %>

                            </span>
                            <br>
                            <input class="inputText" type="text" name="id" value="" maxlength="10" autocomplete="off"/>
                        </div>
                        <div style="margin-top:17px; overflow:hidden;">
                            <label for="password">
                                Password
                            </label>
                            <span id="passwordError" class="error">

                            </span>
                            <br>
                            <input class="inputText" type="password" name="password" value="" maxlength="32" autocomplete="off"/>
                        </div>
                        <div style="margin-top:17px; overflow:hidden;">
                            <div>
                                Forgot your Password?
                            </div>
                        </div>
                        <div style="margin-top:17px; position:relative; overflow:hidden">
                            <input class="inputButton" type="submit" value="Log in" name="loginButton" />
                        </div>
                    </div>
                </form>
            </div>
        </div> 
    </body>
</html>

this is the login.jsp

<head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <jsp:useBean id="loginBean" scope="session" class="myDatabase.Login" />
        <jsp:setProperty name="loginBean" property="id" />
        <jsp:setProperty name="loginBean" property="password" />
        <%
            JavaDB myJavaDB=new JavaDB();
            myJavaDB.Connect("IULChat","iul","iul");
           if(myJavaDB.isConnected()==true){
                    //response.sendRedirect("index.jsp?a=2");
                    Login myLogin = new Login(loginBean.getId(),loginBean.getPassword());
                    myLogin.setConn(myJavaDB.getMyConnection());
                    myLogin.login(); loginBean.setId(0); loginBean.setPassword("");
                    if(myLogin.isValid()==true)
                                               {
                        response.sendRedirect("index.jsp?valid=1");
                    }
                    else
                                               {
                        response.sendRedirect("index.jsp?valid=0");
                    }
                                       }
            else
                out.println("no");
        %>

    </body>
</html>

When I run the project I get this error.

type Exception report

message

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 3.1.2 logs.

This error goes away if I delete the java codes in this section

                    <span id="idError" class="error">
                            <% if(valid.equals("0")) { %>is not valid<% } %>
                    </span>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:48:31+00:00Added an answer on June 8, 2026 at 8:48 pm

    The page is probably throwing NullPointerException because value of ‘valid’ is null.
    Always make string comparisons with literals using format

    <literal>.equals(<variable>)
    

    Try using the following updated lines of code:

    <span id="idError" class="error">
        <% if("0".equals(valid)) { %>is not valid<% } %>
    </span>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my first attempt to throw data back and forth between a local
This is my first attempt at responsive design, so I'm keeping it simple. I
This is my first attempt to write shorthand if statements however am befuddled by
this if my first attempt at using streaming for WCF, and I am struggling
This is my first attempt to create a GUI in MATLAB. I haven't been
this is my first attempt at a responsive design so excuse me if this
Because this is my first attempt at an extension method that seems quite useful
Up front: This is my first attempt at an Android app. I'm in that
This is pretty strange (admitedly, this is my first attempt with python / sqlite),
I'm trying to create a simple threading procedure (granted this is my first attempt

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.