Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP page with java functionality inside shows mistake (jsp, servlet, mysql)  RSS feed

 
Eduard Tarassov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone! I am having a problem with my jsp page with some java functionality inside.
My project is a servlet/jsp project with connection to the database MySQL.
My jsp page (Which I open from servlet doGet method by redirection) is a simple profile.jsp page which takes from java containers all the required information about the user info. And in the bottom it has a link to update profile page (which simply sends request to servlet doPost to update user info).
Here is my code:


And after I push the "Update your profile information" link in my browser, it just opens blank page and shows next error lines in my run output:

https://drive.google.com/file/d/0ByZXQ2R3O8B8UjNib1NsSHlCUVU/view?usp=sharing

I feel like I miss something very very obvious, please help! Thank you in advance!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mentioned "redirection" as the method from getting from a servlet to that JSP? If you really redirected instead of forwarding, then that creates a new request. Your code is expecting to get an attribute from the request, but since the browser produced a new request then it isn't going to contain that attribute. And therefore you're getting a NullPointerException. You should really be forwarding the request anyway, rather than redirecting it.

I expect you'll see that exception if you scroll down and look farther down the stack trace. By the way it would be more helpful if you just pasted the stack trace into your post rather than making us go to another site to see it.
 
Eduard Tarassov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh, sorry. I am exactly forwarding the request back to profile.jsp. And this jsp file sshows all the information correctly (all the information about the user).
But when I touch the link to update_profile.jsp, then it shows null pointer exception and Jasper exception.

Here is my servlet method which forwards information back.
 
Eduard Tarassov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I found the problem. Can't figure out how to solve it.
So I am calling servlet Profile from the index.jsp (with using @webservlet annotation). After all data gathered, my servlet forwards back to the profile.jsp (so the path becomes something like that: http://localhost:1919/Profile/username) which process the data. And after clicking the link the path becomes http://localhost:1919/Profile/update_profile.jsp but not http://localhost:1919/update_profile.jsp as I supposed to have.
So as I understood my jsp launches servlet repeatedly, rather than just go to the update_profile.jsp page. Could you help me please to understand why and how to solve it? Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!