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 null pointer exception after response.sendRedirect() in jsp page. 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 "null pointer exception after response.sendRedirect() in jsp page." Watch "null pointer exception after response.sendRedirect() in jsp page." New topic
Author

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

Daniel Stege Lindsjo
Greenhorn

Joined: Jun 28, 2010
Posts: 13
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

Joined: Jan 10, 2002
Posts: 60804
    
  65

java.lang.NullPointerException
at com.verify.web.LoginUser.doPost(LoginUser.java:26)

What's at line 26?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Daniel Stege Lindsjo
Greenhorn

Joined: Jun 28, 2010
Posts: 13
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

Joined: Jan 13, 2010
Posts: 18

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

Joined: Jun 28, 2010
Posts: 13
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

Joined: Jun 28, 2010
Posts: 13
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

Joined: Jan 13, 2010
Posts: 18

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

Joined: Jan 13, 2010
Posts: 18

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
 
subject: null pointer exception after response.sendRedirect() in jsp page.
 
Similar Threads
No configuration found for the specified action
Jboss portal starting issue
href path changes in jsp on redirecting the servlet to that jsp
web app
problem with basic jsf tags in the jsp