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 My JSP Syntax is correct but still getting 500 error code 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 "My JSP Syntax is correct but still getting 500 error code" Watch "My JSP Syntax is correct but still getting 500 error code" New topic
Author

My JSP Syntax is correct but still getting 500 error code

Alfie Christopher
Greenhorn

Joined: Nov 03, 2010
Posts: 3
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

Joined: Jan 10, 2002
Posts: 60800
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Alfie Christopher
Greenhorn

Joined: Nov 03, 2010
Posts: 3
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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

Joined: Nov 03, 2010
Posts: 3
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.
 
 
subject: My JSP Syntax is correct but still getting 500 error code
 
Similar Threads
cannot connect to microsoft access with jsp
Axis2 - WSDL to code
what is this error
Error while jsp connecting to database
Could not parse configuration hibernate.cfg.xml