Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My JSP Syntax is correct but still getting 500 error code

 
Alfie Christopher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an error page to capture the exceptions but the page itself is giving me 500 error code ... can someone interpret it please ?



Thanks in advance
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

A helpful hint: Please be sure to take the time to compose descriptive subjects for your posts. You will attract people who will can give you better and faster answers when your posts have good, descriptive subjects. For more information, please click this link ⇒ UseAMeaningfulSubjectLine.

Using a title such as "I need some help" isn't going to attract the attention of those who can best help you.

You can change your subject line by clicking the button on your post.
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alfie, why are you doing a jsp:forward in your page?? Because of that your JSP page tries to do a server side forward on the request and fails as the response has already been committed to the client...
 
Alfie Christopher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the Reply

Due to some reason I kept getting database connection exceptions thrown only if the site was idle for certain time... so as remedy I was advised to handle the exception with an error page.. if I do not have the forward it will show the error page.. I did not want the people to see the error page.. instead I thought why not forward it to index page should there be an exception or error.. technically it should work.. should not it ?

Please explain what do you mean saying "response has already been committed to the client"
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the response headers and initial text created by the JSP have been sent, we say the "response has been committed" - at that point it is illegal to forward to another page and you get that exception.

To avoid this, do not send any output until you are sure you can complete the JSP page. Good design practice is to do all the database work in a servlet and only forward to a JSP page when you are sure it can be completed.

Bill
 
Alfie Christopher
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bill That explains it all I use the JNDI connection for database and I found similar issue is faced by many others as well. but what if I just give only the forward without any response ? and should say the exception is thrown only once in a while.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic