Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your code logic is odd. Scriptlets also doesn't make testing more easy. Here's an <a href="http://sscce.org" rel="nofollow noreferrer">SSCCE</a> in flavor of a real Java class to kickoff and ease testing:</p> <pre><code>public class Test { public static void main(String[] args) throws Exception { String user = "WeBeNg"; // Change this as if it is user input. String pass = "2009"; // Change this as if it is user input. String expectedUser = "webeng"; String expectedPass = "2009"; if (user == null || pass == null || user.isEmpty() || pass.isEmpty()) { System.out.println("Please enter both username and password."); } else if (user.equalsIgnoreCase(expectedUser) &amp;&amp; pass.equals(expectedPass)) { System.out.println("Welcome " + user); } else { System.out.println("Unknown login."); } } } </code></pre> <p>Hope this helps.</p> <p><strong>Edit #1</strong>: please do not post screenshots. Copypaste the exception and stacktrace in code blocks. The exception is by the way not coming from Eclipse. It's coming from Tomcat. Also, the exception in question (NullPointerException) is fairly self-explaining. You accessed an object reference which is actually null. </p> <pre><code>SomeObject someObject = null; someObject.doSomething(); // Fails with NPE. someObject = new SomeObject(); someObject.doSomething(); // Succes. </code></pre> <p>You need to do a null-check first, e.g.</p> <pre><code>if (someObject != null) { someObject.doSomething(); // Succes. } </code></pre> <p><strong>Edit #2</strong> I also recommend you to learn about operators, operator precedence and expression grouping in Java. See, the following isn't "logical"</p> <pre><code>if (name !=null | pass!=null &amp;&amp; name.equals("") | pass.equals("")) </code></pre> <p>Here's a good tutorial to start with to learn about this: <a href="http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html" rel="nofollow noreferrer">http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html</a> Good luck.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload