This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Value in the else condition is getting printed as the page loads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Value in the else condition is getting printed as the page loads" Watch "Value in the else condition is getting printed as the page loads" New topic
Author

Value in the else condition is getting printed as the page loads

sanidhya kumar
Greenhorn

Joined: Sep 05, 2012
Posts: 18
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Posting just code without an explanation isn't going to get you much help. Just posting some text in the subject is not enough.

Please explain in detail what the problem is (beside using scriptlets in a modern JSP )


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sanidhya kumar
Greenhorn

Joined: Sep 05, 2012
Posts: 18
sanidhya kumar wrote:
the message in else statement is getting printed as the page loads,
but it should have been printed only if user name and password is wrong.

sanidhya kumar
Greenhorn

Joined: Sep 05, 2012
Posts: 18
sanidhya kumar wrote:
sanidhya kumar wrote:
the message in else statement is getting printed as the page loads,
but it should have been printed only if user name and password is wrong.
please see line no 64

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Well, I'm sure you know that I'm going to tell you that putting Java code into a JSP, especially database access, is a really bad practice that causes lots of problems, including ones like this.

My advice: move the Java code into Java classes, and use the JSTL and EL on the page rather than obsolete and discredited scriptlets.
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
Do you intentionally drop the first element of rs?

William P O'Sullivan
Ranch Hand

Joined: Mar 28, 2012
Posts: 860

Ivan is correct.

The first rs.next() advances the rs pointer, so if only 1 result then the while rs.next() is false

leading to ... ?

WP
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Value in the else condition is getting printed as the page loads
 
Similar Threads
org.apache.jasper.JasperException: java.lang.NullPointerException
Redirecting a page
Value in the else condition is getting printed as the page loads
INCLUDES.DBconnection error
The requested resource (Servlet action is not available) is not available. ...