Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67618
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Greenhorn
Posts: 18
jQuery Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
jQuery Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
jQuery Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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





 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic