see jsp:useBean
have print statements to debug
Main Topics
Browse All TopicsHi All,
Yesterday I sent a question. I got the solution but I tried to implement all still am not getting solved. Still am getting the error in the condition "if (idHandler.authenticate(us
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
15: <%
16: String userName = request.getParameter("user
17: String passWord = request.getParameter("pass
18: if (idHandler.authenticate(us
19: System.out.println("login is successfull");
20: } else {
21: response.sendRedirect("ret
Stacktrace:
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NullPointerExcep
com.mycompany.login.Login.
org.apache.jsp.validateuse
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
Please get me a solution. I attached the code below.
Thank you.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
<jsp:useBean id="idHandler" class="com.mycompany.login
<jsp:setProperty name="idHandler" property="*"/>
</jsp:useBean>
This will access your bean, for a better understanding of the tag
refer : http://www.jsptut.com/Form
idHandler.authenticate(use
here idHandler is actually not defined.. you have to import your class and then validate.
go through the useBean and get back to me
Hi kadaba
I did the changes as you told. But once i fill the username and the password and click the submit button am getting this error. Am getting this error on UI screen only. The error as follows:
HTTP Status 404 - /project2/validateuser.jsp
--------------------------
type Status report
message /project2/validateuser.jsp
description The requested resource (/project2/validateuser.js
--------------------------
Apache Tomcat/6.0.20
1) make sure all your pages are in one folder say pages and try
else make sure you set the path right . right click on validate user.jsp and run it on the server see the path, in index page you need to give the same path(relative path)
2) public boolean authenticate(String user, String pass) should be made static
as
public static boolean authenticate(String user, String pass)
All the pages are in same folder and i changed "public boolean authenticate(String user, String pass) to "public static boolean authenticate(String user, String pass)" .But when I tried to run validateuser.jsp,its giving the error like
HTTP Status 500 -
--------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
14: <%
15: String userName = request.getParameter("user
16: String passWord = request.getParameter("pass
17: if (login.authenticate(userNa
18: {
19: out.println("login is successfull");
20: }
Stacktrace:
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NullPointerExcep
com.mycompany.login.login.
org.apache.jsp.validateuse
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
--------------------------
Apache Tomcat/6.0.20
Hi kadaba
All the pages are in same folder and i changed "public boolean authenticate(String user, String pass) to "public static boolean authenticate(String user, String pass)" .But when I tried to run validateuser.jsp,its giving the error like
HTTP Status 500 -
--------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
14: <%
15: String userName = request.getParameter("user
16: String passWord = request.getParameter("pass
17: if (login.authenticate(userNa
18: {
19: out.println("login is successfull");
20: }
Stacktrace:
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NullPointerExcep
com.mycompany.login.login.
org.apache.jsp.validateuse
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
--------------------------
Apache Tomcat/6.0.20
Hi kadaba
I changed the getConnection part as your previous reply but when i tried to run validateuser.jsp am getting the error like
Oct 8, 2009 1:06:44 PM org.apache.tomcat.util.dig
WARNING: [SetPropertiesRule]{Server
Oct 8, 2009 1:06:44 PM org.apache.catalina.core.A
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\W
Oct 8, 2009 1:06:44 PM org.apache.coyote.http11.H
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 8, 2009 1:06:44 PM org.apache.catalina.startu
INFO: Initialization processed in 363 ms
Oct 8, 2009 1:06:44 PM org.apache.catalina.core.S
INFO: Starting service Catalina
Oct 8, 2009 1:06:44 PM org.apache.catalina.core.S
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
Oct 8, 2009 1:06:44 PM org.apache.coyote.http11.H
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 8, 2009 1:06:44 PM org.apache.jk.common.Chann
INFO: JK: ajp13 listening on /0.0.0.0:8009
Oct 8, 2009 1:06:44 PM org.apache.jk.server.JkMai
INFO: Jk running ID=0 time=0/16 config=null
Oct 8, 2009 1:06:44 PM org.apache.catalina.startu
INFO: Server startup in 282 ms
ClassNotFoundException: com.mysql.jdbc.Driver
The connection object is null
Oct 8, 2009 1:18:10 PM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerExcep
at com.mycompany.login.login.
at org.apache.jsp.validateuse
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
ClassNotFoundException: com.mysql.jdbc.Driver
The connection object is null
Oct 8, 2009 1:22:03 PM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerExcep
at com.mycompany.login.login.
at org.apache.jsp.validateuse
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
Am fininding difficult to understand the error "ClassNotFoundException: com.mysql.jdbc.Driver" in the above console. What exactly the error could be?
And when i tried to run "index.jsp" am getting the error like
HTTP Status 404 - /project2/validateuser.jsp
--------------------------
type Status report
message /project2/validateuser.jsp
description The requested resource (/project2/validateuser.js
--------------------------
Apache Tomcat/6.0.20
Please help me with the things.
Hi kadaba
I did as you said.Now am not getting "class not found" exception.
But now i tried to run the index.jsp.Their after giving username and password and clicking the submit button, am getting the error like
HTTP Status 404 - /project2/validateuser.jsp
--------------------------
type Status report
message /project2/validateuser.jsp
description The requested resource (/project2/validateuser.js
--------------------------
Apache Tomcat/6.0.20
And also i tried to compile validateuser.jsp but am getting the error like
HTTP Status 500 -
--------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NullPointerExcep
com.mycompany.login.login.
org.apache.jsp.validateuse
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
--------------------------
Apache Tomcat/6.0.20
see in your console if you got any exception.... I guess its now not connecting to the database.. .
See according to the logic in getConnection, if you happen to get any exception you will log the error and still return the connection object which will be null.
So you should either get class not found or SQL exception. We first got class not found due to this line
Class.forName("com.mysql.j
check in your console for SQL exception and the reason. If no exception occurs you will get a valid connection object.
Hi kadaba
Yes it is showing null pointer exception.It is showing in the UI screen only. Its all happening after compiling validateuser.jsp.
The errror which is in UI screen is as follows
HTTP Status 500 -
--------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperEx
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
root cause
java.lang.NullPointerExcep
com.mycompany.login.login.
org.apache.jsp.validateuse
org.apache.jasper.runtime.
javax.servlet.http.HttpSer
org.apache.jasper.servlet.
org.apache.jasper.servlet.
org.apache.jasper.servlet.
javax.servlet.http.HttpSer
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
--------------------------
Apache Tomcat/6.0.20
The one which is showing in the system console is as follows
Oct 8, 2009 4:03:20 PM org.apache.tomcat.util.dig
WARNING: [SetPropertiesRule]{Server
Oct 8, 2009 4:03:20 PM org.apache.catalina.core.A
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre6\bin;.;C:\W
Oct 8, 2009 4:03:20 PM org.apache.coyote.http11.H
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 8, 2009 4:03:20 PM org.apache.catalina.startu
INFO: Initialization processed in 366 ms
Oct 8, 2009 4:03:20 PM org.apache.catalina.core.S
INFO: Starting service Catalina
Oct 8, 2009 4:03:20 PM org.apache.catalina.core.S
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
Oct 8, 2009 4:03:20 PM org.apache.coyote.http11.H
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 8, 2009 4:03:20 PM org.apache.jk.common.Chann
INFO: JK: ajp13 listening on /0.0.0.0:8009
Oct 8, 2009 4:03:20 PM org.apache.jk.server.JkMai
INFO: Jk running ID=0 time=0/15 config=null
Oct 8, 2009 4:03:20 PM org.apache.catalina.startu
INFO: Server startup in 264 ms
ClassNotFoundException: com.mysql.jdbc.Driver
The connection object is null
Oct 8, 2009 4:27:07 PM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerExcep
at com.mycompany.login.login.
at org.apache.jsp.validateuse
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
Oct 8, 2009 4:35:10 PM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerExcep
at com.mycompany.login.login.
at org.apache.jsp.validateuse
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
ClassNotFoundException: com.mysql.jdbc.Driver
The connection object is null
ClassNotFoundException: com.mysql.jdbc.Driver
The connection object is null
Oct 8, 2009 4:43:26 PM org.apache.catalina.core.S
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerExcep
at com.mycompany.login.login.
at org.apache.jsp.validateuse
at org.apache.jasper.runtime.
at javax.servlet.http.HttpSer
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at org.apache.jasper.servlet.
at javax.servlet.http.HttpSer
at org.apache.catalina.core.A
at org.apache.catalina.core.A
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.core.S
at org.apache.catalina.valves
at org.apache.catalina.core.S
at org.apache.catalina.connec
at org.apache.coyote.http11.H
at org.apache.coyote.http11.H
at org.apache.tomcat.util.net
at java.lang.Thread.run(Unkno
Hi Bart Cr
I changed the code accroding to the one which u sent but after clicking the submit button in UI screen am getting the error like
HTTP Status 404 - /project2/validateuser.jsp
--------------------------
type Status report
message /project2/validateuser.jsp
description The requested resource (/project2/validateuser.js
--------------------------
Apache Tomcat/6.0.20
Hi kadaba
Thanks for your patience and help. I did everything as it is in zip file which u sent. Now its compiling properly without any error. But the thing is eventhough i give correct username and password its printing "hmmm try again " which is else part of validateuser.jsp.So its not authenticating the username and password. And i got one more doubt. In my database part I gave
Table name as userlogin which I created
Database name as anantha
Username as root
Password as buser
So should I need to change it in " conn = DriverManager.getConnectio
"jdbc:mysql://localhost:33
Yes ... you need to change only this.
conn = DriverManager.getConnectio
"jdbc:mysql://localhost:33
I tested this with the same table name so it should work..[If you happen to change the table name and columns change the query
String sql =
"SELECT USER_NAME,PASSWORD FROM userlogin WHERE USER_NAME='"
+ user + "'" + "AND PASSWORD='" + pass + "'";
]
In the same file you have a main method in the end, you can use it for testing.
Give the user name and password in this file where I have given authenticate("ananth","ana
You right click on the file and run as java application you should be able to test it manually. If this works , run the application on server and it should give the same result.
I will stick around let me know
Hi kadaba
I changed the things but it still giving the same output. I also tried in the main class but it is giving the error which is irrelevant to my code it is giving the error
HTTP Status 404 - /forms1/f2.jsp
--------------------------
type Status report
message /forms1/f2.jsp
description The requested resource (/forms1/f2.jsp) is not available.
--------------------------
Apache Tomcat/6.0.20
But I worked with this f2.jsp yesterday.I dont know why it is showing here. Even I restarted the server and i tried but still am getting the same error. And one more important thing is I haven't created any table within eclipse.I created the tables in a tool called sqlyog. But I have given the same database name,username and password in dbconnection which i have given in sqlyog.
that's weird..
I assume you changed only the Login.java
You need to do this..
right click on the java file, you will have an option to run as java application[DO NOT CHOOSE RUN ON SERVER]
I have given ananth and ananth as the parameters to authenticate, give the user name and password you want to validate.
In your console , see the messages that comes.
so some good news :)
that's ok you can have it in the same work space.
Right click on the web project and run it on the server - while doing so, you will be prompted which all projects will be deployed, you remove all other projects and choose only this project ok and then try this should definitely solve it
if it says resource not found(I am assuming you are using the code I provided which contains the index.jsp as the start up page, so you do not need to do the below , but if its not the case ...)
then in the browser give it as
http://localhost:8080/Te
let me know
when you run on server,
if you dont have an index page it will give you
http://localhost:8080/Test
an
Whats the URL in the browser?
Hi kadaba
Yes am running the code which you gave to me.
When I run on the server am getting this url
http://localhost:8080/Test
After pressing the submit button am getting this url
http://localhost:8080/Test
But Eventhough I give correct username and password, am getting the output "hmmm try again ".
Business Accounts
Answer for Membership
by: Bart_CrPosted on 2009-10-01 at 00:41:17ID: 25466607
Remove the if test in the login:
Select allOpen in new window