The jsp interface I wrote yesterday encountered such a problem. A 500 error occurred every time it was accessed. It was an abnormal error in the java code. After debugging for a long time, I didn't find any problem with the code, and I felt very desperate.
The error message is as follows:
The code is as follows:
<div> list = (ArrayList<jsonobject>)request.getAttribute("newsList"); for(JSONObject j: list){ %> <a>"></a> <p>...</p> </jsonobject> </div>
According to the error message, I found that the problem lies in this line of code:
ArrayList<jsonobject> list = (ArrayList<jsonobject>)request.getAttribute("newsList");</jsonobject></jsonobject>
Intuitively, there is no error, and the parameter name in request.getAttribute("newsList") is not wrong either.
The corresponding servlet also reads the contents of the database.
Why is a 500 error reported?
The code is modified as follows:
<div> list = (ArrayList<jsonobject>)request.getAttribute("newsList"); if (list != null && list.size()!=0){ for(JSONObject j: list){ %> <a>"></a> <p>...</p> </jsonobject> </div>
That is, non-empty judgment is made between directly traversing the printing list! ! !
This also provides me with great inspiration for writing code in the future.
There is still a long way to go in terms of code specifications, coding habits and code rigor! ! !
The above is the detailed content of What is 500 error in jsp. For more information, please follow other related articles on the PHP Chinese website!