File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

null pointer exception after response.sendRedirect() in jsp page.

 
Daniel Stege Lindsjo
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all

On my current project I managed to create a form that allows me to add users to a DB.
Now my only concern is that after using response.sendRedirect() I get redirected to "http://localhost:8080/dt/pages/main.jsp". But when I try to sign in via username and password i get a NULL pointer exception at adress: http://localhost:8080/dt/pages/login.do.

500 Servlet Exception


[show] java.lang.NullPointerException

java.lang.NullPointerException
at com.verify.web.LoginUser.doPost(LoginUser.java:26)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:153)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:91)
at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103)
at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:187)
at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:265)
at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:273)
at com.caucho.server.port.TcpConnection.run(TcpConnection.java:682)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:743)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:662)
at java.lang.Thread.run(Thread.java:637)



My Index.jsp used to send the redirect has the following content:


I've also tried to feed the relative URL directly to sendRedirect() like this:


But I get the same result.
I'm using Resin 3.1.9 for the project.


D
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64184
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NullPointerException
at com.verify.web.LoginUser.doPost(LoginUser.java:26)

What's at line 26?
 
Daniel Stege Lindsjo
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At Line 26 and 27 in LoginUser.java:




Just a check for an empty username.

Here is the entire code for LoginUser.java:



It is no where near done yet. But the class was working just fine before I had to use the reponse.redirect function.

 
Ernesto Chicas
Greenhorn
Posts: 18
Debian Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is in your servlet not in the sendRedirect, is clearly a NullPointeException because you are not sending the parameters



do a in doPost, and if you do


you will get NullPointerException.

Attempts to send the parameter from


greetings and good luck


 
Daniel Stege Lindsjo
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The parameter cannot be set from the index file.
At this point the form is not accepting any data at all. No matter what I enter into userName and password the result of uName is always NULL. God this is driving me insane :S

If there is anybody out there that can see the error please respond. I've been fighting with this error for days now.


D
 
Daniel Stege Lindsjo
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally got the error *facepalm*

The correct version of the form in main is like this:



Dreamweaver had messed up the form causing the fields to be outside the </form> tag.
I can't believe something so trite could drive me nuts hehe.


D


 
Ernesto Chicas
Greenhorn
Posts: 18
Debian Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, try to do something like this


the problem is that you try to get the size of a string that is null


NullPointerException

I hope this helps if you
 
Ernesto Chicas
Greenhorn
Posts: 18
Debian Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Stege Lindsjo wrote:I finally got the error *facepalm*

The correct version of the form in main is like this:



Dreamweaver had messed up the form causing the fields to be outside the </form> tag.
I can't believe something so trite could drive me nuts hehe.


D





 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic