Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<jsp:forward page=""/> not working

 
abhiavi kumar
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my .JSP file, there are two <jsp:forward page> in this code, the one in the "else" part works, while the other does not.



Everything actually works as it should, if the required details are entered and correct, the "password" value in the "Login" table of my backend does get updated, but after that, the code <jsp:forward page="home.html"/> does not work, all I see is a white page with nothing on it.

The <jsp:forward page = login.jsp"/> code in my else part does work though, it works as intended if the entered details are wrong or if nothing is entered (The required details are entered in the previous page).

The problem seems to be because of "ResultSet bs = np.executeQuery();", if I remove this, the <jsp:forward page="home.html"/> does work like it should. but I need this code to update the password in my table. so is there any reason for <jsp:forward page> to not work after an update?

thanks...


 
Stefan Evans
Bartender
Posts: 1778
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#1: Check your logs for an error message.

#2: None of this code belongs in a JSP. Put java code in a java class. There is absolutely no presentation logic here, it should be in a servlet.

#3: Use a JNDI datasource rather than opening a new database connection every time would be preferable.


 
jagrutkumar dalwadi
Ranch Hand
Posts: 83
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also jsp file is used for showing data/view purpose only. It should not contain Business logic or controller related code.
Controller related code should be in servlet and business logic should be in Pojo.
As per the good programming practise, scriptlets should not be used in jsp file, rather use jsp standard actions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic